djs-selfbot-v13 3.1.7 → 3.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +18 -45
  3. package/package.json +8 -37
  4. package/src/client/BaseClient.js +2 -3
  5. package/src/client/Client.js +187 -539
  6. package/src/client/actions/Action.js +18 -13
  7. package/src/client/actions/ActionsManager.js +7 -1
  8. package/src/client/actions/AutoModerationActionExecution.js +1 -0
  9. package/src/client/actions/AutoModerationRuleCreate.js +1 -0
  10. package/src/client/actions/AutoModerationRuleDelete.js +1 -0
  11. package/src/client/actions/AutoModerationRuleUpdate.js +1 -0
  12. package/src/client/actions/MessageCreate.js +0 -4
  13. package/src/client/actions/PresenceUpdate.js +17 -16
  14. package/src/client/websocket/WebSocketManager.js +11 -31
  15. package/src/client/websocket/WebSocketShard.js +39 -38
  16. package/src/client/websocket/handlers/CALL_CREATE.js +3 -3
  17. package/src/client/websocket/handlers/CALL_DELETE.js +2 -2
  18. package/src/client/websocket/handlers/CALL_UPDATE.js +2 -2
  19. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +16 -13
  20. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +11 -11
  21. package/src/client/websocket/handlers/GUILD_CREATE.js +7 -0
  22. package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +1 -0
  23. package/src/client/websocket/handlers/READY.js +47 -137
  24. package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +7 -5
  25. package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +6 -4
  26. package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +32 -9
  27. package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +2 -8
  28. package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +1 -1
  29. package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +78 -0
  30. package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +1 -5
  31. package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +12 -0
  32. package/src/client/websocket/handlers/index.js +15 -20
  33. package/src/errors/Messages.js +24 -69
  34. package/src/index.js +12 -43
  35. package/src/managers/ApplicationCommandManager.js +9 -12
  36. package/src/managers/ApplicationCommandPermissionsManager.js +3 -11
  37. package/src/managers/ChannelManager.js +3 -4
  38. package/src/managers/ClientUserSettingManager.js +161 -279
  39. package/src/managers/GuildBanManager.js +1 -1
  40. package/src/managers/GuildChannelManager.js +2 -0
  41. package/src/managers/GuildForumThreadManager.js +22 -28
  42. package/src/managers/GuildMemberManager.js +40 -216
  43. package/src/managers/GuildSettingManager.js +22 -15
  44. package/src/managers/MessageManager.js +42 -44
  45. package/src/managers/PermissionOverwriteManager.js +1 -1
  46. package/src/managers/ReactionUserManager.js +5 -5
  47. package/src/managers/RelationshipManager.js +81 -74
  48. package/src/managers/ThreadManager.js +12 -45
  49. package/src/managers/ThreadMemberManager.js +1 -1
  50. package/src/managers/UserManager.js +6 -10
  51. package/src/managers/UserNoteManager.js +53 -0
  52. package/src/rest/APIRequest.js +42 -20
  53. package/src/rest/DiscordAPIError.js +17 -16
  54. package/src/rest/RESTManager.js +1 -21
  55. package/src/rest/RequestHandler.js +35 -21
  56. package/src/structures/ApplicationCommand.js +19 -456
  57. package/src/structures/ApplicationRoleConnectionMetadata.js +3 -0
  58. package/src/structures/AutoModerationRule.js +5 -5
  59. package/src/structures/AutocompleteInteraction.js +1 -0
  60. package/src/structures/BaseGuildTextChannel.js +10 -12
  61. package/src/structures/BaseGuildVoiceChannel.js +16 -18
  62. package/src/structures/{Call.js → CallState.js} +17 -12
  63. package/src/structures/CategoryChannel.js +2 -0
  64. package/src/structures/Channel.js +2 -3
  65. package/src/structures/ClientPresence.js +12 -8
  66. package/src/structures/ClientUser.js +117 -336
  67. package/src/structures/ContextMenuInteraction.js +1 -1
  68. package/src/structures/DMChannel.js +29 -92
  69. package/src/structures/ForumChannel.js +0 -10
  70. package/src/structures/GroupDMChannel.js +387 -0
  71. package/src/structures/Guild.js +135 -271
  72. package/src/structures/GuildAuditLogs.js +0 -5
  73. package/src/structures/GuildChannel.js +16 -2
  74. package/src/structures/GuildMember.js +27 -145
  75. package/src/structures/Interaction.js +1 -62
  76. package/src/structures/Invite.js +35 -52
  77. package/src/structures/Message.js +228 -202
  78. package/src/structures/MessageAttachment.js +11 -0
  79. package/src/structures/MessageButton.js +1 -67
  80. package/src/structures/MessageEmbed.js +1 -1
  81. package/src/structures/MessageMentions.js +3 -2
  82. package/src/structures/MessagePayload.js +4 -46
  83. package/src/structures/MessageReaction.js +1 -1
  84. package/src/structures/MessageSelectMenu.js +1 -252
  85. package/src/structures/Modal.js +75 -180
  86. package/src/structures/Presence.js +2 -2
  87. package/src/structures/RichPresence.js +14 -34
  88. package/src/structures/Role.js +18 -2
  89. package/src/structures/SelectMenuInteraction.js +2 -151
  90. package/src/structures/Team.js +0 -49
  91. package/src/structures/TextInputComponent.js +0 -70
  92. package/src/structures/ThreadChannel.js +0 -19
  93. package/src/structures/User.js +117 -345
  94. package/src/structures/UserContextMenuInteraction.js +2 -2
  95. package/src/structures/VoiceState.js +74 -39
  96. package/src/structures/WebEmbed.js +38 -52
  97. package/src/structures/Webhook.js +17 -11
  98. package/src/structures/interfaces/Application.js +146 -23
  99. package/src/structures/interfaces/TextBasedChannel.js +411 -256
  100. package/src/util/ApplicationFlags.js +1 -1
  101. package/src/util/AttachmentFlags.js +38 -0
  102. package/src/util/Constants.js +106 -284
  103. package/src/util/Formatters.js +16 -2
  104. package/src/util/InviteFlags.js +29 -0
  105. package/src/util/LimitedCollection.js +1 -1
  106. package/src/util/Options.js +48 -68
  107. package/src/util/Permissions.js +5 -0
  108. package/src/util/PurchasedFlags.js +2 -0
  109. package/src/util/RemoteAuth.js +221 -356
  110. package/src/util/RoleFlags.js +37 -0
  111. package/src/util/Sweepers.js +1 -1
  112. package/src/util/Util.js +76 -36
  113. package/typings/enums.d.ts +18 -73
  114. package/typings/index.d.ts +873 -1225
  115. package/typings/rawDataTypes.d.ts +68 -9
  116. package/src/client/actions/InteractionCreate.js +0 -115
  117. package/src/client/websocket/handlers/APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE.js +0 -23
  118. package/src/client/websocket/handlers/GUILD_APPLICATION_COMMANDS_UPDATE.js +0 -11
  119. package/src/client/websocket/handlers/GUILD_MEMBER_LIST_UPDATE.js +0 -55
  120. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.js +0 -0
  121. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.js +0 -0
  122. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.js +0 -0
  123. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.js +0 -0
  124. package/src/client/websocket/handlers/INTERACTION_CREATE.js +0 -16
  125. package/src/client/websocket/handlers/INTERACTION_FAILURE.js +0 -18
  126. package/src/client/websocket/handlers/INTERACTION_SUCCESS.js +0 -30
  127. package/src/client/websocket/handlers/MESSAGE_ACK.js +0 -16
  128. package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.js +0 -0
  129. package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +0 -0
  130. package/src/managers/DeveloperPortalManager.js +0 -104
  131. package/src/managers/GuildApplicationCommandManager.js +0 -28
  132. package/src/managers/GuildFolderManager.js +0 -24
  133. package/src/managers/SessionManager.js +0 -57
  134. package/src/rest/CaptchaSolver.js +0 -132
  135. package/src/structures/ClientApplication.js +0 -204
  136. package/src/structures/DeveloperPortalApplication.js +0 -520
  137. package/src/structures/GuildFolder.js +0 -75
  138. package/src/structures/InteractionResponse.js +0 -114
  139. package/src/structures/PartialGroupDMChannel.js +0 -433
  140. package/src/structures/Session.js +0 -81
  141. package/src/util/Voice.js +0 -1456
  142. package/src/util/arRPC/index.js +0 -229
  143. package/src/util/arRPC/process/detectable.json +0 -1
  144. package/src/util/arRPC/process/index.js +0 -102
  145. package/src/util/arRPC/process/native/index.js +0 -5
  146. package/src/util/arRPC/process/native/linux.js +0 -37
  147. package/src/util/arRPC/process/native/win32.js +0 -25
  148. package/src/util/arRPC/transports/ipc.js +0 -281
  149. package/src/util/arRPC/transports/websocket.js +0 -128
