djs-selfbot-v13 3.1.6 → 3.1.7

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.
Files changed (148) hide show
  1. package/README.md +31 -16
  2. package/package.json +15 -8
  3. package/src/client/BaseClient.js +3 -2
  4. package/src/client/Client.js +539 -187
  5. package/src/client/actions/Action.js +13 -18
  6. package/src/client/actions/ActionsManager.js +1 -7
  7. package/src/client/actions/AutoModerationActionExecution.js +0 -1
  8. package/src/client/actions/AutoModerationRuleCreate.js +0 -1
  9. package/src/client/actions/AutoModerationRuleDelete.js +0 -1
  10. package/src/client/actions/AutoModerationRuleUpdate.js +0 -1
  11. package/src/client/actions/InteractionCreate.js +115 -0
  12. package/src/client/actions/MessageCreate.js +4 -0
  13. package/src/client/actions/PresenceUpdate.js +16 -17
  14. package/src/client/websocket/WebSocketManager.js +31 -11
  15. package/src/client/websocket/WebSocketShard.js +38 -39
  16. package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +23 -0
  17. package/src/client/websocket/handlers/CALL_CREATE.js +3 -3
  18. package/src/client/websocket/handlers/CALL_DELETE.js +2 -2
  19. package/src/client/websocket/handlers/CALL_UPDATE.js +2 -2
  20. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +13 -16
  21. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
  22. package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +11 -0
  23. package/src/client/websocket/handlers/GUILD_CREATE.js +0 -7
  24. package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +55 -0
  25. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +0 -0
  26. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +0 -0
  27. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.js +0 -0
  28. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +0 -0
  29. package/src/client/websocket/handlers/INTERACTION_CREATE.js +16 -0
  30. package/src/client/websocket/handlers/INTERACTION_FAILURE.js +18 -0
  31. package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +0 -1
  32. package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +30 -0
  33. package/src/client/websocket/handlers/MESSAGE_ACK.js +16 -0
  34. package/src/client/websocket/handlers/READY.js +137 -47
  35. package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +5 -7
  36. package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +4 -6
  37. package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +9 -32
  38. package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
  39. package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +8 -2
  40. package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
  41. package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +5 -1
  42. package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
  43. package/src/client/websocket/handlers/index.js +20 -15
  44. package/src/errors/Messages.js +69 -24
  45. package/src/index.js +43 -12
  46. package/src/managers/ApplicationCommandManager.js +12 -9
  47. package/src/managers/ApplicationCommandPermissionsManager.js +11 -3
  48. package/src/managers/ChannelManager.js +4 -2
  49. package/src/managers/ClientUserSettingManager.js +279 -161
  50. package/src/managers/DeveloperPortalManager.js +104 -0
  51. package/src/managers/GuildApplicationCommandManager.js +28 -0
  52. package/src/managers/GuildBanManager.js +1 -1
  53. package/src/managers/GuildChannelManager.js +0 -2
  54. package/src/managers/GuildFolderManager.js +24 -0
  55. package/src/managers/GuildForumThreadManager.js +28 -22
  56. package/src/managers/GuildMemberManager.js +216 -40
  57. package/src/managers/GuildSettingManager.js +15 -22
  58. package/src/managers/MessageManager.js +44 -42
  59. package/src/managers/PermissionOverwriteManager.js +1 -1
  60. package/src/managers/ReactionUserManager.js +5 -5
  61. package/src/managers/RelationshipManager.js +74 -81
  62. package/src/managers/SessionManager.js +57 -0
  63. package/src/managers/ThreadManager.js +45 -12
  64. package/src/managers/ThreadMemberManager.js +1 -1
  65. package/src/managers/UserManager.js +10 -6
  66. package/src/rest/APIRequest.js +20 -42
  67. package/src/rest/CaptchaSolver.js +132 -0
  68. package/src/rest/DiscordAPIError.js +16 -17
  69. package/src/rest/RESTManager.js +21 -1
  70. package/src/rest/RequestHandler.js +21 -35
  71. package/src/structures/ApplicationCommand.js +456 -19
  72. package/src/structures/ApplicationRoleConnectionMetadata.js +0 -3
  73. package/src/structures/AutoModerationRule.js +5 -5
  74. package/src/structures/AutocompleteInteraction.js +0 -1
  75. package/src/structures/BaseGuildTextChannel.js +12 -10
  76. package/src/structures/BaseGuildVoiceChannel.js +18 -16
  77. package/src/structures/{CallState.js → Call.js} +12 -17
  78. package/src/structures/CategoryChannel.js +0 -2
  79. package/src/structures/Channel.js +3 -2
  80. package/src/structures/ClientApplication.js +204 -0
  81. package/src/structures/ClientPresence.js +8 -12
  82. package/src/structures/ClientUser.js +336 -117
  83. package/src/structures/ContextMenuInteraction.js +1 -1
  84. package/src/structures/DMChannel.js +92 -29
  85. package/src/structures/DeveloperPortalApplication.js +520 -0
  86. package/src/structures/ForumChannel.js +10 -0
  87. package/src/structures/Guild.js +271 -135
  88. package/src/structures/GuildAuditLogs.js +5 -0
  89. package/src/structures/GuildChannel.js +2 -16
  90. package/src/structures/GuildFolder.js +75 -0
  91. package/src/structures/GuildMember.js +145 -27
  92. package/src/structures/Interaction.js +62 -1
  93. package/src/structures/InteractionResponse.js +114 -0
  94. package/src/structures/Invite.js +52 -35
  95. package/src/structures/Message.js +202 -222
  96. package/src/structures/MessageAttachment.js +0 -11
  97. package/src/structures/MessageButton.js +67 -1
  98. package/src/structures/MessageEmbed.js +1 -1
  99. package/src/structures/MessageMentions.js +2 -3
  100. package/src/structures/MessagePayload.js +46 -4
  101. package/src/structures/MessageReaction.js +1 -1
  102. package/src/structures/MessageSelectMenu.js +252 -1
  103. package/src/structures/Modal.js +180 -75
  104. package/src/structures/PartialGroupDMChannel.js +433 -0
  105. package/src/structures/Presence.js +2 -2
  106. package/src/structures/RichPresence.js +34 -14
  107. package/src/structures/Role.js +2 -18
  108. package/src/structures/SelectMenuInteraction.js +151 -2
  109. package/src/structures/Session.js +81 -0
  110. package/src/structures/Team.js +49 -0
  111. package/src/structures/TextInputComponent.js +70 -0
  112. package/src/structures/ThreadChannel.js +19 -0
  113. package/src/structures/User.js +345 -117
  114. package/src/structures/UserContextMenuInteraction.js +2 -2
  115. package/src/structures/VoiceState.js +39 -74
  116. package/src/structures/WebEmbed.js +52 -38
  117. package/src/structures/Webhook.js +11 -17
  118. package/src/structures/interfaces/Application.js +23 -146
  119. package/src/structures/interfaces/TextBasedChannel.js +256 -411
  120. package/src/util/ApplicationFlags.js +1 -1
  121. package/src/util/Constants.js +284 -106
  122. package/src/util/Formatters.js +2 -16
  123. package/src/util/LimitedCollection.js +1 -1
  124. package/src/util/Options.js +68 -48
  125. package/src/util/Permissions.js +0 -5
  126. package/src/util/PurchasedFlags.js +0 -2
  127. package/src/util/RemoteAuth.js +356 -221
  128. package/src/util/Sweepers.js +1 -1
  129. package/src/util/Util.js +36 -76
  130. package/src/util/Voice.js +1456 -0
  131. package/src/util/arRPC/index.js +229 -0
  132. package/src/util/arRPC/process/detectable.json +1 -0
  133. package/src/util/arRPC/process/index.js +102 -0
  134. package/src/util/arRPC/process/native/index.js +5 -0
  135. package/src/util/arRPC/process/native/linux.js +37 -0
  136. package/src/util/arRPC/process/native/win32.js +25 -0
  137. package/src/util/arRPC/transports/ipc.js +281 -0
  138. package/src/util/arRPC/transports/websocket.js +128 -0
  139. package/typings/enums.d.ts +73 -18
  140. package/typings/index.d.ts +1249 -897
  141. package/typings/rawDataTypes.d.ts +9 -68
  142. package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +0 -78
  143. package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +0 -12
  144. package/src/managers/UserNoteManager.js +0 -53
  145. package/src/structures/GroupDMChannel.js +0 -387
  146. package/src/util/AttachmentFlags.js +0 -38
  147. package/src/util/InviteFlags.js +0 -29
  148. package/src/util/RoleFlags.js +0 -37
