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
@@ -7,7 +7,7 @@ const { TypeError } = require('../errors/DJSError.js');
7
7
  /**
8
8
  * @typedef {Function} GlobalSweepFilter
9
9
  * @returns {Function|null} Return `null` to skip sweeping, otherwise a function passed to `sweep()`,
10
- * See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/stable/Collection:Class#sweep)}
10
+ * See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/stable/Collection:Class?scrollTo=sweep)}
11
11
  * for the definition of this function.
12
12
  */
13
13
 
package/src/util/Util.js CHANGED
@@ -5,17 +5,12 @@ const process = require('node:process');
5
5
  const { Collection } = require('@discordjs/collection');
6
6
  const fetch = require('node-fetch');
7
7
  const { Colors } = require('./Constants');
8
- const { Error: DiscordError, RangeError, TypeError } = require('../errors');
8
+ const { RangeError, TypeError } = require('../errors');
9
9
  const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
10
10
  const isObject = d => typeof d === 'object' && d !== null;
11
11
 
12
12
  let deprecationEmittedForSplitMessage = false;
13
13
  let deprecationEmittedForRemoveMentions = false;
14
- let deprecationEmittedForResolveAutoArchiveMaxLimit = false;
15
-
16
- const TextSortableGroupTypes = ['GUILD_TEXT', 'GUILD_ANNOUCMENT', 'GUILD_FORUM'];
17
- const VoiceSortableGroupTypes = ['GUILD_VOICE', 'GUILD_STAGE_VOICE'];
18
- const CategorySortableGroupTypes = ['GUILD_CATEGORY'];
19
14
 
20
15
  /**
21
16
  * Contains various general-purpose utility methods.
@@ -139,7 +134,6 @@ class Util extends null {
139
134
  * @property {boolean} [numberedList=false] Whether to escape numbered lists
140
135
  * @property {boolean} [maskedLink=false] Whether to escape masked links
141
136
  */
142
-
143
137
  /**
144
138
  * Escapes any Discord-flavour markdown in a string.
145
139
  * @param {string} text Content to escape
@@ -222,7 +216,6 @@ class Util extends null {
222
216
  if (maskedLink) text = Util.escapeMaskedLink(text);
223
217
  return text;
224
218
  }
225
-
226
219
  /**
227
220
  * Escapes code block markdown in a string.
228
221
  * @param {string} text Content to escape
@@ -231,7 +224,6 @@ class Util extends null {
231
224
  static escapeCodeBlock(text) {
232
225
  return text.replaceAll('```', '\\`\\`\\`');
233
226
  }
234
-
235
227
  /**
236
228
  * Escapes inline code markdown in a string.
237
229
  * @param {string} text Content to escape
@@ -240,7 +232,6 @@ class Util extends null {
240
232
  static escapeInlineCode(text) {
241
233
  return text.replace(/(?<=^|[^`])``?(?=[^`]|$)/g, match => (match.length === 2 ? '\\`\\`' : '\\`'));
242
234
  }
243
-
244
235
  /**
245
236
  * Escapes italic markdown in a string.
246
237
  * @param {string} text Content to escape
@@ -258,7 +249,6 @@ class Util extends null {
258
249
  return `\\_${match}`;
259
250
  });
260
251
  }
261
-
262
252
  /**
263
253
  * Escapes bold markdown in a string.
264
254
  * @param {string} text Content to escape
@@ -271,7 +261,6 @@ class Util extends null {
271
261
  return '\\*\\*';
272
262
  });
273
263
  }
274
-
275
264
  /**
276
265
  * Escapes underline markdown in a string.
277
266
  * @param {string} text Content to escape
@@ -284,7 +273,6 @@ class Util extends null {
284
273
  return '\\_\\_';
285
274
  });
286
275
  }
287
-
288
276
  /**
289
277
  * Escapes strikethrough markdown in a string.
290
278
  * @param {string} text Content to escape
@@ -293,7 +281,6 @@ class Util extends null {
293
281
  static escapeStrikethrough(text) {
294
282
  return text.replaceAll('~~', '\\~\\~');
295
283
  }
296
-
297
284
  /**
298
285
  * Escapes spoiler markdown in a string.
299
286
  * @param {string} text Content to escape
@@ -302,7 +289,6 @@ class Util extends null {
302
289
  static escapeSpoiler(text) {
303
290
  return text.replaceAll('||', '\\|\\|');
304
291
  }
305
-
306
292
  /**
307
293
  * Escapes escape characters in a string.
308
294
  * @param {string} text Content to escape
@@ -311,7 +297,6 @@ class Util extends null {
311
297
  static escapeEscape(text) {
312
298
  return text.replaceAll('\\', '\\\\');
313
299
  }
314
-
315
300
  /**
316
301
  * Escapes heading characters in a string.
317
302
  * @param {string} text Content to escape
@@ -320,7 +305,6 @@ class Util extends null {
320
305
  static escapeHeading(text) {
321
306
  return text.replaceAll(/^( {0,2}[*-] +)?(#{1,3} )/gm, '$1\\$2');
322
307
  }
323
-
324
308
  /**
325
309
  * Escapes bulleted list characters in a string.
326
310
  * @param {string} text Content to escape
@@ -329,7 +313,6 @@ class Util extends null {
329
313
  static escapeBulletedList(text) {
330
314
  return text.replaceAll(/^( *)[*-]( +)/gm, '$1\\-$2');
331
315
  }
332
-
333
316
  /**
334
317
  * Escapes numbered list characters in a string.
335
318
  * @param {string} text Content to escape
@@ -338,7 +321,6 @@ class Util extends null {
338
321
  static escapeNumberedList(text) {
339
322
  return text.replaceAll(/^( *\d+)\./gm, '$1\\.');
340
323
  }
341
-
342
324
  /**
343
325
  * Escapes masked link characters in a string.
344
326
  * @param {string} text Content to escape
@@ -348,16 +330,6 @@ class Util extends null {
348
330
  return text.replaceAll(/\[.+\]\(.+\)/gm, '\\$&');
349
331
  }
350
332
 
351
- /**
352
- * @typedef {Object} FetchRecommendedShardsOptions
353
- * @property {number} [guildsPerShard=1000] Number of guilds assigned per shard
354
- * @property {number} [multipleOf=1] The multiple the shard count should round up to. (16 for large bot sharding)
355
- */
356
-
357
- static fetchRecommendedShards() {
358
- throw new DiscordError('INVALID_USER_API');
359
- }
360
-
361
333
  /**
362
334
  * Parses emoji info out of a string. The string must be one of:
363
335
  * * A UTF-8 emoji (no id)
@@ -647,22 +619,26 @@ class Util extends null {
647
619
 
648
620
  /**
649
621
  * Resolves the maximum time a guild's thread channels should automatically archive in case of no recent activity.
650
- * @param {Guild} guild The guild to resolve this limit from.
651
- * @deprecated This will be removed in the next major version.
622
+ * @deprecated
652
623
  * @returns {number}
653
624
  */