@@ -224,7 +224,6 @@ class GuildAuditLogs {
224
224
  this.applicationCommands.set(command.id, new ApplicationCommand(guild.client, command, guild));
225
225
  }
226
226
  }
227
-
228
227
  /**
229
228
  * Cached auto moderation rules.
230
229
  * @type {Collection<Snowflake, AutoModerationRule>}
@@ -487,7 +486,6 @@ class GuildAuditLogsEntry {
487
486
  count: Number(data.options.count),
488
487
  };
489
488
  break;
490
-
491
489
  case Actions.MESSAGE_PIN:
492
490
  case Actions.MESSAGE_UNPIN:
493
491
  this.extra = {
@@ -533,13 +531,11 @@ class GuildAuditLogsEntry {
533
531
  channel: guild.client.channels.cache.get(data.options?.channel_id) ?? { id: data.options?.channel_id },
534
532
  };
535
533
  break;
536
-
537
534
  case Actions.APPLICATION_COMMAND_PERMISSION_UPDATE:
538
535
  this.extra = {
539
536
  applicationId: data.options.application_id,
540
537
  };
541
538
  break;
542
-
543
539
  case Actions.AUTO_MODERATION_BLOCK_MESSAGE:
544
540
  case Actions.AUTO_MODERATION_FLAG_TO_CHANNEL:
545
541
  case Actions.AUTO_MODERATION_USER_COMMUNICATION_DISABLED:
@@ -549,7 +545,6 @@ class GuildAuditLogsEntry {
549
545
  channel: guild.client.channels.cache.get(data.options?.channel_id) ?? { id: data.options?.channel_id },
550
546
  };
551
547
  break;
552
-
553
548
  default:
554
549
  break;
555
550
  }
@@ -5,6 +5,7 @@ const { Error } = require('../errors');
5
5
  const PermissionOverwriteManager = require('../managers/PermissionOverwriteManager');
6
6
  const { VoiceBasedChannelTypes } = require('../util/Constants');
7
7
  const Permissions = require('../util/Permissions');
8
+ const Util = require('../util/Util');
8
9
 
9
10
  /**
10
11
  * Represents a guild channel from any of the following:
@@ -145,8 +146,21 @@ class GuildChannel extends Channel {
145
146
  * @readonly
146
147
  */
