djs-selfbot-v13 3.1.7 → 3.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +18 -45
- package/package.json +8 -37
- package/src/client/BaseClient.js +2 -3
- package/src/client/Client.js +187 -539
- package/src/client/actions/Action.js +18 -13
- package/src/client/actions/ActionsManager.js +7 -1
- package/src/client/actions/AutoModerationActionExecution.js +1 -0
- package/src/client/actions/AutoModerationRuleCreate.js +1 -0
- package/src/client/actions/AutoModerationRuleDelete.js +1 -0
- package/src/client/actions/AutoModerationRuleUpdate.js +1 -0
- package/src/client/actions/MessageCreate.js +0 -4
- package/src/client/actions/PresenceUpdate.js +17 -16
- package/src/client/websocket/WebSocketManager.js +11 -31
- package/src/client/websocket/WebSocketShard.js +39 -38
- package/src/client/websocket/handlers/CALL_CREATE.js +3 -3
- package/src/client/websocket/handlers/CALL_DELETE.js +2 -2
- package/src/client/websocket/handlers/CALL_UPDATE.js +2 -2
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +16 -13
- package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
- package/src/client/websocket/handlers/GUILD_CREATE.js +7 -0
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +1 -0
- package/src/client/websocket/handlers/READY.js +47 -137
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +7 -5
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +6 -4
- package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +32 -9
- package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +2 -8
- package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
- package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +78 -0
- package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +1 -5
- package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +12 -0
- package/src/client/websocket/handlers/index.js +15 -20
- package/src/errors/Messages.js +24 -69
- package/src/index.js +12 -43
- package/src/managers/ApplicationCommandManager.js +9 -12
- package/src/managers/ApplicationCommandPermissionsManager.js +3 -11
- package/src/managers/ChannelManager.js +3 -4
- package/src/managers/ClientUserSettingManager.js +161 -279
- package/src/managers/GuildBanManager.js +1 -1
- package/src/managers/GuildChannelManager.js +2 -0
- package/src/managers/GuildForumThreadManager.js +22 -28
- package/src/managers/GuildMemberManager.js +40 -216
- package/src/managers/GuildSettingManager.js +22 -15
- package/src/managers/MessageManager.js +42 -44
- package/src/managers/PermissionOverwriteManager.js +1 -1
- package/src/managers/ReactionUserManager.js +5 -5
- package/src/managers/RelationshipManager.js +81 -74
- package/src/managers/ThreadManager.js +12 -45
- package/src/managers/ThreadMemberManager.js +1 -1
- package/src/managers/UserManager.js +6 -10
- package/src/managers/UserNoteManager.js +53 -0
- package/src/rest/APIRequest.js +42 -20
- package/src/rest/DiscordAPIError.js +17 -16
- package/src/rest/RESTManager.js +1 -21
- package/src/rest/RequestHandler.js +35 -21
- package/src/structures/ApplicationCommand.js +19 -456
- package/src/structures/ApplicationRoleConnectionMetadata.js +3 -0
- package/src/structures/AutoModerationRule.js +5 -5
- package/src/structures/AutocompleteInteraction.js +1 -0
- package/src/structures/BaseGuildTextChannel.js +10 -12
- package/src/structures/BaseGuildVoiceChannel.js +16 -18
- package/src/structures/{Call.js → CallState.js} +17 -12
- package/src/structures/CategoryChannel.js +2 -0
- package/src/structures/Channel.js +2 -3
- package/src/structures/ClientPresence.js +12 -8
- package/src/structures/ClientUser.js +117 -336
- package/src/structures/ContextMenuInteraction.js +1 -1
- package/src/structures/DMChannel.js +29 -92
- package/src/structures/ForumChannel.js +0 -10
- package/src/structures/GroupDMChannel.js +387 -0
- package/src/structures/Guild.js +135 -271
- package/src/structures/GuildAuditLogs.js +0 -5
- package/src/structures/GuildChannel.js +16 -2
- package/src/structures/GuildMember.js +27 -145
- package/src/structures/Interaction.js +1 -62
- package/src/structures/Invite.js +35 -52
- package/src/structures/Message.js +228 -202
- package/src/structures/MessageAttachment.js +11 -0
- package/src/structures/MessageButton.js +1 -67
- package/src/structures/MessageEmbed.js +1 -1
- package/src/structures/MessageMentions.js +3 -2
- package/src/structures/MessagePayload.js +4 -46
- package/src/structures/MessageReaction.js +1 -1
- package/src/structures/MessageSelectMenu.js +1 -252
- package/src/structures/Modal.js +75 -180
- package/src/structures/Presence.js +2 -2
- package/src/structures/RichPresence.js +14 -34
- package/src/structures/Role.js +18 -2
- package/src/structures/SelectMenuInteraction.js +2 -151
- package/src/structures/Team.js +0 -49
- package/src/structures/TextInputComponent.js +0 -70
- package/src/structures/ThreadChannel.js +0 -19
- package/src/structures/User.js +117 -345
- package/src/structures/UserContextMenuInteraction.js +2 -2
- package/src/structures/VoiceState.js +74 -39
- package/src/structures/WebEmbed.js +38 -52
- package/src/structures/Webhook.js +17 -11
- package/src/structures/interfaces/Application.js +146 -23
- package/src/structures/interfaces/TextBasedChannel.js +411 -256
- package/src/util/ApplicationFlags.js +1 -1
- package/src/util/AttachmentFlags.js +38 -0
- package/src/util/Constants.js +106 -284
- package/src/util/Formatters.js +16 -2
- package/src/util/InviteFlags.js +29 -0
- package/src/util/LimitedCollection.js +1 -1
- package/src/util/Options.js +48 -68
- package/src/util/Permissions.js +5 -0
- package/src/util/PurchasedFlags.js +2 -0
- package/src/util/RemoteAuth.js +221 -356
- package/src/util/RoleFlags.js +37 -0
- package/src/util/Sweepers.js +1 -1
- package/src/util/Util.js +76 -36
- package/typings/enums.d.ts +18 -73
- package/typings/index.d.ts +873 -1225
- package/typings/rawDataTypes.d.ts +68 -9
- package/src/client/actions/InteractionCreate.js +0 -115
- package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +0 -23
- package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +0 -11
- package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +0 -55
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.js +0 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +0 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.js +0 -16
- package/src/client/websocket/handlers/INTERACTION_FAILURE.js +0 -18
- package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +0 -30
- package/src/client/websocket/handlers/MESSAGE_ACK.js +0 -16
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
- package/src/managers/DeveloperPortalManager.js +0 -104
- package/src/managers/GuildApplicationCommandManager.js +0 -28
- package/src/managers/GuildFolderManager.js +0 -24
- package/src/managers/SessionManager.js +0 -57
- package/src/rest/CaptchaSolver.js +0 -132
- package/src/structures/ClientApplication.js +0 -204
- package/src/structures/DeveloperPortalApplication.js +0 -520
- package/src/structures/GuildFolder.js +0 -75
- package/src/structures/InteractionResponse.js +0 -114
- package/src/structures/PartialGroupDMChannel.js +0 -433
- package/src/structures/Session.js +0 -81
- package/src/util/Voice.js +0 -1456
- package/src/util/arRPC/index.js +0 -229
- package/src/util/arRPC/process/detectable.json +0 -1
- package/src/util/arRPC/process/index.js +0 -102
- package/src/util/arRPC/process/native/index.js +0 -5
- package/src/util/arRPC/process/native/linux.js +0 -37
- package/src/util/arRPC/process/native/win32.js +0 -25
- package/src/util/arRPC/transports/ipc.js +0 -281
- package/src/util/arRPC/transports/websocket.js +0 -128
package/src/structures/User.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const { Collection } = require('@discordjs/collection');
|
|
4
3
|
const Base = require('./Base');
|
|
5
|
-
const ClientApplication = require('./ClientApplication');
|
|
6
4
|
const VoiceState = require('./VoiceState');
|
|
7
5
|
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
|
8
6
|
const { Error } = require('../errors');
|
|
9
|
-
const { RelationshipTypes
|
|
7
|
+
const { RelationshipTypes } = require('../util/Constants');
|
|
10
8
|
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
|
11
9
|
const UserFlags = require('../util/UserFlags');
|
|
12
10
|
const Util = require('../util/Util');
|
|
@@ -17,8 +15,9 @@ const Util = require('../util/Util');
|
|
|
17
15
|
* @extends {Base}
|
|
18
16
|
*/
|
|
19
17
|
class User extends Base {
|
|
20
|
-
constructor(client, data
|
|
18
|
+
constructor(client, data) {
|
|
21
19
|
super(client);
|
|
20
|
+
|
|
22
21
|
/**
|
|
23
22
|
* The user's id
|
|
24
23
|
* @type {Snowflake}
|
|
@@ -31,52 +30,6 @@ class User extends Base {
|
|
|
31
30
|
|
|
32
31
|
this.flags = null;
|
|
33
32
|
|
|
34
|
-
/**
|
|
35
|
-
* An array of object (connected accounts), containing the following properties:
|
|
36
|
-
* @property {string} type The account type (twitch, youtube, etc)
|
|
37
|
-
* @property {string} name The account name
|
|
38
|
-
* @property {string} id The account id
|
|
39
|
-
* @property {boolean} verified Whether the account is verified
|
|
40
|
-
* @see {@link https://discord.com/developers/docs/resources/user#connection-object}
|
|
41
|
-
* @typedef {Object} ConnectionAccount
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Accounts connected to this user
|
|
46
|
-
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
47
|
-
* @type {?ConnectionAccount[]}
|
|
48
|
-
*/
|
|
49
|
-
this.connectedAccounts = [];
|
|
50
|
-
/**
|
|
51
|
-
* Time that User has nitro (Unix Timestamp)
|
|
52
|
-
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
53
|
-
* @type {?number}
|
|
54
|
-
*/
|
|
55
|
-
this.premiumSince = null;
|
|
56
|
-
/**
|
|
57
|
-
* Time that User has nitro and boost server (Unix Timestamp)
|
|
58
|
-
* @type {?number}
|
|
59
|
-
*/
|
|
60
|
-
this.premiumGuildSince = null;
|
|
61
|
-
/**
|
|
62
|
-
* About me (User)
|
|
63
|
-
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
64
|
-
* @type {?string}
|
|
65
|
-
*/
|
|
66
|
-
this.bio = null;
|
|
67
|
-
/**
|
|
68
|
-
* Pronouns (User)
|
|
69
|
-
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
70
|
-
* @type {?string}
|
|
71
|
-
*/
|
|
72
|
-
this.pronouns = null;
|
|
73
|
-
this._mutualGuilds = [];
|
|
74
|
-
/**
|
|
75
|
-
* [Bot] Application
|
|
76
|
-
* @type {?ClientApplication}
|
|
77
|
-
*/
|
|
78
|
-
this.application = application ? new ClientApplication(this.client, application, this) : null;
|
|
79
|
-
this._partial = true;
|
|
80
33
|
this._patch(data);
|
|
81
34
|
}
|
|
82
35
|
|
|
@@ -107,10 +60,6 @@ class User extends Base {
|
|
|
107
60
|
* @type {?boolean}
|
|
108
61
|
*/
|
|
109
62
|
this.bot = Boolean(data.bot);
|
|
110
|
-
if (this.bot === true && !this.application) {
|
|
111
|
-
this.application = new ClientApplication(this.client, { id: this.id }, this);
|
|
112
|
-
this.botInGuildsCount = null;
|
|
113
|
-
}
|
|
114
63
|
} else if (!this.partial && typeof this.bot !== 'boolean') {
|
|
115
64
|
this.bot = false;
|
|
116
65
|
}
|
|
@@ -147,6 +96,17 @@ class User extends Base {
|
|
|
147
96
|
this.banner ??= undefined;
|
|
148
97
|
}
|
|
149
98
|
|
|
99
|
+
if ('banner_color' in data) {
|
|
100
|
+
/**
|
|
101
|
+
* The user banner's hex
|
|
102
|
+
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
103
|
+
* @type {?string}
|
|
104
|
+
*/
|
|
105
|
+
this.bannerColor = data.banner_color;
|
|
106
|
+
} else if (this.bannerColor !== null) {
|
|
107
|
+
this.bannerColor ??= undefined;
|
|
108
|
+
}
|
|
109
|
+
|
|
150
110
|
if ('accent_color' in data) {
|
|
151
111
|
/**
|
|
152
112
|
* The base 10 accent color of the user's banner
|
|
@@ -176,252 +136,23 @@ class User extends Base {
|
|
|
176
136
|
this.flags = new UserFlags(data.public_flags);
|
|
177
137
|
}
|
|
178
138
|
|
|
179
|
-
if ('
|
|
180
|
-
/**
|
|
181
|
-
* Check how many guilds the bot is in (Probably only approximate) (application.fetch() first)
|
|
182
|
-
* @type {?number}
|
|
183
|
-
*/
|
|
184
|
-
this.botInGuildsCount = data.approximate_guild_count;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
if ('avatar_decoration' in data) {
|
|
139
|
+
if ('avatar_decoration_data' in data) {
|
|
188
140
|
/**
|
|
189
141
|
* The user avatar decoration's hash
|
|
190
142
|
* @type {?string}
|
|
191
143
|
*/
|
|
192
|
-
this.avatarDecoration = data.
|
|
193
|
-
} else {
|
|
194
|
-
this.avatarDecoration ??= null;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* This user is on the same servers as Client User
|
|
200
|
-
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
201
|
-
* @type {Collection<Snowflake, Guild>}
|
|
202
|
-
* @readonly
|
|
203
|
-
*/
|
|
204
|
-
get mutualGuilds() {
|
|
205
|
-
return new Collection(this._mutualGuilds.map(obj => [obj.id, obj]));
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
/**
|
|
209
|
-
* Get all mutual friends (Client -> User)
|
|
210
|
-
* @type {Promise<Collection<Snowflake, User>>}
|
|
211
|
-
* @readonly
|
|
212
|
-
*/
|
|
213
|
-
get mutualFriends() {
|
|
214
|
-
// eslint-disable-next-line no-async-promise-executor
|
|
215
|
-
return new Promise(async resolve => {
|
|
216
|
-
const all = new Collection();
|
|
217
|
-
if (this.bot || this.client.user.id === this.id) return resolve(all);
|
|
218
|
-
const data = await this.client.api.users(this.id).relationships.get();
|
|
219
|
-
for (const u of data) {
|
|
220
|
-
all.set(u.id, this.client.users._add(u));
|
|
221
|
-
}
|
|
222
|
-
return resolve(all);
|
|
223
|
-
});
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Check relationship status (Client -> User)
|
|
228
|
-
* @type {RelationshipTypes}
|
|
229
|
-
* @readonly
|
|
230
|
-
*/
|
|
231
|
-
get relationships() {
|
|
232
|
-
const i = this.client.relationships.cache.get(this.id) ?? 0;
|
|
233
|
-
return RelationshipTypes[parseInt(i)];
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Check note
|
|
238
|
-
* @type {?string}
|
|
239
|
-
* @readonly
|
|
240
|
-
*/
|
|
241
|
-
get note() {
|
|
242
|
-
return this.client.user.notes.get(this.id);
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
/**
|
|
246
|
-
* Get friend nickname
|
|
247
|
-
* @type {?string}
|
|
248
|
-
* @readonly
|
|
249
|
-
*/
|
|
250
|
-
get nickname() {
|
|
251
|
-
return this.client.user.friendNicknames.get(this.id);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
/**
|
|
255
|
-
* The voice state of this member
|
|
256
|
-
* @type {VoiceState}
|
|
257
|
-
* @readonly
|
|
258
|
-
*/
|
|
259
|
-
get voice() {
|
|
260
|
-
return (
|
|
261
|
-
this.client.voiceStates.cache.get(this.id) ??
|
|
262
|
-
this.client.guilds.cache.find(g => g?.voiceStates?.cache?.get(this.id))?.voiceStates?.cache?.get(this.id) ??
|
|
263
|
-
new VoiceState({ client: this.client }, { user_id: this.id })
|
|
264
|
-
);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
_ProfilePatch(data) {
|
|
268
|
-
if (!data) return;
|
|
269
|
-
|
|
270
|
-
this._partial = false;
|
|
271
|
-
|
|
272
|
-
if (data.connected_accounts.length > 0) {
|
|
273
|
-
this.connectedAccounts = data.connected_accounts;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
if ('premium_since' in data) {
|
|
277
|
-
const date = new Date(data.premium_since);
|
|
278
|
-
this.premiumSince = date.getTime();
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
if ('premium_guild_since' in data) {
|
|
282
|
-
const date = new Date(data.premium_guild_since);
|
|
283
|
-
this.premiumGuildSince = date.getTime();
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
if ('premium_type' in data) {
|
|
287
|
-
const nitro = NitroType[data.premium_type ?? 0];
|
|
144
|
+
this.avatarDecoration = data.avatar_decoration_data?.asset;
|
|
288
145
|
/**
|
|
289
|
-
*
|
|
290
|
-
* @type {
|
|
146
|
+
* The ID of the avatar decoration's SKU
|
|
147
|
+
* @type {?Snowflake}
|
|
291
148
|
*/
|
|
292
|
-
this.
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
this.bio = data.user_profile.bio;
|
|
297
|
-
/**
|
|
298
|
-
* The user's theme colors (Profile theme) [Primary, Accent]
|
|
299
|
-
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
300
|
-
* @type {?Array<number>}
|
|
301
|
-
*/
|
|
302
|
-
this.themeColors = data.user_profile.theme_colors;
|
|
303
|
-
|
|
304
|
-
this.pronouns = data.user_profile.pronouns;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
if ('guild_member_profile' in data && 'guild_member' in data) {
|
|
308
|
-
const guild = this.client.guilds.cache.get(data.guild_member_profile.guild_id);
|
|
309
|
-
const member = guild?.members._add(data.guild_member);
|
|
310
|
-
member._ProfilePatch(data.guild_member_profile);
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
if ('application' in data) {
|
|
314
|
-
this.application = new ClientApplication(this.client, data.application, this);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if ('badges' in data) {
|
|
318
|
-
/**
|
|
319
|
-
* @callback BadgeIcon
|
|
320
|
-
* @returns {string}
|
|
321
|
-
*/
|
|
322
|
-
|
|
323
|
-
/**
|
|
324
|
-
* @typedef {Object} UserBadge
|
|
325
|
-
* @property {string} id The id of the badge
|
|
326
|
-
* @property {string} description The description of the badge
|
|
327
|
-
* @property {string} icon The icon hash of the badge
|
|
328
|
-
* @property {?string} link The link of the badge
|
|
329
|
-
* @property {BadgeIcon} iconURL The iconURL of the badge
|
|
330
|
-
*/
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* User badges (Boost, Slash, AutoMod, etc.)
|
|
334
|
-
* @type {?Array<UserBadge>}
|
|
335
|
-
*/
|
|
336
|
-
this.badges = data.badges.map(o => ({ ...o, iconURL: () => this.client.rest.cdn.BadgeIcon(o.icon) }));
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
if ('guild_badges' in data) {
|
|
340
|
-
// Unknown
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
if ('mutual_guilds' in data) {
|
|
344
|
-
this._mutualGuilds = data.mutual_guilds;
|
|
149
|
+
this.avatarDecorationSKUId = data.avatar_decoration_data?.sku_id;
|
|
150
|
+
} else {
|
|
151
|
+
this.avatarDecoration ??= null;
|
|
152
|
+
this.avatarDecorationSKUId ??= null;
|
|
345
153
|
}
|
|
346
154
|
}
|
|
347
155
|
|
|
348
|
-
/**
|
|
349
|
-
* Get profile from Discord, if client is in a server with the target.
|
|
350
|
-
* @type {User}
|
|
351
|
-
* @param {Snowflake | null} guildId The guild id to get the profile from
|
|
352
|
-
* @returns {Promise<User>}
|
|
353
|
-
*/
|
|
354
|
-
async getProfile(guildId) {
|
|
355
|
-
if (this.client.bot) throw new Error('INVALID_BOT_METHOD');
|
|
356
|
-
const query = guildId
|
|
357
|
-
? {
|
|
358
|
-
with_mutual_guilds: true,
|
|
359
|
-
guild_id: guildId,
|
|
360
|
-
}
|
|
361
|
-
: {
|
|
362
|
-
with_mutual_guilds: true,
|
|
363
|
-
};
|
|
364
|
-
const data = await this.client.api.users(this.id).profile.get({
|
|
365
|
-
query,
|
|
366
|
-
});
|
|
367
|
-
this._ProfilePatch(data);
|
|
368
|
-
return this;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* Friends the user [If incoming request]
|
|
373
|
-
* @type {boolean}
|
|
374
|
-
* @returns {Promise<boolean>}
|
|
375
|
-
*/
|
|
376
|
-
setFriend() {
|
|
377
|
-
return this.client.relationships.addFriend(this);
|
|
378
|
-
}
|
|
379
|
-
|
|
380
|
-
/**
|
|
381
|
-
* Changes the nickname of the friend
|
|
382
|
-
* @param {?string} nickname The nickname to change
|
|
383
|
-
* @type {boolean}
|
|
384
|
-
* @returns {Promise<boolean>}
|
|
385
|
-
*/
|
|
386
|
-
setNickname(nickname) {
|
|
387
|
-
return this.client.relationships.setNickname(this.id, nickname);
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* Send Friend Request to the user
|
|
392
|
-
* @type {boolean}
|
|
393
|
-
* @returns {Promise<boolean>}
|
|
394
|
-
*/
|
|
395
|
-
sendFriendRequest() {
|
|
396
|
-
return this.client.relationships.sendFriendRequest(this.username, this.discriminator);
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* Blocks the user
|
|
400
|
-
* @type {boolean}
|
|
401
|
-
* @returns {Promise<boolean>}
|
|
402
|
-
*/
|
|
403
|
-
setBlock() {
|
|
404
|
-
return this.client.relationships.addBlocked(this);
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* Removes the user from your blocks list
|
|
409
|
-
* @type {boolean}
|
|
410
|
-
* @returns {Promise<boolean>}
|
|
411
|
-
*/
|
|
412
|
-
unBlock() {
|
|
413
|
-
return this.client.relationships.deleteBlocked(this);
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Removes the user from your friends list
|
|
418
|
-
* @type {boolean}
|
|
419
|
-
* @returns {Promise<boolean>}
|
|
420
|
-
*/
|
|
421
|
-
unFriend() {
|
|
422
|
-
return this.client.relationships.deleteFriend(this);
|
|
423
|
-
}
|
|
424
|
-
|
|
425
156
|
/**
|
|
426
157
|
* Whether this User is a partial
|
|
427
158
|
* @type {boolean}
|
|
@@ -508,47 +239,11 @@ class User extends Base {
|
|
|
508
239
|
* @returns {?string}
|
|
509
240
|
*/
|
|
510
241
|
bannerURL({ format, size, dynamic } = {}) {
|
|
511
|
-
if (typeof this.banner === 'undefined')
|
|
512
|
-
throw new Error('USER_BANNER_NOT_FETCHED');
|
|
513
|
-
}
|
|
242
|
+
if (typeof this.banner === 'undefined') throw new Error('USER_BANNER_NOT_FETCHED');
|
|
514
243
|
if (!this.banner) return null;
|
|
515
244
|
return this.client.rest.cdn.Banner(this.id, this.banner, format, size, dynamic);
|
|
516
245
|
}
|
|
517
246
|
|
|
518
|
-
/**
|
|
519
|
-
* Ring the user's phone / PC (call)
|
|
520
|
-
* @returns {Promise<boolean>}
|
|
521
|
-
*/
|
|
522
|
-
ring() {
|
|
523
|
-
if (this.relationships !== 'FRIEND') return Promise.reject(new Error('USER_NOT_FRIEND'));
|
|
524
|
-
if (!this.client.user.voice?.channelId || !this.client.callVoice) {
|
|
525
|
-
return Promise.reject(new Error('CLIENT_NO_CALL'));
|
|
526
|
-
}
|
|
527
|
-
return new Promise((resolve, reject) => {
|
|
528
|
-
this.client.api
|
|
529
|
-
.channels(this.dmChannel.id)
|
|
530
|
-
.call.ring.post({
|
|
531
|
-
data: {
|
|
532
|
-
recipients: [this.id],
|
|
533
|
-
},
|
|
534
|
-
})
|
|
535
|
-
.then(() => resolve(true))
|
|
536
|
-
.catch(e => {
|
|
537
|
-
reject(e);
|
|
538
|
-
});
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
* The hexadecimal version of the user theme color, with a leading hash [Primary, Accent]
|
|
544
|
-
* <info>The user must be force fetched for this property to be present or be updated</info>
|
|
545
|
-
* @type {?Array<string>}
|
|
546
|
-
* @readonly
|
|
547
|
-
*/
|
|
548
|
-
get hexThemeColor() {
|
|
549
|
-
return this.themeColors?.map(c => `#${c.toString(16).padStart(6, '0')}`) || null;
|
|
550
|
-
}
|
|
551
|
-
|
|
552
247
|
/**
|
|
553
248
|
* The tag of this user
|
|
554
249
|
* <info>This user's username, or their legacy tag (e.g. `hydrabolt#0001`)
|
|
@@ -616,8 +311,7 @@ class User extends Base {
|
|
|
616
311
|
this.avatar === user.avatar &&
|
|
617
312
|
this.flags?.bitfield === user.flags?.bitfield &&
|
|
618
313
|
this.banner === user.banner &&
|
|
619
|
-
this.accentColor === user.accentColor
|
|
620
|
-
this.bio === user.bio
|
|
314
|
+
this.accentColor === user.accentColor
|
|
621
315
|
);
|
|
622
316
|
}
|
|
623
317
|
|
|
@@ -659,6 +353,28 @@ class User extends Base {
|
|
|
659
353
|
return this.client.users.fetch(this.id, { force });
|
|
660
354
|
}
|
|
661
355
|
|
|
356
|
+
/**
|
|
357
|
+
* Returns a user profile object for a given user ID.
|
|
358
|
+
* <info>This endpoint requires one of the following:
|
|
359
|
+
* - The user is a bot
|
|
360
|
+
* - The user shares a mutual guild with the current user
|
|
361
|
+
* - The user is a friend of the current user
|
|
362
|
+
* - The user is a friend suggestion of the current user
|
|
363
|
+
* - The user has an outgoing friend request to the current user</info>
|
|
364
|
+
* @param {Snowflake} [guildId] The guild ID to get the user's member profile in
|
|
365
|
+
* @returns {Promise<Object>}
|
|
366
|
+
* @see {@link https://discord-userdoccers.vercel.app/resources/user#response-body}
|
|
367
|
+
*/
|
|
368
|
+
getProfile(guildId) {
|
|
369
|
+
return this.client.api.users(this.id).profile.get({
|
|
370
|
+
query: {
|
|
371
|
+
with_mutual_guilds: true,
|
|
372
|
+
with_mutual_friends_count: true,
|
|
373
|
+
guild_id: guildId,
|
|
374
|
+
},
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
662
378
|
/**
|
|
663
379
|
* When concatenated with a string, this automatically returns the user's mention instead of the User object.
|
|
664
380
|
* @returns {string}
|
|
@@ -687,29 +403,85 @@ class User extends Base {
|
|
|
687
403
|
}
|
|
688
404
|
|
|
689
405
|
/**
|
|
690
|
-
*
|
|
691
|
-
* @param {string} note
|
|
692
|
-
*
|
|
406
|
+
* The function updates the note of a user and returns the updated user.
|
|
407
|
+
* @param {string|null|undefined} [note=null] - The `note` parameter is the new value that you want to set for the note of the
|
|
408
|
+
* user. It is an optional parameter and its default value is `null`.
|
|
409
|
+
* @returns {Promise<User>} The `setNote` method is returning the `User` object.
|
|
693
410
|
*/
|
|
694
411
|
async setNote(note = null) {
|
|
695
|
-
await this.client.
|
|
412
|
+
await this.client.notes.updateNote(this.id, note);
|
|
696
413
|
return this;
|
|
697
414
|
}
|
|
698
415
|
|
|
699
416
|
/**
|
|
700
|
-
*
|
|
701
|
-
* @
|
|
417
|
+
* The function returns the note associated with a specific client ID from a cache.
|
|
418
|
+
* @type {?string} The note that corresponds to the given id.
|
|
702
419
|
*/
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
420
|
+
get note() {
|
|
421
|
+
return this.client.notes.cache.get(this.id);
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* The voice state of this member
|
|
426
|
+
* @type {VoiceState}
|
|
427
|
+
* @readonly
|
|
428
|
+
*/
|
|
429
|
+
get voice() {
|
|
430
|
+
return (
|
|
431
|
+
this.client.voiceStates.cache.get(this.id) ??
|
|
432
|
+
this.client.guilds.cache.find(g => g?.voiceStates?.cache?.get(this.id))?.voiceStates?.cache?.get(this.id) ??
|
|
433
|
+
new VoiceState({ client: this.client }, { user_id: this.id })
|
|
711
434
|
);
|
|
712
|
-
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Ring the user's phone / PC (call)
|
|
439
|
+
* @returns {Promise<void>}
|
|
440
|
+
* @deprecated
|
|
441
|
+
*/
|
|
442
|
+
ring() {
|
|
443
|
+
return this.client.api.channels(this.dmChannel.id).call.ring.post({
|
|
444
|
+
data: {
|
|
445
|
+
recipients: [this.id],
|
|
446
|
+
},
|
|
447
|
+
});
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Send Friend Request to the user
|
|
452
|
+
* @type {boolean}
|
|
453
|
+
* @returns {Promise<boolean>}
|
|
454
|
+
*/
|
|
455
|
+
sendFriendRequest() {
|
|
456
|
+
return this.client.relationships.sendFriendRequest({ user: this });
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/**
|
|
460
|
+
* Unblock / Unfriend / Cancels a friend request
|
|
461
|
+
* @type {boolean}
|
|
462
|
+
* @returns {Promise<boolean>}
|
|
463
|
+
*/
|
|
464
|
+
deleteRelationship() {
|
|
465
|
+
return this.client.relationships.deleteRelationship(this);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
/**
|
|
469
|
+
* Check relationship status (Client -> User)
|
|
470
|
+
* @type {RelationshipTypes}
|
|
471
|
+
* @readonly
|
|
472
|
+
*/
|
|
473
|
+
get relationship() {
|
|
474
|
+
const i = this.client.relationships.cache.get(this.id) ?? 0;
|
|
475
|
+
return RelationshipTypes[parseInt(i)];
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Get friend nickname
|
|
480
|
+
* @type {?string}
|
|
481
|
+
* @readonly
|
|
482
|
+
*/
|
|
483
|
+
get friendNickname() {
|
|
484
|
+
return this.client.relationships.friendNicknames.get(this.id);
|
|
713
485
|
}
|
|
714
486
|
}
|
|
715
487
|
|
|
@@ -8,7 +8,7 @@ const ContextMenuInteraction = require('./ContextMenuInteraction');
|
|
|
8
8
|
*/
|
|
9
9
|
class UserContextMenuInteraction extends ContextMenuInteraction {
|
|
10
10
|
/**
|
|
11
|
-
* The user this interaction
|
|
11
|
+
* The target user from this interaction
|
|
12
12
|
* @type {User}
|
|
13
13
|
* @readonly
|
|
14
14
|
*/
|
|
@@ -17,7 +17,7 @@ class UserContextMenuInteraction extends ContextMenuInteraction {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
* The member this interaction
|
|
20
|
+
* The target member from this interaction
|
|
21
21
|
* @type {?(GuildMember|APIGuildMember)}
|
|
22
22
|
* @readonly
|
|
23
23
|
*/
|