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.
Files changed (155) hide show
  1. package/README.md +18 -35
  2. package/package.json +85 -100
  3. package/src/client/BaseClient.js +3 -4
  4. package/src/client/Client.js +249 -530
  5. package/src/client/actions/Action.js +18 -13
  6. package/src/client/actions/ActionsManager.js +7 -1
  7. package/src/client/actions/AutoModerationActionExecution.js +1 -0
  8. package/src/client/actions/AutoModerationRuleCreate.js +1 -0
  9. package/src/client/actions/AutoModerationRuleDelete.js +1 -0
  10. package/src/client/actions/AutoModerationRuleUpdate.js +1 -0
  11. package/src/client/actions/GuildMemberRemove.js +0 -1
  12. package/src/client/actions/GuildMemberUpdate.js +0 -1
  13. package/src/client/actions/MessageCreate.js +0 -4
  14. package/src/client/actions/PresenceUpdate.js +17 -16
  15. package/src/client/websocket/WebSocketManager.js +11 -31
  16. package/src/client/websocket/WebSocketShard.js +39 -38
  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 +16 -13
  21. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
  22. package/src/client/websocket/handlers/GUILD_CREATE.js +19 -13
  23. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +0 -1
  24. package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +1 -0
  25. package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.js +22 -0
  26. package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.js +12 -0
  27. package/src/client/websocket/handlers/READY.js +90 -140
  28. package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +7 -5
  29. package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +7 -5
  30. package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +32 -9
  31. package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +2 -8
  32. package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
  33. package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +78 -0
  34. package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +1 -5
  35. package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +12 -0
  36. package/src/client/websocket/handlers/index.js +17 -20
  37. package/src/errors/Messages.js +25 -69
  38. package/src/index.js +13 -43
  39. package/src/managers/ApplicationCommandManager.js +9 -12
  40. package/src/managers/ApplicationCommandPermissionsManager.js +3 -11
  41. package/src/managers/ChannelManager.js +2 -3
  42. package/src/managers/ClientUserSettingManager.js +162 -280
  43. package/src/managers/GuildBanManager.js +47 -1
  44. package/src/managers/GuildChannelManager.js +2 -16
  45. package/src/managers/GuildForumThreadManager.js +24 -30
  46. package/src/managers/GuildManager.js +1 -1
  47. package/src/managers/GuildMemberManager.js +50 -222
  48. package/src/managers/GuildSettingManager.js +22 -15
  49. package/src/managers/MessageManager.js +42 -44
  50. package/src/managers/PermissionOverwriteManager.js +1 -1
  51. package/src/managers/ReactionUserManager.js +5 -5
  52. package/src/managers/RelationshipManager.js +83 -76
  53. package/src/managers/ThreadManager.js +12 -45
  54. package/src/managers/ThreadMemberManager.js +1 -1
  55. package/src/managers/UserManager.js +6 -10
  56. package/src/managers/UserNoteManager.js +53 -0
  57. package/src/rest/APIRequest.js +48 -20
  58. package/src/rest/DiscordAPIError.js +17 -16
  59. package/src/rest/RESTManager.js +1 -21
  60. package/src/rest/RequestHandler.js +35 -21
  61. package/src/structures/ApplicationCommand.js +19 -456
  62. package/src/structures/ApplicationRoleConnectionMetadata.js +3 -0
  63. package/src/structures/AutoModerationRule.js +5 -5
  64. package/src/structures/AutocompleteInteraction.js +1 -0
  65. package/src/structures/BaseGuildTextChannel.js +10 -12
  66. package/src/structures/BaseGuildVoiceChannel.js +16 -18
  67. package/src/structures/{Call.js → CallState.js} +17 -12
  68. package/src/structures/CategoryChannel.js +2 -0
  69. package/src/structures/Channel.js +2 -3
  70. package/src/structures/ClientPresence.js +20 -19
  71. package/src/structures/ClientUser.js +117 -338
  72. package/src/structures/ContextMenuInteraction.js +1 -1
  73. package/src/structures/DMChannel.js +29 -92
  74. package/src/structures/ForumChannel.js +0 -10
  75. package/src/structures/GroupDMChannel.js +387 -0
  76. package/src/structures/Guild.js +135 -271
  77. package/src/structures/GuildAuditLogs.js +0 -5
  78. package/src/structures/GuildChannel.js +16 -2
  79. package/src/structures/GuildMember.js +27 -145
  80. package/src/structures/Interaction.js +1 -62
  81. package/src/structures/Invite.js +35 -52
  82. package/src/structures/Message.js +220 -203
  83. package/src/structures/MessageAttachment.js +11 -0
  84. package/src/structures/MessageButton.js +1 -67
  85. package/src/structures/MessageEmbed.js +1 -1
  86. package/src/structures/MessageMentions.js +3 -2
  87. package/src/structures/MessagePayload.js +6 -46
  88. package/src/structures/MessagePoll.js +238 -0
  89. package/src/structures/MessageReaction.js +1 -1
  90. package/src/structures/MessageSelectMenu.js +1 -252
  91. package/src/structures/Modal.js +70 -188
  92. package/src/structures/Presence.js +787 -129
  93. package/src/structures/Role.js +18 -2
  94. package/src/structures/SelectMenuInteraction.js +2 -151
  95. package/src/structures/Team.js +0 -49
  96. package/src/structures/TextInputComponent.js +0 -70
  97. package/src/structures/ThreadChannel.js +0 -19
  98. package/src/structures/User.js +145 -339
  99. package/src/structures/UserContextMenuInteraction.js +2 -2
  100. package/src/structures/VoiceState.js +74 -39
  101. package/src/structures/WebEmbed.js +38 -52
  102. package/src/structures/Webhook.js +17 -11
  103. package/src/structures/interfaces/Application.js +146 -23
  104. package/src/structures/interfaces/TextBasedChannel.js +409 -256
  105. package/src/util/ApplicationFlags.js +1 -1
  106. package/src/util/AttachmentFlags.js +38 -0
  107. package/src/util/Constants.js +120 -285
  108. package/src/util/Formatters.js +16 -2
  109. package/src/util/InviteFlags.js +29 -0
  110. package/src/util/LimitedCollection.js +1 -1
  111. package/src/util/Options.js +48 -74
  112. package/src/util/Permissions.js +15 -0
  113. package/src/util/PurchasedFlags.js +2 -0
  114. package/src/util/RemoteAuth.js +221 -356
  115. package/src/util/RoleFlags.js +37 -0
  116. package/src/util/Sweepers.js +1 -1
  117. package/src/util/Util.js +158 -32
  118. package/typings/enums.d.ts +24 -73
  119. package/typings/index.d.ts +978 -1288
  120. package/typings/rawDataTypes.d.ts +68 -9
  121. package/src/client/actions/InteractionCreate.js +0 -115
  122. package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +0 -23
  123. package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +0 -11
  124. package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +0 -55
  125. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +0 -0
  126. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +0 -0
  127. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.js +0 -0
  128. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +0 -0
  129. package/src/client/websocket/handlers/INTERACTION_CREATE.js +0 -16
  130. package/src/client/websocket/handlers/INTERACTION_FAILURE.js +0 -18
  131. package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +0 -30
  132. package/src/client/websocket/handlers/MESSAGE_ACK.js +0 -16
  133. package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
  134. package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
  135. package/src/managers/DeveloperPortalManager.js +0 -104
  136. package/src/managers/GuildApplicationCommandManager.js +0 -28
  137. package/src/managers/GuildFolderManager.js +0 -24
  138. package/src/managers/SessionManager.js +0 -57
  139. package/src/rest/CaptchaSolver.js +0 -132
  140. package/src/structures/ClientApplication.js +0 -204
  141. package/src/structures/DeveloperPortalApplication.js +0 -520
  142. package/src/structures/GuildFolder.js +0 -75
  143. package/src/structures/InteractionResponse.js +0 -114
  144. package/src/structures/PartialGroupDMChannel.js +0 -433
  145. package/src/structures/RichPresence.js +0 -722
  146. package/src/structures/Session.js +0 -81
  147. package/src/util/Voice.js +0 -1456
  148. package/src/util/arRPC/index.js +0 -229
  149. package/src/util/arRPC/process/detectable.json +0 -1
  150. package/src/util/arRPC/process/index.js +0 -102
  151. package/src/util/arRPC/process/native/index.js +0 -5
  152. package/src/util/arRPC/process/native/linux.js +0 -37
  153. package/src/util/arRPC/process/native/win32.js +0 -25
  154. package/src/util/arRPC/transports/ipc.js +0 -281
  155. package/src/util/arRPC/transports/websocket.js +0 -128
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ const BitField = require('./BitField');
4
+
5
+ /**
6
+ * Data structure that makes it easy to interact with an {@link GuildMember#flags} bitfield.
7
+ * @extends {BitField}
8
+ */
9
+ class RoleFlags extends BitField {}
10
+
11
+ /**
12
+ * @name RoleFlags
13
+ * @kind constructor
14
+ * @memberof RoleFlags
15
+ * @param {BitFieldResolvable} [bits=0] Bit(s) to read from
16
+ */
17
+
18
+ /**
19
+ * Numeric guild member flags. All available properties:
20
+ * * `IN_PROMPT`
21
+ * @type {Object}
22
+ * @see {@link https://discord.com/developers/docs/topics/permissions#role-object-role-flags}
23
+ */
24
+ RoleFlags.FLAGS = {
25
+ IN_PROMPT: 1 << 0,
26
+ };
27
+
28
+ /**
29
+ * Data that can be resolved to give a role flag bitfield. This can be:
30
+ * * A string (see {@link RoleFlags.FLAGS})
31
+ * * A role flag
32
+ * * An instance of RoleFlags
33
+ * * An Array of RoleFlagsResolvable
34
+ * @typedef {string|number|RoleFlags|RoleFlagsResolvable[]} RoleFlagsResolvable
35
+ */
36
+
37
+ module.exports = RoleFlags;
@@ -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?scrollTo=sweep)}
10
+ * See {@link [Collection#sweep](https://discord.js.org/docs/packages/collection/stable/Collection:Class#sweep)}
11
11
  * for the definition of this function.
12
12
  */
13
13
 
package/src/util/Util.js CHANGED
@@ -1,16 +1,23 @@
1
1
  'use strict';
2
2
 
3
+ const { Agent } = require('node:http');
3
4
  const { parse } = require('node:path');
4
5
  const process = require('node:process');
6
+ const { setTimeout } = require('node:timers');
5
7
  const { Collection } = require('@discordjs/collection');
6
8
  const fetch = require('node-fetch');
7
- const { Colors } = require('./Constants');
8
- const { RangeError, TypeError } = require('../errors');
9
+ const { Colors, Events } = require('./Constants');
10
+ const { Error: DiscordError, RangeError, TypeError } = require('../errors');
9
11
  const has = (o, k) => Object.prototype.hasOwnProperty.call(o, k);
10
12
  const isObject = d => typeof d === 'object' && d !== null;
11
13
 
12
14
  let deprecationEmittedForSplitMessage = false;
13
15
  let deprecationEmittedForRemoveMentions = false;
16
+ let deprecationEmittedForResolveAutoArchiveMaxLimit = false;
17
+
18
+ const TextSortableGroupTypes = ['GUILD_TEXT', 'GUILD_ANNOUCMENT', 'GUILD_FORUM'];
19
+ const VoiceSortableGroupTypes = ['GUILD_VOICE', 'GUILD_STAGE_VOICE'];
20
+ const CategorySortableGroupTypes = ['GUILD_CATEGORY'];
14
21
 
15
22
  /**
16
23
  * Contains various general-purpose utility methods.
@@ -134,6 +141,7 @@ class Util extends null {
134
141
  * @property {boolean} [numberedList=false] Whether to escape numbered lists
135
142
  * @property {boolean} [maskedLink=false] Whether to escape masked links
136
143
  */
144
+
137
145
  /**
138
146
  * Escapes any Discord-flavour markdown in a string.
139
147
  * @param {string} text Content to escape
@@ -216,6 +224,7 @@ class Util extends null {
216
224
  if (maskedLink) text = Util.escapeMaskedLink(text);
217
225
  return text;
218
226
  }
227
+
219
228
  /**
220
229
  * Escapes code block markdown in a string.
221
230
  * @param {string} text Content to escape
@@ -224,6 +233,7 @@ class Util extends null {
224
233
  static escapeCodeBlock(text) {
225
234
  return text.replaceAll('```', '\\`\\`\\`');
226
235
  }
236
+
227
237
  /**
228
238
  * Escapes inline code markdown in a string.
229
239
  * @param {string} text Content to escape
@@ -232,6 +242,7 @@ class Util extends null {
232
242
  static escapeInlineCode(text) {
233
243
  return text.replace(/(?<=^|[^`])``?(?=[^`]|$)/g, match => (match.length === 2 ? '\\`\\`' : '\\`'));
234
244
  }
245
+
235
246
  /**
236
247
  * Escapes italic markdown in a string.
237
248
  * @param {string} text Content to escape
@@ -249,6 +260,7 @@ class Util extends null {
249
260
  return `\\_${match}`;
250
261
  });
251
262
  }
263
+
252
264
  /**
253
265
  * Escapes bold markdown in a string.
254
266
  * @param {string} text Content to escape
@@ -261,6 +273,7 @@ class Util extends null {
261
273
  return '\\*\\*';
262
274
  });
263
275
  }
276
+
264
277
  /**
265
278
  * Escapes underline markdown in a string.
266
279
  * @param {string} text Content to escape
@@ -273,6 +286,7 @@ class Util extends null {
273
286
  return '\\_\\_';
274
287
  });
275
288
  }
289
+
276
290
  /**
277
291
  * Escapes strikethrough markdown in a string.
278
292
  * @param {string} text Content to escape
@@ -281,6 +295,7 @@ class Util extends null {
281
295
  static escapeStrikethrough(text) {
282
296
  return text.replaceAll('~~', '\\~\\~');
283
297
  }
298
+
284
299
  /**
285
300
  * Escapes spoiler markdown in a string.
286
301
  * @param {string} text Content to escape
@@ -289,6 +304,7 @@ class Util extends null {
289
304
  static escapeSpoiler(text) {
290
305
  return text.replaceAll('||', '\\|\\|');
291
306
  }
307
+
292
308
  /**
293
309
  * Escapes escape characters in a string.
294
310
  * @param {string} text Content to escape
@@ -297,6 +313,7 @@ class Util extends null {
297
313
  static escapeEscape(text) {
298
314
  return text.replaceAll('\\', '\\\\');
299
315
  }
316
+
300
317
  /**
301
318
  * Escapes heading characters in a string.
302
319
  * @param {string} text Content to escape
@@ -305,6 +322,7 @@ class Util extends null {
305
322
  static escapeHeading(text) {
306
323
  return text.replaceAll(/^( {0,2}[*-] +)?(#{1,3} )/gm, '$1\\$2');
307
324
  }
325
+
308
326
  /**
309
327
  * Escapes bulleted list characters in a string.
310
328
  * @param {string} text Content to escape
@@ -313,6 +331,7 @@ class Util extends null {
313
331
  static escapeBulletedList(text) {
314
332
  return text.replaceAll(/^( *)[*-]( +)/gm, '$1\\-$2');
315
333
  }
334
+
316
335
  /**
317
336
  * Escapes numbered list characters in a string.
318
337
  * @param {string} text Content to escape
@@ -321,6 +340,7 @@ class Util extends null {
321
340
  static escapeNumberedList(text) {
322
341
  return text.replaceAll(/^( *\d+)\./gm, '$1\\.');
323
342
  }
343
+
324
344
  /**
325
345
  * Escapes masked link characters in a string.
326
346
  * @param {string} text Content to escape
@@ -330,6 +350,16 @@ class Util extends null {
330
350
  return text.replaceAll(/\[.+\]\(.+\)/gm, '\\$&');
331
351
  }
332
352
 
353
+ /**
354
+ * @typedef {Object} FetchRecommendedShardsOptions
355
+ * @property {number} [guildsPerShard=1000] Number of guilds assigned per shard
356
+ * @property {number} [multipleOf=1] The multiple the shard count should round up to. (16 for large bot sharding)
357
+ */
358
+
359
+ static fetchRecommendedShards() {
360
+ throw new DiscordError('INVALID_USER_API');
361
+ }
362
+
333
363
  /**
334
364
  * Parses emoji info out of a string. The string must be one of:
335
365
  * * A UTF-8 emoji (no id)
@@ -576,7 +606,7 @@ class Util extends null {
576
606
  return user ? Util._removeMentions(`@${user.username}`) : input;
577
607
  }
578
608
 
579
- const member = channel.guild.members.cache.get(id);
609
+ const member = channel.guild?.members.cache.get(id);
580
610
  if (member) {
581
611
  return Util._removeMentions(`@${member.displayName}`);
582
612
  } else {
@@ -619,26 +649,22 @@ class Util extends null {
619
649
 
620
650
  /**
621
651
  * Resolves the maximum time a guild's thread channels should automatically archive in case of no recent activity.
622
- * @deprecated
652
+ * @param {Guild} guild The guild to resolve this limit from.
653
+ * @deprecated This will be removed in the next major version.
623
654
  * @returns {number}
624
655
  */
625
656
  static resolveAutoArchiveMaxLimit() {
657
+ if (!deprecationEmittedForResolveAutoArchiveMaxLimit) {
658
+ process.emitWarning(
659
+ // eslint-disable-next-line max-len
660
+ "The Util.resolveAutoArchiveMaxLimit method and the 'MAX' option are deprecated and will be removed in the next major version.",
661
+ 'DeprecationWarning',
662
+ );
663
+ deprecationEmittedForResolveAutoArchiveMaxLimit = true;
664
+ }
626
665
  return 10080;
627
666
  }
628
667
 
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
-
642
668
  /**
643
669
  * Transforms an API guild forum tag to camel-cased guild forum tag.
644
670
  * @param {APIGuildForumTag} tag The tag to transform
@@ -704,11 +730,44 @@ class Util extends null {
704
730
  };
705
731
  }
706
732
 
707
- static async getAttachments(client, channelId, ...files) {
708
- files = files.flat(2);
733
+ /**
734
+ * Gets an array of the channel types that can be moved in the channel group. For example, a GuildText channel would
735
+ * return an array containing the types that can be ordered within the text channels (always at the top), and a voice
736
+ * channel would return an array containing the types that can be ordered within the voice channels (always at the
737
+ * bottom).
738
+ * @param {ChannelType} type The type of the channel
739
+ * @returns {ChannelType[]}
740
+ * @ignore
741
+ */
742
+ static getSortableGroupTypes(type) {
743
+ switch (type) {
744
+ case 'GUILD_TEXT':
745
+ case 'GUILD_ANNOUNCEMENT':
746
+ case 'GUILD_FORUM':
747
+ return TextSortableGroupTypes;
748
+ case 'GUILD_VOICE':
749
+ case 'GUILD_STAGE_VOICE':
750
+ return VoiceSortableGroupTypes;
751
+ case 'GUILD_CATEGORY':
752
+ return CategorySortableGroupTypes;
753
+ default:
754
+ return [type];
755
+ }
756
+ }
757
+
758
+ /**
759
+ * Calculates the default avatar index for a given user id.
760
+ * @param {Snowflake} userId - The user id to calculate the default avatar index for
761
+ * @returns {number}
762
+ */
763
+ static calculateUserDefaultAvatarIndex(userId) {
764
+ return Number(BigInt(userId) >> 22n) % 6;
765
+ }
766
+
767
+ static async getUploadURL(client, channelId, files) {
709
768
  if (!files.length) return [];
710
769
  files = files.map((file, i) => ({
711
- filename: file.name ?? file.attachment?.name ?? file.attachment?.filename ?? 'file.jpg',
770
+ filename: file.name,
712
771
  // 25MB = 26_214_400bytes
713
772
  file_size: Math.floor((26_214_400 / 10) * Math.random()),
714
773
  id: `${i}`,
@@ -726,6 +785,7 @@ class Util extends null {
726
785
  fetch(url, {
727
786
  method: 'PUT',
728
787
  body: data,
788
+ duplex: 'half', // Node.js v20
729
789
  })
730
790
  .then(res => {
731
791
  if (res.ok) {
@@ -738,22 +798,88 @@ class Util extends null {
738
798
  });
739
799
  }
740
800
 
741
- static testImportModule(name) {
742
- try {
743
- require.resolve(name);
744
- return true;
745
- } catch {
746
- return false;
747
- }
801
+ /**
802
+ * Lazily evaluates a callback function (yea it's v14 :yay:)
803
+ * @param {Function} cb The callback to lazily evaluate
804
+ * @returns {Function}
805
+ * @example
806
+ * const User = lazy(() => require('./User'));
807
+ * const user = new (User())(client, data);
808
+ */
809
+ static lazy(cb) {
810
+ let defaultValue;
811
+ return () => (defaultValue ??= cb());
748
812
  }
749
813
 
750
814
  /**
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}
815
+ * Hacking check object instanceof Proxy-agent
816
+ * @param {Object} object any
817
+ * @returns {boolean}
754
818
  */
755
- static calculateUserDefaultAvatarIndex(userId) {
756
- return Number(BigInt(userId) >> 22n) % 6;
819
+ static verifyProxyAgent(object) {
820
+ return typeof object == 'object' && object.httpAgent instanceof Agent && object.httpsAgent instanceof Agent;
821
+ }
822
+
823
+ static createPromiseInteraction(client, nonce, timeoutMs = 5_000, isHandlerDeferUpdate = false, parent) {
824
+ return new Promise((resolve, reject) => {
825
+ // Waiting for MsgCreate / ModalCreate
826
+ let dataFromInteractionSuccess;
827
+ let dataFromNormal;
828
+ const handler = data => {
829
+ // UnhandledPacket
830
+ if (isHandlerDeferUpdate && data.d?.nonce == nonce && data.t == 'INTERACTION_SUCCESS') {
831
+ // Interaction#deferUpdate
832
+ client.removeListener(Events.MESSAGE_CREATE, handler);
833
+ client.removeListener(Events.UNHANDLED_PACKET, handler);
834
+ client.removeListener(Events.INTERACTION_MODAL_CREATE, handler);
835
+ dataFromInteractionSuccess = parent;
836
+ }
837
+ if (data.nonce !== nonce) return;
838
+ clearTimeout(timeout);
839
+ client.removeListener(Events.MESSAGE_CREATE, handler);
840
+ client.removeListener(Events.INTERACTION_MODAL_CREATE, handler);
841
+ if (isHandlerDeferUpdate) client.removeListener(Events.UNHANDLED_PACKET, handler);
842
+ client.decrementMaxListeners();
843
+ dataFromNormal = data;
844
+ resolve(data);
845
+ };
846
+ const timeout = setTimeout(() => {
847
+ if (dataFromInteractionSuccess || dataFromNormal) {
848
+ resolve(dataFromNormal || dataFromInteractionSuccess);
849
+ return;
850
+ }
851
+ client.removeListener(Events.MESSAGE_CREATE, handler);
852
+ client.removeListener(Events.INTERACTION_MODAL_CREATE, handler);
853
+ if (isHandlerDeferUpdate) client.removeListener(Events.UNHANDLED_PACKET, handler);
854
+ client.decrementMaxListeners();
855
+ reject(new Error('INTERACTION_FAILED'));
856
+ }, timeoutMs).unref();
857
+ client.incrementMaxListeners();
858
+ client.on(Events.MESSAGE_CREATE, handler);
859
+ client.on(Events.INTERACTION_MODAL_CREATE, handler);
860
+ if (isHandlerDeferUpdate) client.on(Events.UNHANDLED_PACKET, handler);
861
+ });
862
+ }
863
+
864
+ static clearNullOrUndefinedObject(object) {
865
+ const data = {};
866
+ const keys = Object.keys(object);
867
+
868
+ for (const key of keys) {
869
+ const value = object[key];
870
+ if (value === undefined || value === null || (Array.isArray(value) && value.length === 0)) {
871
+ continue;
872
+ } else if (!Array.isArray(value) && typeof value === 'object') {
873
+ const cleanedValue = Util.clearNullOrUndefinedObject(value);
874
+ if (cleanedValue !== undefined) {
875
+ data[key] = cleanedValue;
876
+ }
877
+ } else {
878
+ data[key] = value;
879
+ }
880
+ }
881
+
882
+ return Object.keys(data).length > 0 ? data : undefined;
757
883
  }
758
884
  }
759
885
 
@@ -8,67 +8,7 @@ export const enum ActivityTypes {
8
8
  WATCHING = 3,
9
9
  CUSTOM = 4,
10
10
  COMPETING = 5,
11
- }
12
-
13
- export const enum DMScanLevel {
14
- NOT_SCAN = 0,
15
- NOT_FRIEND = 1,
16
- EVERYONE = 2,
17
- }
18
-
19
- export const enum stickerAnimationMode {
20
- ALWAYS = 0,
21
- INTERACTION = 1,
22
- NEVER = 2,
23
- }
24
-
25
- export const enum NitroType {
26
- NONE = 0,
27
- NITRO_CLASSIC = 1,
28
- NITRO_BOOST = 2,
29
- NITRO_BASIC = 3,
30
- }
31
-
32
- export const enum RelationshipTypes {
33
- NONE = 0,
34
- FRIEND = 1,
35
- BLOCKED = 2,
36
- PENDING_INCOMING = 3,
37
- PENDING_OUTGOING = 4,
38
- IMPLICIT = 5,
39
- }
40
-
41
- export const enum localeSetting {
42
- DANISH = 'da',
43
- GERMAN = 'de',
44
- ENGLISH_UK = 'en-GB',
45
- ENGLISH_US = 'en-US',
46
- SPANISH = 'es-ES',
47
- FRENCH = 'fr',
48
- CROATIAN = 'hr',
49
- ITALIAN = 'it',
50
- LITHUANIAN = 'lt',
51
- HUNGARIAN = 'hu',
52
- DUTCH = 'nl',
53
- NORWEGIAN = 'no',
54
- POLISH = 'pl',
55
- BRAZILIAN_PORTUGUESE = 'pt-BR',
56
- ROMANIA_ROMANIAN = 'ro',
57
- FINNISH = 'fi',
58
- SWEDISH = 'sv-SE',
59
- VIETNAMESE = 'vi',
60
- TURKISH = 'tr',
61
- CZECH = 'cs',
62
- GREEK = 'el',
63
- BULGARIAN = 'bg',
64
- RUSSIAN = 'ru',
65
- UKRAINIAN = 'uk',
66
- HINDI = 'hi',
67
- THAI = 'th',
68
- CHINA_CHINESE = 'zh-CN',
69
- JAPANESE = 'ja',
70
- TAIWAN_CHINESE = 'zh-TW',
71
- KOREAN = 'ko',
11
+ HANG = 6,
72
12
  }
73
13
 
74
14
  export const enum ApplicationCommandTypes {
@@ -147,6 +87,11 @@ export const enum ForumLayoutType {
147
87
  GALLERY_VIEW = 2,
148
88
  }
149
89
 
90
+ export const enum MessagePollLayoutType {
91
+ DEFAULT = 1,
92
+ IMAGE_ONLY_ANSWERS,
93
+ }
94
+
150
95
  export const enum MessageTypes {
151
96
  DEFAULT,
152
97
  RECIPIENT_ADD,
@@ -203,13 +148,6 @@ export const enum GuildScheduledEventStatuses {
203
148
  CANCELED = 4,
204
149
  }
205
150
 
206
- export const enum HypeSquadType {
207
- LEAVE = 0,
208
- HOUSE_BRAVERY = 1,
209
- HOUSE_BRILLIANCE = 2,
210
- HOUSE_BALANCE = 3,
211
- }
212
-
213
151
  export const enum InteractionResponseTypes {
214
152
  PONG = 1,
215
153
  CHANNEL_MESSAGE_WITH_SOURCE = 4,
@@ -230,7 +168,15 @@ export const enum InteractionTypes {
230
168
 
231
169
  export const enum InviteTargetType {
232
170
  STREAM = 1,
233
- EMBEDDED_APPLICATION = 2,
171
+ EMBEDDED_APPLICATION,
172
+ ROLE_SUBSCRIPTIONS,
173
+ CREATOR_PAGE,
174
+ }
175
+
176
+ export const enum InviteType {
177
+ GUILD,
178
+ GROUP_DM,
179
+ FRIEND,
234
180
  }
235
181
 
236
182
  export const enum MembershipStates {
@@ -249,8 +195,6 @@ export const enum MessageButtonStyles {
249
195
  export const enum MessageComponentTypes {
250
196
  ACTION_ROW = 1,
251
197
  BUTTON = 2,
252
- /** @deprecated Use `STRING_SELECT` instead */
253
- SELECT_MENU = 3,
254
198
  STRING_SELECT = 3,
255
199
  TEXT_INPUT = 4,
256
200
  USER_SELECT = 5,
@@ -260,8 +204,6 @@ export const enum MessageComponentTypes {
260
204
  }
261
205
 
262
206
  export const enum SelectMenuComponentTypes {
263
- /** @deprecated Use `STRING_SELECT` instead */
264
- SELECT_MENU = 3,
265
207
  STRING_SELECT = 3,
266
208
  USER_SELECT = 5,
267
209
  ROLE_SELECT = 6,
@@ -344,3 +286,12 @@ export enum ApplicationRoleConnectionMetadataTypes {
344
286
  BOOLEAN_EQUAL,
345
287
  BOOLEAN_NOT_EQUAL,
346
288
  }
289
+
290
+ export const enum RelationshipType {
291
+ NONE = 0,
292
+ FRIEND = 1,
293
+ BLOCKED = 2,
294
+ PENDING_INCOMING = 3,
295
+ PENDING_OUTGOING = 4,
296
+ IMPLICIT = 5,
297
+ }