147
148
  get position() {
148
- const sorted = this.guild._sortedChannels(this);
149
- return [...sorted.values()].indexOf(sorted.get(this.id));
149
+ const selfIsCategory = this.type === 'GUILD_CATEGORY';
150
+ const types = Util.getSortableGroupTypes(this.type);
151
+
152
+ let count = 0;
153
+ for (const channel of this.guild.channels.cache.values()) {
154
+ if (!types.includes(channel.type)) continue;
155
+ if (!selfIsCategory && channel.parentId !== this.parentId) continue;
156
+ if (this.rawPosition === channel.rawPosition) {
157
+ if (BigInt(channel.id) < BigInt(this.id)) count++;
158
+ } else if (this.rawPosition > channel.rawPosition) {
159
+ count++;
160
+ }
161
+ }
162
+
163
+ return count;
150
164
  }
151
165
 
152
166
  /**
@@ -8,7 +8,6 @@ const { Error } = require('../errors');
8
8
  const GuildMemberRoleManager = require('../managers/GuildMemberRoleManager');
9
9
  const GuildMemberFlags = require('../util/GuildMemberFlags');
10
10
  const Permissions = require('../util/Permissions');
11
- const Util = require('../util/Util');
12
11
 
13
12
  /**
14
13
  * @type {WeakSet<GuildMember>}
@@ -102,7 +101,6 @@ class GuildMember extends Base {
102
101
  this.communicationDisabledUntilTimestamp =
103
102
  data.communication_disabled_until && Date.parse(data.communication_disabled_until);
104
103
  }
105
-
106
104
  if ('flags' in data) {
107
105
  /**
108
106
  * The flags of this member
@@ -114,51 +112,6 @@ class GuildMember extends Base {
114
112
  }
115
113
  }
116
114
 
117
- _ProfilePatch(data) {
118
- if ('accent_color' in data) {
119
- /**
120
- * The member's accent color
121
- * <info>The user must be force fetched for this property to be present or be updated</info>
122
- * @type {?number}
123
- */
124
- this.accentColor = data.accent_color;
125
- }
126
- if ('banner' in data) {
127
- /**
128
- * The member's banner hash
129
- * <info>The user must be force fetched for this property to be present or be updated</info>
130
- * @type {?string}
131
- */
132
- this.banner = data.banner;
133
- }
134
- if ('bio' in data) {
135
- /**
136
- * The member's biography (About me)
137
- * <info>The user must be force fetched for this property to be present or be updated</info>
138
- * @type {?string}
139
- */
140
- this.bio = data.bio;
141
- }
142
- if ('theme_colors' in data) {
143
- /**
144
- * The member's theme colors (Profile theme) [Primary, Accent]
145
- * <info>The user must be force fetched for this property to be present or be updated</info>
146
- * @type {?Array<number>}
147
- */
148
- this.themeColors = data.theme_colors;
149
- }
150
- }
151
-
152
- /**
153
- * The hexadecimal version of the user theme color, with a leading hash [Primary, Accent]
154
- * <info>The user must be force fetched for this property to be present or be updated</info>
155
- * @type {?Array<string>}
156
- * @readonly
157
- */
158
- get hexThemeColor() {
159
- return this.themeColors?.map(c => `#${c.toString(16).padStart(6, '0')}`) || null;
160
- }
161
-
162
115
  _clone() {
163
116
  const clone = super._clone();
164
117
  clone._roles = this._roles.slice();
@@ -232,21 +185,6 @@ class GuildMember extends Base {
232
185
  return this.client.rest.cdn.GuildMemberAvatar(this.guild.id, this.id, this.avatar, format, size, dynamic);
233
186
  }
234
187
 
235
- /**
236
- * A link to the user's banner.
237
- * <info>This method will throw an error if called before the user is force fetched Profile.
238
- * See {@link GuildMember#banner} for more info</info>
239
- * @param {ImageURLOptions} [options={}] Options for the Image URL
240
- * @returns {?string}
241
- */
242
- bannerURL({ format, size, dynamic } = {}) {
243
- if (typeof this.banner === 'undefined') {
244
- throw new Error('USER_BANNER_NOT_FETCHED');
245
- }
246
- if (!this.banner) return null;
247
- return this.client.rest.cdn.GuildMemberBanner(this.guild.id, this.id, this.banner, format, size, dynamic);
248
- }
249
-
250
188
  /**
251
189
  * A link to the member's guild avatar if they have one.
252
190
  * Otherwise, a link to their {@link User#displayAvatarURL} will be returned.
@@ -444,79 +382,6 @@ class GuildMember extends Base {
444
382
  return this.edit({ flags, reason });
445
383
  }
446
384
 
447
- /**
448
- * Sets the guild avatar of the logged in client.
449
- * @param {?(BufferResolvable|Base64Resolvable)} avatar The new avatar
450
- * @returns {Promise<GuildMember>}
451
- */
452
- setAvatar(avatar) {
453
- if (this.user.id !== this.client.user.id) {
454
- throw new Error('ONLY_ME');
455
- }
456
- if (this.client.user.nitroType !== 'NITRO_BOOST') {
457
- throw new Error('NITRO_BOOST_REQUIRED', 'avatar');
458
- }
459
- return this.edit({ avatar });
460
- }
461
-
462
- /**
463
- * Sets the guild banner of the logged in client.
464
- * @param {?(BufferResolvable|Base64Resolvable)} banner The new banner
465
- * @returns {Promise<GuildMember>}
466
- */
467
- setBanner(banner) {
468
- if (this.user.id !== this.client.user.id) {
469
- throw new Error('ONLY_ME');
470
- }
471
- if (this.client.user.nitroType !== 'NITRO_BOOST') {
472
- throw new Error('NITRO_BOOST_REQUIRED', 'banner');
473
- }
474
- return this.edit({ banner });
475
- }
476
-
477
- /**
478
- * Set Guild About me
479
- * @param {string | null} bio Bio to set
480
- * @returns {Promise<GuildMember>}
481
- */
482
- setAboutMe(bio = null) {
483
- if (this.user.id !== this.client.user.id) {
484
- throw new Error('ONLY_ME');
485
- }
486
- if (this.client.user.nitroType !== 'NITRO_BOOST') {
487
- throw new Error('NITRO_BOOST_REQUIRED', 'bio');
488
- }
489
- return this.edit({ bio });
490
- }
491
-
492
- /**
493
- * Change Theme color
494
- * @param {ColorResolvable} primary The primary color of the user's profile
495
- * @param {ColorResolvable} accent The accent color of the user's profile
496
- * @returns {Promise<GuildMember>}
497
- */
498
- async setThemeColors(primary, accent) {
499
- if (this.user.id !== this.client.user.id) {
500
- throw new Error('ONLY_ME');
501
- }
502
- if (!primary || !accent) throw new Error('PRIMARY_COLOR or ACCENT_COLOR are required.');
503
- // Check nitro
504
- if (this.nitroType !== 'NITRO_BOOST') {
505
- throw new Error('NITRO_BOOST_REQUIRED', 'themeColors');
506
- }
507
- primary = Util.resolveColor(primary) || this.themeColors ? this.themeColors[0] : 0;
508
- accent = Util.resolveColor(accent) || this.themeColors ? this.themeColors[1] : 0;
509
- const data_ = await this.client.api.guilds[this.guild.id].profile['@me'].patch({
510
- data: {
511
- theme_colors: [primary, accent],
512
- },
513
- });
514
- this._ProfilePatch({
515
- guild_member_profile: data_,
516
- });
517
- return this;
518
- }
519
-
520
385
  /**
521
386
  * Creates a DM channel between the client and this member.
522
387
  * @param {boolean} [force=false] Whether to skip the cache check and request the API
@@ -619,8 +484,6 @@ class GuildMember extends Base {
619
484
  this.joinedTimestamp === member.joinedTimestamp &&
620
485
  this.nickname === member.nickname &&
621
486
  this.avatar === member.avatar &&
622
- this.accentColor === member.accentColor &&
623
- this.bio === member.bio &&
624
487
  this.pending === member.pending &&
625
488
  this.communicationDisabledUntilTimestamp === member.communicationDisabledUntilTimestamp &&
626
489
  this.flags.equals(member.flags) &&
@@ -629,14 +492,6 @@ class GuildMember extends Base {
629
492
  );
630
493
  }
631
494
 
632
- /**
633
- * Get profile guildMember
634
- * @returns {Promise<User>}
635
- */
636
- getProfile() {
637
- return this.user.getProfile(this.guild.id);
638
- }
639
-
640
495
  /**
641
496
  * When concatenated with a string, this automatically returns the user's mention instead of the GuildMember object.
642
497
  * @returns {string}
@@ -659,6 +514,33 @@ class GuildMember extends Base {
659
514
  json.displayAvatarURL = this.displayAvatarURL();
660
515
  return json;
661
516
  }
517
+
518
+ /**
519
+ * Sets the guild avatar of the logged in client.
520
+ * @param {?(BufferResolvable|Base64Resolvable)} avatar The new avatar
521
+ * @returns {Promise<GuildMember>}
522
+ */
523
+ setAvatar(avatar) {
524
+ return this.edit({ avatar });
525
+ }
526
+
527
+ /**
528
+ * Sets the guild banner of the logged in client.
529
+ * @param {?(BufferResolvable|Base64Resolvable)} banner The new banner
530
+ * @returns {Promise<GuildMember>}
531
+ */
532
+ setBanner(banner) {
533
+ return this.edit({ banner });
534
+ }
535
+
536
+ /**
537
+ * Set Guild About me
538
+ * @param {string | null} bio Bio to set
539
+ * @returns {Promise<GuildMember>}
540
+ */
541
+ setAboutMe(bio = null) {
542
+ return this.edit({ bio });
543
+ }
662
544
  }