@@ -3,12 +3,14 @@
3
3
  const { setInterval } = require('node:timers');
4
4
  const { Collection } = require('@discordjs/collection');
5
5
  const Invite = require('./Invite');
6
+ const { Message } = require('./Message');
6
7
  const User = require('./User');
8
+ const { Util } = require('..');
9
+ const { Error: Error_ } = require('../errors');
10
+ const { Opcodes, NitroType, HypeSquadType } = require('../util/Constants');
7
11
  const DataResolver = require('../util/DataResolver');
8
12
  const PremiumUsageFlags = require('../util/PremiumUsageFlags');
9
13
  const PurchasedFlags = require('../util/PurchasedFlags');
10
- const Util = require('../util/Util');
11
-
12
14
  /**
13
15
  * Represents the logged in client's Discord user.
14
16
  * @extends {User}
@@ -34,7 +36,7 @@ class ClientUser extends User {
34
36
 
35
37
  if ('mfa_enabled' in data) {
36
38
  /**
37
- * If the bot's {@link Application#owner Owner} has MFA enabled on their account
39
+ * If the bot's {@link ClientApplication#owner Owner} has MFA enabled on their account
38
40
  * @type {?boolean}
39
41
  */
40
42
  this.mfaEnabled = typeof data.mfa_enabled === 'boolean' ? data.mfa_enabled : null;