654
625
  static resolveAutoArchiveMaxLimit() {
655
- if (!deprecationEmittedForResolveAutoArchiveMaxLimit) {
656
- process.emitWarning(
657
- // eslint-disable-next-line max-len
658
- "The Util.resolveAutoArchiveMaxLimit method and the 'MAX' option are deprecated and will be removed in the next major version.",
659
- 'DeprecationWarning',
660
- );
661
- deprecationEmittedForResolveAutoArchiveMaxLimit = true;
662
- }
663
626
  return 10080;
664
627
  }
665
628
 
629
+ /**
630
+ * Lazily evaluates a callback function (yea it's v14 :yay:)
631
+ * @param {Function} cb The callback to lazily evaluate
632
+ * @returns {Function}
633
+ * @example
634
+ * const User = lazy(() => require('./User'));
635
+ * const user = new (User())(client, data);
636
+ */
637
+ static lazy(cb) {
638
+ let defaultValue;
639
+ return () => (defaultValue ??= cb());
640
+ }
641
+
666
642
  /**
667
643
  * Transforms an API guild forum tag to camel-cased guild forum tag.
668
644
  * @param {APIGuildForumTag} tag The tag to transform
@@ -728,44 +704,11 @@ class Util extends null {
728
704
  };
729
705
  }
730
706
 
731
- /**
732
- * Gets an array of the channel types that can be moved in the channel group. For example, a GuildText channel would
733
- * return an array containing the types that can be ordered within the text channels (always at the top), and a voice
734
- * channel would return an array containing the types that can be ordered within the voice channels (always at the
735
- * bottom).
736
- * @param {ChannelType} type The type of the channel
737
- * @returns {ChannelType[]}
738
- * @ignore
739
- */
740
- static getSortableGroupTypes(type) {
741
- switch (type) {
742
- case 'GUILD_TEXT':
743
- case 'GUILD_ANNOUNCEMENT':
744
- case 'GUILD_FORUM':
745
- return TextSortableGroupTypes;
746
- case 'GUILD_VOICE':
747
- case 'GUILD_STAGE_VOICE':
748
- return VoiceSortableGroupTypes;
749
- case 'GUILD_CATEGORY':
750
- return CategorySortableGroupTypes;
751
- default:
752
- return [type];
753
- }
754
- }
755
-
756
- /**
757
- * Calculates the default avatar index for a given user id.
758
- * @param {Snowflake} userId - The user id to calculate the default avatar index for
759
- * @returns {number}
760
- */
761
- static calculateUserDefaultAvatarIndex(userId) {
762
- return Number(BigInt(userId) >> 22n) % 6;
763
- }
764
-
765
- static async getUploadURL(client, channelId, files) {
707
+ static async getAttachments(client, channelId, ...files) {
708
+ files = files.flat(2);
766
709
  if (!files.length) return [];
767
710
  files = files.map((file, i) => ({
768
- filename: file.name,
711
+ filename: file.name ?? file.attachment?.name ?? file.attachment?.filename ?? 'file.jpg',
769
712
  // 25MB = 26_214_400bytes
770
713
  file_size: Math.floor((26_214_400 / 10) * Math.random()),
771
714
  id: `${i}`,
@@ -783,7 +726,6 @@ class Util extends null {
783
726
  fetch(url, {
784
727
  method: 'PUT',
785
728
  body: data,
786
- duplex: 'half', // Node.js v20
787
729
  })
788
730
  .then(res => {
789
731
  if (res.ok) {
@@ -795,6 +737,24 @@ class Util extends null {
795
737
  .catch(reject);
796
738
  });
797
739
  }
740
+
741
+ static testImportModule(name) {
742
+ try {
743
+ require.resolve(name);
744
+ return true;
745
+ } catch {
746
+ return false;
747
+ }
748
+ }
749
+
750
+ /**
751
+ * Calculates the default avatar index for a given user id.
752
+ * @param {Snowflake} userId - The user id to calculate the default avatar index for
753
+ * @returns {number}
754
+ */
755
+ static calculateUserDefaultAvatarIndex(userId) {
756
+ return Number(BigInt(userId) >> 22n) % 6;
757
+ }
798
758
  }
799
759
 
800
760
  module.exports = Util;