663
545
 
664
546
  /**
@@ -269,71 +269,10 @@ class Interaction extends Base {
269
269
  * Indicates whether this interaction is a {@link SelectMenuInteraction}.
270
270
  * @returns {boolean}
271
271
  */
272
- isAnySelectMenu() {
273
- return InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT && typeof this.values !== 'undefined';
274
- }
275
-
276
- /**
277
- * Indicates whether this interaction is a {@link SelectMenuInteraction} with a `STRING_SELECT` type.
278
- * @returns {boolean}
279
- * @deprecated Use {@link Interaction#isStringSelect()} instead
280
- */
281
272
  isSelectMenu() {
282
- return this.isStringSelect();
283
- }
284
-
285
- /**
286
- * Indicates whether this interaction is a {@link SelectMenuInteraction} with a `STRING_SELECT` type.
287
- * @returns {boolean}
288
- */
289
- isStringSelect() {
290
- return (
291
- InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT &&
292
- MessageComponentTypes[this.componentType] === MessageComponentTypes.STRING_SELECT
293
- );
294
- }
295
-
296
- /**
297
- * Indicates whether this interaction is a {@link SelectMenuInteraction} with a `USER_SELECT` type.
298
- * @returns {boolean}
299
- */
300
- isUserSelect() {
301
- return (
302
- InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT &&
303
- MessageComponentTypes[this.componentType] === MessageComponentTypes.USER_SELECT
304
- );
305
- }
306
-
307
- /**
308
- * Indicates whether this interaction is a {@link SelectMenuInteraction} with a `ROLE_SELECT` type.
309
- * @returns {boolean}
310
- */
311
- isRoleSelect() {
312
- return (
313
- InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT &&
314
- MessageComponentTypes[this.componentType] === MessageComponentTypes.ROLE_SELECT
315
- );
316
- }
317
-
318
- /**
319
- * Indicates whether this interaction is a {@link SelectMenuInteraction} with a `MENTIONABLE_SELECT` type.
320
- * @returns {boolean}
321
- */
322
- isMentionableSelect() {
323
- return (
324
- InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT &&
325
- MessageComponentTypes[this.componentType] === MessageComponentTypes.MENTIONABLE_SELECT
326
- );
327
- }
328
-
329
- /**
330
- * Indicates whether this interaction is a {@link SelectMenuInteraction} with a `CHANNEL_SELECT` type.
331
- * @returns {boolean}
332
- */
333
- isChannelSelect() {
334
273
  return (
335
274
  InteractionTypes[this.type] === InteractionTypes.MESSAGE_COMPONENT &&
336
- MessageComponentTypes[this.componentType] === MessageComponentTypes.CHANNEL_SELECT
275
+ MessageComponentTypes[this.componentType] === MessageComponentTypes.SELECT_MENU
337
276
  );
338
277
  }
