djs-selfbot-v13 3.1.7 → 3.2.2
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/README.md +18 -35
- package/package.json +85 -100
- package/src/client/BaseClient.js +3 -4
- package/src/client/Client.js +249 -530
- 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/GuildMemberRemove.js +0 -1
- package/src/client/actions/GuildMemberUpdate.js +0 -1
- 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 +19 -13
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +0 -1
- package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +1 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.js +22 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.js +12 -0
- package/src/client/websocket/handlers/READY.js +90 -140
- package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +7 -5
- package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +7 -5
- 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 +17 -20
- package/src/errors/Messages.js +25 -69
- package/src/index.js +13 -43
- package/src/managers/ApplicationCommandManager.js +9 -12
- package/src/managers/ApplicationCommandPermissionsManager.js +3 -11
- package/src/managers/ChannelManager.js +2 -3
- package/src/managers/ClientUserSettingManager.js +162 -280
- package/src/managers/GuildBanManager.js +47 -1
- package/src/managers/GuildChannelManager.js +2 -16
- package/src/managers/GuildForumThreadManager.js +24 -30
- package/src/managers/GuildManager.js +1 -1
- package/src/managers/GuildMemberManager.js +50 -222
- 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 +83 -76
- 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 +48 -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 +20 -19
- package/src/structures/ClientUser.js +117 -338
- 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 +220 -203
- 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 +6 -46
- package/src/structures/MessagePoll.js +238 -0
- package/src/structures/MessageReaction.js +1 -1
- package/src/structures/MessageSelectMenu.js +1 -252
- package/src/structures/Modal.js +70 -188
- package/src/structures/Presence.js +787 -129
- 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 +145 -339
- 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 +409 -256
- package/src/util/ApplicationFlags.js +1 -1
- package/src/util/AttachmentFlags.js +38 -0
- package/src/util/Constants.js +120 -285
- 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 -74
- package/src/util/Permissions.js +15 -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 +158 -32
- package/typings/enums.d.ts +24 -73
- package/typings/index.d.ts +978 -1288
- 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/RichPresence.js +0 -722
- 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,47 @@ 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];
|
|
288
|
-
/**
|
|
289
|
-
* Nitro type of the user.
|
|
290
|
-
* @type {NitroType}
|
|
291
|
-
*/
|
|
292
|
-
this.nitroType = nitro ?? `UNKNOWN_TYPE_${data.premium_type}`;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
if ('user_profile' in data) {
|
|
296
|
-
this.bio = data.user_profile.bio;
|
|
144
|
+
this.avatarDecoration = data.avatar_decoration_data?.asset;
|
|
297
145
|
/**
|
|
298
|
-
* The
|
|
299
|
-
*
|
|
300
|
-
* @type {?Array<number>}
|
|
146
|
+
* The ID of the avatar decoration's SKU
|
|
147
|
+
* @type {?Snowflake}
|
|
301
148
|
*/
|
|
302
|
-
this.
|
|
303
|
-
|
|
304
|
-
this.
|
|
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);
|
|
149
|
+
this.avatarDecorationSKUId = data.avatar_decoration_data?.sku_id;
|
|
150
|
+
} else {
|
|
151
|
+
this.avatarDecoration ??= null;
|
|
152
|
+
this.avatarDecorationSKUId ??= null;
|
|
315
153
|
}
|
|
316
154
|
|
|
317
|
-
if ('
|
|
318
|
-
/**
|
|
319
|
-
* @callback BadgeIcon
|
|
320
|
-
* @returns {string}
|
|
321
|
-
*/
|
|
322
|
-
|
|
155
|
+
if ('clan' in data && data.clan) {
|
|
323
156
|
/**
|
|
324
|
-
*
|
|
325
|
-
* @
|
|
326
|
-
* @
|
|
327
|
-
* @property {
|
|
328
|
-
* @property {
|
|
329
|
-
* @property {
|
|
157
|
+
* User Clan Structure
|
|
158
|
+
* @see {@link https://docs.discord.sex/resources/user#user-clan-structure}
|
|
159
|
+
* @typedef {Object} UserClan
|
|
160
|
+
* @property {?Snowflake} identityGuildId The ID of the user's primary clan
|
|
161
|
+
* @property {boolean} identityEnabled Whether the user is displaying their clan tag
|
|
162
|
+
* @property {?string} tag The text of the user's clan tag (max 4 characters)
|
|
163
|
+
* @property {?string} badge The clan's badge hash
|
|
330
164
|
*/
|
|
331
|
-
|
|
332
165
|
/**
|
|
333
|
-
*
|
|
334
|
-
* @type {?
|
|
166
|
+
* The primary clan the user is in
|
|
167
|
+
* @type {?UserClan}
|
|
335
168
|
*/
|
|
336
|
-
this.
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
this._mutualGuilds = data.mutual_guilds;
|
|
169
|
+
this.clan = {
|
|
170
|
+
identityGuildId: data.clan.identity_guild_id,
|
|
171
|
+
identityEnabled: data.clan.identity_enabled,
|
|
172
|
+
tag: data.clan.tag,
|
|
173
|
+
badge: data.clan.badge,
|
|
174
|
+
};
|
|
175
|
+
} else {
|
|
176
|
+
this.clan ??= null;
|
|
345
177
|
}
|
|
346
178
|
}
|
|
347
179
|
|
|
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
180
|
/**
|
|
426
181
|
* Whether this User is a partial
|
|
427
182
|
* @type {boolean}
|
|
@@ -469,6 +224,15 @@ class User extends Base {
|
|
|
469
224
|
return this.client.rest.cdn.AvatarDecoration(this.id, this.avatarDecoration, format, size);
|
|
470
225
|
}
|
|
471
226
|
|
|
227
|
+
/**
|
|
228
|
+
* A link to the user's clan badge.
|
|
229
|
+
* @returns {?string}
|
|
230
|
+
*/
|
|
231
|
+
clanBadgeURL() {
|
|
232
|
+
if (!this.clan || !this.clan.identityGuildId || !this.clan.badge) return null;
|
|
233
|
+
return this.client.rest.cdn.ClanBadge(this.clan.identityGuildId, this.clan.badge);
|
|
234
|
+
}
|
|
235
|
+
|
|
472
236
|
/**
|
|
473
237
|
* A link to the user's default avatar
|
|
474
238
|
* @type {string}
|
|
@@ -508,47 +272,11 @@ class User extends Base {
|
|
|
508
272
|
* @returns {?string}
|
|
509
273
|
*/
|
|
510
274
|
bannerURL({ format, size, dynamic } = {}) {
|
|
511
|
-
if (typeof this.banner === 'undefined')
|
|
512
|
-
throw new Error('USER_BANNER_NOT_FETCHED');
|
|
513
|
-
}
|
|
275
|
+
if (typeof this.banner === 'undefined') throw new Error('USER_BANNER_NOT_FETCHED');
|
|
514
276
|
if (!this.banner) return null;
|
|
515
277
|
return this.client.rest.cdn.Banner(this.id, this.banner, format, size, dynamic);
|
|
516
278
|
}
|
|
517
279
|
|
|
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
280
|
/**
|
|
553
281
|
* The tag of this user
|
|
554
282
|
* <info>This user's username, or their legacy tag (e.g. `hydrabolt#0001`)
|
|
@@ -616,8 +344,7 @@ class User extends Base {
|
|
|
616
344
|
this.avatar === user.avatar &&
|
|
617
345
|
this.flags?.bitfield === user.flags?.bitfield &&
|
|
618
346
|
this.banner === user.banner &&
|
|
619
|
-
this.accentColor === user.accentColor
|
|
620
|
-
this.bio === user.bio
|
|
347
|
+
this.accentColor === user.accentColor
|
|
621
348
|
);
|
|
622
349
|
}
|
|
623
350
|
|
|
@@ -659,6 +386,29 @@ class User extends Base {
|
|
|
659
386
|
return this.client.users.fetch(this.id, { force });
|
|
660
387
|
}
|
|
661
388
|
|
|
389
|
+
/**
|
|
390
|
+
* Returns a user profile object for a given user ID.
|
|
391
|
+
* <info>This endpoint requires one of the following:
|
|
392
|
+
* - The user is a bot
|
|
393
|
+
* - The user shares a mutual guild with the current user
|
|
394
|
+
* - The user is a friend of the current user
|
|
395
|
+
* - The user is a friend suggestion of the current user
|
|
396
|
+
* - The user has an outgoing friend request to the current user</info>
|
|
397
|
+
* @param {Snowflake} [guildId] The guild ID to get the user's member profile in
|
|
398
|
+
* @returns {Promise<Object>}
|
|
399
|
+
* @see {@link https://discord-userdoccers.vercel.app/resources/user#response-body}
|
|
400
|
+
*/
|
|
401
|
+
getProfile(guildId) {
|
|
402
|
+
return this.client.api.users(this.id).profile.get({
|
|
403
|
+
query: {
|
|
404
|
+
with_mutual_guilds: true,
|
|
405
|
+
with_mutual_friends: true,
|
|
406
|
+
with_mutual_friends_count: true,
|
|
407
|
+
guild_id: guildId,
|
|
408
|
+
},
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
|
|
662
412
|
/**
|
|
663
413
|
* When concatenated with a string, this automatically returns the user's mention instead of the User object.
|
|
664
414
|
* @returns {string}
|
|
@@ -687,29 +437,85 @@ class User extends Base {
|
|
|
687
437
|
}
|
|
688
438
|
|
|
689
439
|
/**
|
|
690
|
-
*
|
|
691
|
-
* @param {string} note
|
|
692
|
-
*
|
|
440
|
+
* The function updates the note of a user and returns the updated user.
|
|
441
|
+
* @param {string|null|undefined} [note=null] - The `note` parameter is the new value that you want to set for the note of the
|
|
442
|
+
* user. It is an optional parameter and its default value is `null`.
|
|
443
|
+
* @returns {Promise<User>} The `setNote` method is returning the `User` object.
|
|
693
444
|
*/
|
|
694
445
|
async setNote(note = null) {
|
|
695
|
-
await this.client.
|
|
446
|
+
await this.client.notes.updateNote(this.id, note);
|
|
696
447
|
return this;
|
|
697
448
|
}
|
|
698
449
|
|
|
699
450
|
/**
|
|
700
|
-
*
|
|
701
|
-
* @
|
|
451
|
+
* The function returns the note associated with a specific client ID from a cache.
|
|
452
|
+
* @type {?string} The note that corresponds to the given id.
|
|
453
|
+
*/
|
|
454
|
+
get note() {
|
|
455
|
+
return this.client.notes.cache.get(this.id);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/**
|
|
459
|
+
* The voice state of this member
|
|
460
|
+
* @type {VoiceState}
|
|
461
|
+
* @readonly
|
|
702
462
|
*/
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
this.client.guilds.cache.
|
|
707
|
-
|
|
708
|
-
if (res_) return (data = res_);
|
|
709
|
-
return true;
|
|
710
|
-
}),
|
|
463
|
+
get voice() {
|
|
464
|
+
return (
|
|
465
|
+
this.client.voiceStates.cache.get(this.id) ??
|
|
466
|
+
this.client.guilds.cache.find(g => g?.voiceStates?.cache?.get(this.id))?.voiceStates?.cache?.get(this.id) ??
|
|
467
|
+
new VoiceState({ client: this.client }, { user_id: this.id })
|
|
711
468
|
);
|
|
712
|
-
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Ring the user's phone / PC (call)
|
|
473
|
+
* @returns {Promise<void>}
|
|
474
|
+
* @deprecated
|
|
475
|
+
*/
|
|
476
|
+
ring() {
|
|
477
|
+
return this.client.api.channels(this.dmChannel.id).call.ring.post({
|
|
478
|
+
data: {
|
|
479
|
+
recipients: [this.id],
|
|
480
|
+
},
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* Send Friend Request to the user
|
|
486
|
+
* @type {boolean}
|
|
487
|
+
* @returns {Promise<boolean>}
|
|
488
|
+
*/
|
|
489
|
+
sendFriendRequest() {
|
|
490
|
+
return this.client.relationships.sendFriendRequest({ user: this });
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/**
|
|
494
|
+
* Unblock / Unfriend / Cancels a friend request
|
|
495
|
+
* @type {boolean}
|
|
496
|
+
* @returns {Promise<boolean>}
|
|
497
|
+
*/
|
|
498
|
+
deleteRelationship() {
|
|
499
|
+
return this.client.relationships.deleteRelationship(this);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/**
|
|
503
|
+
* Check relationship status (Client -> User)
|
|
504
|
+
* @type {RelationshipType}
|
|
505
|
+
* @readonly
|
|
506
|
+
*/
|
|
507
|
+
get relationship() {
|
|
508
|
+
const i = this.client.relationships.cache.get(this.id) ?? 0;
|
|
509
|
+
return RelationshipTypes[parseInt(i)];
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Get friend nickname
|
|
514
|
+
* @type {?string}
|
|
515
|
+
* @readonly
|
|
516
|
+
*/
|
|
517
|
+
get friendNickname() {
|
|
518
|
+
return this.client.relationships.friendNicknames.get(this.id);
|
|
713
519
|
}
|
|
714
520
|
}
|
|
715
521
|
|
|
@@ -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
|
*/
|