@@ -44,24 +46,30 @@ class ClientUser extends User {
44
46
 
45
47
  if ('token' in data) this.client.token = data.token;
46
48
 
49
+ // Todo: Add (Selfbot)
50
+ if ('premium_type' in data) {
51
+ const nitro = NitroType[data.premium_type ?? 0];
52
+ /**
53
+ * Nitro type of the client user.
54
+ * @type {NitroType}
55
+ */
56
+ this.nitroType = nitro ?? `UNKNOWN_TYPE_${data.premium_type}`;
57
+ }
58
+
47
59
  if ('purchased_flags' in data) {
48
60
  /**
49
61
  * Purchased state of the client user.
50
- * @type {Readonly<PurchasedFlags>}
62
+ * @type {?PurchasedFlags}
51
63
  */
52
- this.purchasedFlags = new PurchasedFlags(data.purchased_flags || 0).freeze();
53
- } else {
54
- this.purchasedFlags = new PurchasedFlags().freeze();
64
+ this.purchasedFlags = new PurchasedFlags(data.purchased_flags || 0);
55
65
  }
56
66
 
57
67
  if ('premium_usage_flags' in data) {
58
68
  /**
59
69
  * Premium usage state of the client user.
60
- * @type {Readonly<PremiumUsageFlags>}
70
+ * @type {?PremiumUsageFlags}
61
71
  */
62
72
  this.premiumUsageFlags = new PremiumUsageFlags(data.premium_usage_flags || 0);
63
- } else {
64
- this.premiumUsageFlags = new PremiumUsageFlags().freeze();
65
73
  }
66
74
 
67
75
  if ('phone' in data) {
@@ -69,7 +77,7 @@ class ClientUser extends User {
69
77
  * Phone number of the client user.
70
78
  * @type {?string}
71
79
  */
72
- this.phone = data.phone;
80
+ this.phoneNumber = data.phone;
73
81
  }
74
82
 
75
83
  if ('nsfw_allowed' in data) {
@@ -85,37 +93,50 @@ class ClientUser extends User {
85
93
  * Email address of the client user.
86
94
  * @type {?string}
87
95
  */
88
- this.email = data.email;
96
+ this.emailAddress = data.email;
89
97
  }
90
98
 
91
99
  if ('bio' in data) {
92
- /**
93
- * About me (User)
94
- * <info>The user must be force fetched for this property to be present or be updated</info>
95
- * @type {?string}
96
- */
97
100
  this.bio = data.bio;
98
101
  }
99
102
 
100
103
  if ('pronouns' in data) {
101
- /**
102
- * Pronouns (User)
103
- * <info>The user must be force fetched for this property to be present or be updated</info>
104
- * @type {?string}
105
- */
106
104
  this.pronouns = data.pronouns;
107
105
  }
108
106
 
109
- if ('premium_type' in data) {
107
+ if (!this.friendNicknames?.size) {
110
108
  /**
111
- * Premium types denote the level of premium a user has.
112
- * @type {number}
113
- * @see {@link https://discord-userdoccers.vercel.app/resources/user#premium-type}
109
+ * The friend nicknames cache of the client user.
110
+ * @type {Collection<Snowflake, string>}
111
+ * @private
114
112
  */
115
- this.premiumType = data.premium_type;
113
+ this.friendNicknames = new Collection();
114
+ }
115
+
116
+ if (!this._intervalSamsungPresence) {
117
+ this._intervalSamsungPresence = setInterval(() => {
118
+ this.client.emit('debug', `Samsung Presence: ${this._packageName}`);
119
+ if (!this._packageName) return;
120
+ this.setSamsungActivity(this._packageName, 'UPDATE');
121
+ }, 1000 * 60 * 10).unref();
122
+ // 20 minutes max
116
123
  }
117
124
  }
118
125
 
126
+ /**
127
+ * Patch note
128
+ * @param {Object} data Note data
129
+ * @private
130
+ */
131
+ _patchNote(data) {
132
+ /**
133
+ * The notes cache of the client user.
134
+ * @type {Collection<Snowflake, string>}
135
+ * @private
136
+ */
137
+ this.notes = data ? new Collection(Object.entries(data)) : new Collection();
138
+ }
139
+
119
140
  /**
120
141
  * Represents the client user's presence
121
142
  * @type {ClientPresence}
@@ -151,16 +172,22 @@ class ClientUser extends User {
151
172
  * <info>Changing usernames in Discord is heavily rate limited, with only 2 requests
152
173
  * every hour. Use this sparingly!</info>
153
174
  * @param {string} username The new username
154
- * @param {string} password Current Password
175
+ * @param {string} password The password of the account
155
176
  * @returns {Promise<ClientUser>}
156
177
  * @example
157
178
  * // Set username
158
- * client.user.setUsername('discordjs', 'passw@rd')
179
+ * client.user.setUsername('discordjs')
159
180
  * .then(user => console.log(`My new username is ${user.username}`))
160
181
  * .catch(console.error);
161
182
  */
162
183
  setUsername(username, password) {
163
- return this.edit({ username, password });
184
+ if (!password && !this.client.password) {
185
+ throw new Error('A password is required to change a username.');
186
+ }
187
+ return this.edit({
188
+ username,
189
+ password: this.client.password ? this.client.password : password,
190
+ });
164
191
  }
165
192
 
166
193
  /**
@@ -177,12 +204,191 @@ class ClientUser extends User {
177
204
  avatar = avatar && (await DataResolver.resolveImage(avatar));
178
205
  return this.edit({ avatar });
179
206
  }
207
+ /**
208
+ * Sets the banner of the logged in client.
209
+ * @param {?(BufferResolvable|Base64Resolvable)} banner The new banner
210
+ * @returns {Promise<ClientUser>}
211
+ * @example
212
+ * // Set banner
213
+ * client.user.setBanner('./banner.png')
214
+ * .then(user => console.log(`New banner set!`))
215
+ * .catch(console.error);
216
+ */
217
+ async setBanner(banner) {
218
+ if (this.nitroType !== 'NITRO_BOOST') {
219
+ throw new Error('You must be a Nitro Boosted User to change your banner.');
220
+ }
221
+ banner = banner && (await DataResolver.resolveImage(banner));
222
+ return this.edit({ banner });
223
+ }
224
+
225
+ /**
226
+ * Set HyperSquad House
227
+ * @param {HypeSquadType} type
228
+ * * `LEAVE`: 0
229
+ * * `HOUSE_BRAVERY`: 1
230
+ * * `HOUSE_BRILLIANCE`: 2
231
+ * * `HOUSE_BALANCE`: 3
232
+ * @returns {Promise<void>}
233
+ * @example
234
+ * // Set HyperSquad HOUSE_BRAVERY
235
+ * client.user.setHypeSquad(1); || client.user.setHypeSquad('HOUSE_BRAVERY');
236
+ * // Leave
237
+ * client.user.setHypeSquad(0);
238
+ */
239
+ async setHypeSquad(type) {
240
+ const id = typeof type === 'string' ? HypeSquadType[type] : type;
241
+ if (!id && id !== 0) throw new Error('Invalid HypeSquad type.');
242
+ if (id !== 0) {
243
+ const data = await this.client.api.hypesquad.online.post({
244
+ data: { house_id: id },
245
+ });
246
+ return data;
247
+ } else {
248
+ const data = await this.client.api.hypesquad.online.delete();
249
+ return data;
250
+ }
251
+ }
252
+
253
+ /**
254
+ * Set Accent color
255
+ * @param {ColorResolvable} color Color to set
256
+ * @returns {Promise<ClientUser>}
257
+ */
258
+ setAccentColor(color = null) {
259
+ return this.edit({ accent_color: color ? Util.resolveColor(color) : null });
260
+ }
261
+
262
+ /**
263
+ * Set discriminator
264
+ * @param {User.discriminator} discriminator It is #1234
265
+ * @param {string} password The password of the account
266
+ * @returns {Promise<ClientUser>}
267
+ */
268
+ setDiscriminator(discriminator, password) {
269
+ if (this.nitroType == 'NONE') throw new Error('You must be a Nitro User to change your discriminator.');
270
+ if (!password && !this.client.password) {
271
+ throw new Error('A password is required to change a discriminator.');
272
+ }
273
+ return this.edit({
274
+ discriminator,
275
+ username: this.username,
276
+ password: this.client.password ? this.client.password : password,
277
+ });
278
+ }
279
+
280
+ /**
281
+ * Set About me
282
+ * @param {string | null} bio Bio to set
283
+ * @returns {Promise<ClientUser>}
284
+ */
285
+ setAboutMe(bio = null) {
286
+ return this.edit({
287
+ bio,
288
+ });
289
+ }
290
+
291
+ /**
292
+ * Change the email
293
+ * @param {Email<string>} email Email to change
294
+ * @param {string} password Password of the account
295
+ * @returns {Promise<ClientUser>}
296
+ */
297
+ setEmail(email, password) {
298
+ throw new Error('This method is not available yet. Please use the official Discord client to change your email.');
299
+ // eslint-disable-next-line no-unreachable
300
+ if (!password && !this.client.password) {
301
+ throw new Error('A password is required to change a email.');
302
+ }
303
+ return this.edit({
304
+ email,
305
+ password: this.client.password ? this.client.password : password,
306
+ });
307
+ }
308
+
309
+ /**
310
+ * Set new password
311
+ * @param {string} oldPassword Old password
312
+ * @param {string} newPassword New password to set
313
+ * @returns {Promise<ClientUser>}
314
+ */
315
+ setPassword(oldPassword, newPassword) {
316
+ if (!oldPassword && !this.client.password) {
317
+ throw new Error('A password is required to change a password.');
318
+ }
319
+ if (!newPassword) throw new Error('New password is required.');
320
+ return this.edit({
321
+ password: this.client.password ? this.client.password : oldPassword,
322
+ new_password: newPassword,
323
+ });
324
+ }
325
+
326
+ /**
327
+ * Disable account
328
+ * @param {string} password Password of the account
329
+ * @returns {Promise<ClientUser>}
330
+ */
331
+ async disableAccount(password) {
332
+ if (!password && !this.client.password) {
333
+ throw new Error('A password is required to disable an account.');
334
+ }
335
+ const data = await this.client.api.users['@me'].disable.post({
336
+ data: {
337
+ password: this.client.password ? this.client.password : password,
338
+ },
339
+ });
340
+ return data;
341
+ }
342
+
343
+ /**
344
+ * Set selfdeaf (Global)
345
+ * @param {boolean} status Whether or not the ClientUser is deafened
346
+ * @returns {boolean}
347
+ */
348
+ setDeaf(status) {
349
+ if (typeof status !== 'boolean') throw new Error('Deaf status must be a boolean.');
350
+ this.client.ws.broadcast({
351
+ op: Opcodes.VOICE_STATE_UPDATE,
352
+ d: { self_deaf: status },
353
+ });
354
+ return status;
355
+ }
356
+
357
+ /**
358
+ * Set selfmute (Global)
359
+ * @param {boolean} status Whether or not the ClientUser is muted
360
+ * @returns {boolean}
361
+ */
362
+ setMute(status) {
363
+ if (typeof status !== 'boolean') throw new Error('Mute status must be a boolean.');
364
+ this.client.ws.broadcast({
365
+ op: Opcodes.VOICE_STATE_UPDATE,
366
+ d: { self_mute: status },
367
+ });
368
+ return status;
369
+ }
370
+
371
+ /**
372
+ * Delete account. Warning: Cannot be changed once used!
373
+ * @param {string} password Password of the account
374
+ * @returns {Promise<ClientUser>}
375
+ */
376
+ async deleteAccount(password) {
377
+ if (!password && !this.client.password) {
378
+ throw new Error('A password is required to delete an account.');
379
+ }
380
+ const data = await this.client.api.users['@me/delete'].post({
381
+ data: {
382
+ password: this.client.password ? this.client.password : password,
383
+ },
384
+ });
385
+ return data;
386
+ }
180
387
 
181
388
  /**
182
389
  * Options for setting activities
183
390
  * @typedef {Object} ActivitiesOptions
184
- * @property {string} name Name of the activity
185
- * @property {string} [state] State of the activity
391
+ * @property {string} [name] Name of the activity
186
392
  * @property {ActivityType|number} [type] Type of the activity
187
393
  * @property {string} [url] Twitch / YouTube stream URL
188
394
  */
@@ -234,7 +440,7 @@ class ClientUser extends User {
234
440
  /**
235
441
  * Options for setting an activity.
236
442
  * @typedef {Object} ActivityOptions
237
- * @property {string} name Name of the activity
443
+ * @property {string} [name] Name of the activity
238
444
  * @property {string} [url] Twitch / YouTube stream URL
239
445
  * @property {ActivityType|number} [type] Type of the activity
240
446
  * @property {number|number[]} [shardId] Shard Id(s) to have the activity set on
@@ -242,7 +448,7 @@ class ClientUser extends User {
242
448
 
243
449
  /**
244
450
  * Sets the activity the client user is playing.
245
- * @param {string|ActivityOptions} name Activity being played, or options for setting the activity
451
+ * @param {string|ActivityOptions} [name] Activity being played, or options for setting the activity
246
452
  * @param {ActivityOptions} [options] Options for setting the activity
247
453
  * @returns {ClientPresence}
248
454
  * @example
@@ -251,10 +457,15 @@ class ClientUser extends User {
251
457
  * @see {@link https://github.com/aiko-chan-ai/discord.js-selfbot-v13/blob/main/Document/RichPresence.md}
252
458
  */
253
459
  setActivity(name, options = {}) {
254
- if (!name) return this.setPresence({ activities: [], shardId: options.shardId });
460
+ if (!name) {
461
+ return this.setPresence({ activities: [], shardId: options.shardId });
462
+ }
255
463
 
256
464
  const activity = Object.assign({}, options, typeof name === 'object' ? name : { name });
257
- return this.setPresence({ activities: [activity], shardId: activity.shardId });
465
+ return this.setPresence({
466
+ activities: [activity],
467
+ shardId: activity.shardId,
468
+ });
258
469
  }
259
470
 
260
471
  /**
@@ -267,81 +478,6 @@ class ClientUser extends User {
267
478
  return this.setPresence({ afk, shardId });
268
479
  }
269
480
 
270
- /**
271
- * Sets the banner of the logged in client.
272
- * @param {?(BufferResolvable|Base64Resolvable)} banner The new banner
273
- * @returns {Promise<ClientUser>}
274
- * @example
275
- * // Set banner
276
- * client.user.setBanner('./banner.png')
277
- * .then(user => console.log(`New banner set!`))
278
- * .catch(console.error);
279
- */
280
- async setBanner(banner) {
281
- banner = banner && (await DataResolver.resolveImage(banner));
282
- return this.edit({ banner });
283
- }
284
-
285
- /**
286
- * Set HyperSquad House
287
- * @param {string|number} type
288
- * * `LEAVE`: 0
289
- * * `HOUSE_BRAVERY`: 1
290
- * * `HOUSE_BRILLIANCE`: 2
291
- * * `HOUSE_BALANCE`: 3
292
- * @returns {Promise<void>}
293
- * @example
294
- * // Set HyperSquad HOUSE_BRAVERY
295
- * client.user.setHypeSquad(1); || client.user.setHypeSquad('HOUSE_BRAVERY');
296
- * // Leave
297
- * client.user.setHypeSquad(0);
298
- */
299
- setHypeSquad(type) {
300
- switch (type) {
301
- case 'LEAVE': {
302
- type = 0;
303
- break;
304
- }
305
- case 'HOUSE_BRAVERY': {
306
- type = 1;
307
- break;
308
- }
309
- case 'HOUSE_BRILLIANCE': {
310
- type = 2;
311
- break;
312
- }
313
- case 'HOUSE_BALANCE': {
314
- type = 3;
315
- break;
316
- }
317
- }
318
- if (type == 0) {
319
- return this.client.api.hypesquad.online.delete();
320
- } else {
321
- return this.client.api.hypesquad.online.post({
322
- data: { house_id: type },
323
- });
324
- }
325
- }
326
-
327
- /**
328
- * Set Accent color
329
- * @param {ColorResolvable} color Color to set
330
- * @returns {Promise<ClientUser>}
331
- */
332
- setAccentColor(color = null) {
333
- return this.edit({ accent_color: color ? Util.resolveColor(color) : null });
334
- }
335
-
336
- /**
337
- * Set About me
338
- * @param {string} [bio=null] Bio to set
339
- * @returns {Promise<ClientUser>}
340
- */
341
- setAboutMe(bio = null) {
342
- return this.edit({ bio });
343
- }
344
-
345
481
  /**
346
482
  * Create an invite [Friend Invites]
347
483
  * maxAge: 604800 | maxUses: 1
@@ -375,10 +511,63 @@ class ClientUser extends User {
375
511
 
376
512
  /**
377
513
  * Revoke all friend invites
378
- * @returns {Promise<void>}
514
+ * @returns {Promise<Collection<string, Invite>>}
379
515
  */
380
- revokeAllFriendInvites() {
381
- return this.client.api.users['@me'].invites.delete();
516
+ async revokeAllFriendInvites() {
517
+ const data = await this.client.api.users['@me'].invites.delete();
518
+ const collection = new Collection();
519
+ for (const invite of data) {
520
+ collection.set(invite.code, new Invite(this.client, invite));
521
+ }
522
+ return collection;
523
+ }
524
+
525
+ /**
526
+ * Get a collection of messages mentioning clientUser
527
+ * @param {number} [limit=25] Maximum number of messages to get
528
+ * @param {boolean} [mentionRoles=true] Whether or not to mention roles
529
+ * @param {boolean} [mentionEveryone=true] Whether or not to mention `@everyone`
530
+ * @returns {Promise<Collection<Snowflake, Message>>}
531
+ */
532
+ async getMentions(limit = 25, mentionRoles = true, mentionEveryone = true) {
533
+ // https://canary.discord.com/api/v9/users/@me/mentions?limit=25&roles=true&everyone=true
534
+ const data = await this.client.api.users['@me'].mentions.get({
535
+ query: {
536
+ limit,
537
+ roles: mentionRoles,
538
+ everyone: mentionEveryone,
539
+ },
540
+ });
541
+ const collection = new Collection();
542
+ for (const msg of data) {
543
+ collection.set(msg.id, new Message(this.client, msg));
544
+ }
545
+ return collection;
546
+ }
547
+
548
+ /**
549
+ * Change Theme color
550
+ * @param {ColorResolvable} primary The primary color of the user's profile
551
+ * @param {ColorResolvable} accent The accent color of the user's profile
552
+ * @returns {Promise<ClientUser>}
553
+ */
554
+ async setThemeColors(primary, accent) {
555
+ if (!primary || !accent) throw new Error('PRIMARY_COLOR or ACCENT_COLOR are required.');
556
+ // Check nitro
557
+ if (this.nitroType !== 'NITRO_BOOST') {
558
+ throw new Error_('NITRO_BOOST_REQUIRED', 'themeColors');
559
+ }
560
+ primary = Util.resolveColor(primary) || this.themeColors[0];
561
+ accent = Util.resolveColor(accent) || this.themeColors[1];
562
+ const data_ = await this.client.api.users['@me'].profile.patch({
563
+ data: {
564
+ theme_colors: [primary, accent],
565
+ },
566
+ });
567
+ this._ProfilePatch({
568
+ user_profile: data_,
569
+ });
570
+ return this;
382
571
  }
383
572
 
384
573
  /**
@@ -404,18 +593,48 @@ class ClientUser extends User {
404
593
  update: type,
405
594
  },
406
595
  });
407
- if (type !== 'STOP') this.#packageName = packageName;
408
- else this.#packageName = null;
596
+ if (type !== 'STOP') this._packageName = packageName;
597
+ else this._packageName = null;
409
598
  return this;
410
599
  }
411
600
 
601
+ /**
602
+ * Sets Discord Playing status to "Playing on Samsung Galaxy". Only selected gamss from discords database works
603
+ * @param {string} packageName Android package name
604
+ * @param {?string} type Must be START, UPDATE, or STOP
605
+ * @returns {Promise<ClientUser>}
606
+ * @example
607
+ * // Set the client user's status
608
+ * client.user.setSamsungActivity('com.YostarJP.BlueArchive', 'START');
609
+ * // Update
610
+ * client.user.setSamsungActivity('com.miHoYo.bh3oversea', 'UPDATE');
611
+ * // Stop
612
+ * client.user.setSamsungActivity('com.miHoYo.GenshinImpact', 'STOP');
613
+ */
614
+ async setSamsungActivity(packageName, type = 'START') {
615
+ type = type.toUpperCase();
616
+ if (!packageName || typeof packageName !== 'string') throw new Error('Package name is required.');
617
+ if (!['START', 'UPDATE', 'STOP'].includes(type)) throw new Error('Invalid type (Must be START, UPDATE, or STOP)');
618
+ await this.client.api.presences.post({
619
+ data: {
620
+ package_name: packageName,
621
+ update: type,
622
+ },
623
+ });
624
+ if (type !== 'STOP') this.#packageName = packageName;
625
+ else this.#packageName = null;
626
+ return this;
627
+ }
628
+
412
629
  /**
413
630
  * Stop ringing
414
631
  * @param {ChannelResolvable} channel DMChannel | GroupDMChannel
415
632
  * @returns {Promise<void>}
416
633
  */
417
634
  stopRinging(channel) {
418
- return this.client.api.channels(this.client.channels.resolveId(channel)).call['stop-ringing'].post({
635
+ const id = this.client.channels.resolveId(channel);
636
+ if (!channel) return false;
637
+ return this.client.api.channels(id).call['stop-ringing'].post({
419
638
  data: {},
420
639
  });
421
640
  }
@@ -22,7 +22,7 @@ class ContextMenuInteraction extends BaseCommandInteraction {
22
22
  );
23
23
 
24
24
  /**
25
- * The id of the target of this interaction
25
+ * The id of the target of the interaction
26
26
  * @type {Snowflake}
27
27
  */
28
28
  this.targetId = data.data.target_id;