339
278
 
@@ -1,12 +1,12 @@
1
1
  'use strict';
2
2
 
3
- const Buffer = require('node:buffer').Buffer;
4
3
  const Base = require('./Base');
5
4
  const { GuildScheduledEvent } = require('./GuildScheduledEvent');
6
5
  const IntegrationApplication = require('./IntegrationApplication');
7
6
  const InviteStageInstance = require('./InviteStageInstance');
8
7
  const { Error } = require('../errors');
9
- const { ChannelTypes, Endpoints } = require('../util/Constants');
8
+ const { Endpoints } = require('../util/Constants');
9
+ const InviteFlags = require('../util/InviteFlags');
10
10
  const Permissions = require('../util/Permissions');
11
11
 
12
12
  // TODO: Convert `inviter` and `channel` in this class to a getter.
@@ -156,6 +156,8 @@ class Invite extends Base {
156
156
  * The type of the invite target:
157
157
  * * 1: STREAM
158
158
  * * 2: EMBEDDED_APPLICATION
159
+ * * 3: ROLE_SUBSCRIPTIONS
160
+ * * 4: CREATOR_PAGE
159
161
  * @typedef {number} TargetType
160
162
  * @see {@link https://discord.com/developers/docs/resources/invite#invite-object-invite-target-types}
161
163
  */
@@ -170,19 +172,37 @@ class Invite extends Base {
170
172
  this.targetType ??= null;
171
173
  }
172
174
 
175
+ /**
176
+ * The type of the invite:
177
+ * * 0: GUILD
178
+ * * 1: GROUP_DM
179
+ * * 2: FRIEND
180
+ * @typedef {number} InviteType
181
+ * @see {@link https://docs.discord.sex/resources/invite#invite-type}
182
+ */
183
+ if ('type' in data) {
184
+ /**
185
+ * The type of invite
186
+ * @type {?InviteType}
187
+ */
188
+ this.type = data.type;
189
+ } else {
190
+ this.type ??= null;
191
+ }
192
+
173
193
  if ('channel_id' in data) {
174
194
  /**
175
195
  * The channel's id this invite is for
176
- * @type {Snowflake}
196
+ * @type {?Snowflake}
177
197
  */
178
198
  this.channelId = data.channel_id;
179
199
  this.channel = this.client.channels.cache.get(data.channel_id);
180
200
  }
181
201
 
182
- if ('channel' in data && data.channel) {
202
+ if ('channel' in data && data.channel !== null) {
183
203
  /**
184
204
  * The channel this invite is for
185
- * @type {Channel}
205
+ * @type {?Channel}
186
206
  */
187
207
  this.channel ??= this.client.channels._add(data.channel, this.guild, { cache: false });
188
208
  this.channelId ??= data.channel.id;
@@ -223,6 +243,16 @@ class Invite extends Base {
223
243
  } else {
224
244
  this.guildScheduledEvent ??= null;
225
245
  }
246
+
247
+ if ('flags' in data) {
248
+ /**
249
+ * The flags that are applied to the invite.
250
+ * @type {?Readonly<InviteFlags>}
251
+ */
252
+ this.flags = new InviteFlags(data.flags).freeze();
253
+ } else {
254
+ this.flags ??= new InviteFlags().freeze();
255
+ }
226
256
  }
227
257
 
228
258
  /**
@@ -317,53 +347,6 @@ class Invite extends Base {
317
347
  valueOf() {
318
348
  return this.code;
319
349
  }
320
-
321
- /**
322
- * Join this Guild using this invite.
323
- * @param {boolean} [autoVerify] Whether to automatically verify member
324
- * @returns {Promise<Guild>}
325
- * @example
326
- * await client.fetchInvite('code').then(async invite => {
327
- * await invite.acceptInvite();
328
- * });
329
- */
330
- async acceptInvite(autoVerify = false) {
331
- if (!this.guild) throw new Error('INVITE_NO_GUILD');
332
- if (this.client.guilds.cache.get(this.guild.id)) return this.guild;
333
- const dataHeader = {
334
- location: 'Join Guild',
335
- location_guild_id: this.guild?.id,
336
- location_channel_id: this.channelId,
337
- location_channel_type: ChannelTypes[this.channel?.type] ?? 0,
338
- };
339
- await this.client.api.invites(this.code).post({
340
- data: {
341
- session_id: this.client.session_id,
342
- },
343
- headers: {
344
- 'X-Context-Properties': Buffer.from(JSON.stringify(dataHeader), 'utf8').toString('base64'),
345
- },
346
- });
347
- const guild = this.client.guilds.cache.get(this.guild.id);
348
- /*
349
- //
350
- if (autoVerify) {
351
- console.warn('Feature is under maintenance - Invite#acceptInvite(true)');
352
- }
353
- */
354
- if (autoVerify) {
355
- const getForm = await this.client.api
356
- .guilds(this.guild.id)
357
- ['member-verification'].get({ query: { with_guild: false, invite_code: this.code } })
358
- .catch(() => {});
359
- if (!getForm) return guild;
360
- const form = Object.assign(getForm.form_fields[0], { response: true });
361
- // Respond to the form
362
- // https://discord.com/api/v9/guilds/:id/requests/@me
363
- await this.client.api.guilds(this.guild.id).requests['@me'].put({ data: { form_fields: [form] } });
364
- }
365
- return guild;
366
- }
367
350
  }
368
351
 
369
352
  /**