@velliajs/discord 1.0.2 → 1.0.4

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 (258) hide show
  1. package/README.md +4 -11
  2. package/package.json +3 -3
  3. package/src/client/BaseClient.js +7 -28
  4. package/src/client/Client.js +116 -283
  5. package/src/client/WebhookClient.js +17 -59
  6. package/src/client/actions/Action.js +0 -10
  7. package/src/client/actions/ActionsManager.js +3 -3
  8. package/src/client/actions/ApplicationCommandPermissionsUpdate.js +2 -15
  9. package/src/client/actions/AutoModerationActionExecution.js +1 -6
  10. package/src/client/actions/AutoModerationRuleCreate.js +1 -6
  11. package/src/client/actions/AutoModerationRuleDelete.js +1 -6
  12. package/src/client/actions/AutoModerationRuleUpdate.js +1 -7
  13. package/src/client/actions/ChannelCreate.js +1 -5
  14. package/src/client/actions/ChannelDelete.js +1 -5
  15. package/src/client/actions/GuildAuditLogEntryCreate.js +1 -6
  16. package/src/client/actions/GuildBanAdd.js +1 -5
  17. package/src/client/actions/GuildBanRemove.js +1 -5
  18. package/src/client/actions/GuildDelete.js +6 -14
  19. package/src/client/actions/GuildEmojiCreate.js +1 -5
  20. package/src/client/actions/GuildEmojiDelete.js +1 -5
  21. package/src/client/actions/GuildEmojiUpdate.js +1 -6
  22. package/src/client/actions/GuildEmojisUpdate.js +4 -4
  23. package/src/client/actions/GuildIntegrationsUpdate.js +1 -5
  24. package/src/client/actions/GuildMemberRemove.js +1 -5
  25. package/src/client/actions/GuildMemberUpdate.js +2 -11
  26. package/src/client/actions/GuildRoleCreate.js +1 -5
  27. package/src/client/actions/GuildRoleDelete.js +1 -5
  28. package/src/client/actions/GuildRoleUpdate.js +1 -6
  29. package/src/client/actions/GuildScheduledEventCreate.js +1 -5
  30. package/src/client/actions/GuildScheduledEventDelete.js +1 -5
  31. package/src/client/actions/GuildScheduledEventUpdate.js +1 -6
  32. package/src/client/actions/GuildScheduledEventUserAdd.js +1 -6
  33. package/src/client/actions/GuildScheduledEventUserRemove.js +1 -6
  34. package/src/client/actions/GuildStickerCreate.js +1 -5
  35. package/src/client/actions/GuildStickerDelete.js +1 -5
  36. package/src/client/actions/GuildStickerUpdate.js +1 -6
  37. package/src/client/actions/GuildStickersUpdate.js +4 -4
  38. package/src/client/actions/GuildUpdate.js +1 -6
  39. package/src/client/actions/InteractionCreate.js +3 -7
  40. package/src/client/actions/InviteCreate.js +1 -7
  41. package/src/client/actions/InviteDelete.js +1 -7
  42. package/src/client/actions/MessageCreate.js +1 -5
  43. package/src/client/actions/MessageDelete.js +1 -5
  44. package/src/client/actions/MessageDeleteBulk.js +1 -6
  45. package/src/client/actions/MessageReactionAdd.js +5 -18
  46. package/src/client/actions/MessageReactionRemove.js +5 -16
  47. package/src/client/actions/MessageReactionRemoveAll.js +4 -9
  48. package/src/client/actions/MessageReactionRemoveEmoji.js +1 -5
  49. package/src/client/actions/PresenceUpdate.js +1 -6
  50. package/src/client/actions/StageInstanceCreate.js +1 -5
  51. package/src/client/actions/StageInstanceDelete.js +1 -5
  52. package/src/client/actions/StageInstanceUpdate.js +1 -6
  53. package/src/client/actions/ThreadCreate.js +1 -6
  54. package/src/client/actions/ThreadDelete.js +1 -5
  55. package/src/client/actions/ThreadListSync.js +2 -7
  56. package/src/client/actions/ThreadMemberUpdate.js +2 -7
  57. package/src/client/actions/ThreadMembersUpdate.js +2 -9
  58. package/src/client/actions/TypingStart.js +1 -5
  59. package/src/client/actions/UserUpdate.js +1 -8
  60. package/src/client/actions/VoiceStateUpdate.js +4 -9
  61. package/src/client/actions/WebhooksUpdate.js +1 -6
  62. package/src/client/voice/ClientVoiceManager.js +3 -13
  63. package/src/client/websocket/WebSocketManager.js +25 -117
  64. package/src/client/websocket/WebSocketShard.js +29 -116
  65. package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +2 -8
  66. package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -6
  67. package/src/client/websocket/handlers/GUILD_CREATE.js +3 -7
  68. package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +2 -16
  69. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -5
  70. package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -6
  71. package/src/client/websocket/handlers/RESUMED.js +1 -6
  72. package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -6
  73. package/src/errors/DJSError.js +3 -14
  74. package/src/errors/ErrorCodes.js +2 -164
  75. package/src/index.js +6 -6
  76. package/src/managers/ApplicationCommandManager.js +14 -130
  77. package/src/managers/ApplicationCommandPermissionsManager.js +31 -202
  78. package/src/managers/AutoModerationRuleManager.js +17 -145
  79. package/src/managers/BaseGuildEmojiManager.js +7 -38
  80. package/src/managers/BaseManager.js +2 -10
  81. package/src/managers/CachedManager.js +3 -17
  82. package/src/managers/CategoryChannelChildManager.js +6 -48
  83. package/src/managers/ChannelManager.js +11 -52
  84. package/src/managers/DataManager.js +5 -27
  85. package/src/managers/GuildApplicationCommandManager.js +3 -12
  86. package/src/managers/GuildBanManager.js +16 -105
  87. package/src/managers/GuildChannelManager.js +31 -226
  88. package/src/managers/GuildEmojiManager.js +9 -65
  89. package/src/managers/GuildEmojiRoleManager.js +8 -47
  90. package/src/managers/GuildForumThreadManager.js +5 -39
  91. package/src/managers/GuildInviteManager.js +18 -117
  92. package/src/managers/GuildManager.js +14 -115
  93. package/src/managers/GuildMemberManager.js +38 -256
  94. package/src/managers/GuildMemberRoleManager.js +13 -76
  95. package/src/managers/GuildScheduledEventManager.js +25 -128
  96. package/src/managers/GuildStickerManager.js +16 -96
  97. package/src/managers/GuildTextThreadManager.js +4 -47
  98. package/src/managers/MessageManager.js +23 -137
  99. package/src/managers/PermissionOverwriteManager.js +10 -78
  100. package/src/managers/PresenceManager.js +6 -27
  101. package/src/managers/ReactionManager.js +7 -40
  102. package/src/managers/ReactionUserManager.js +6 -29
  103. package/src/managers/RoleManager.js +29 -177
  104. package/src/managers/StageInstanceManager.js +14 -77
  105. package/src/managers/ThreadManager.js +23 -113
  106. package/src/managers/ThreadMemberManager.js +20 -89
  107. package/src/managers/UserManager.js +13 -65
  108. package/src/managers/VoiceStateManager.js +3 -13
  109. package/src/sharding/Shard.js +42 -158
  110. package/src/sharding/ShardClientUtil.js +17 -101
  111. package/src/sharding/ShardingManager.js +34 -151
  112. package/src/structures/ActionRow.js +4 -21
  113. package/src/structures/ActionRowBuilder.js +3 -13
  114. package/src/structures/AnonymousGuild.js +10 -43
  115. package/src/structures/ApplicationCommand.js +54 -308
  116. package/src/structures/ApplicationRoleConnectionMetadata.js +7 -27
  117. package/src/structures/Attachment.js +16 -65
  118. package/src/structures/AttachmentBuilder.js +13 -58
  119. package/src/structures/AutoModerationActionExecution.js +16 -69
  120. package/src/structures/AutoModerationRule.js +32 -164
  121. package/src/structures/AutocompleteInteraction.js +10 -52
  122. package/src/structures/Base.js +2 -10
  123. package/src/structures/BaseChannel.js +16 -80
  124. package/src/structures/BaseGuild.js +13 -59
  125. package/src/structures/BaseGuildEmoji.js +5 -21
  126. package/src/structures/BaseGuildTextChannel.js +19 -100
  127. package/src/structures/BaseGuildVoiceChannel.js +21 -110
  128. package/src/structures/BaseInteraction.js +40 -196
  129. package/src/structures/BaseSelectMenuComponent.js +6 -29
  130. package/src/structures/ButtonBuilder.js +4 -18
  131. package/src/structures/ButtonComponent.js +7 -34
  132. package/src/structures/ButtonInteraction.js +1 -4
  133. package/src/structures/CategoryChannel.js +5 -30
  134. package/src/structures/ChannelSelectMenuBuilder.js +3 -13
  135. package/src/structures/ChannelSelectMenuComponent.js +2 -9
  136. package/src/structures/ChannelSelectMenuInteraction.js +3 -12
  137. package/src/structures/ChatInputCommandInteraction.js +3 -13
  138. package/src/structures/ClientApplication.js +20 -83
  139. package/src/structures/ClientPresence.js +5 -20
  140. package/src/structures/ClientUser.js +21 -118
  141. package/src/structures/CommandInteraction.js +21 -96
  142. package/src/structures/CommandInteractionOptionResolver.js +26 -147
  143. package/src/structures/Component.js +5 -21
  144. package/src/structures/ContextMenuCommandInteraction.js +4 -18
  145. package/src/structures/DMChannel.js +17 -52
  146. package/src/structures/DirectoryChannel.js +4 -16
  147. package/src/structures/Embed.js +21 -107
  148. package/src/structures/EmbedBuilder.js +4 -18
  149. package/src/structures/Emoji.js +12 -60
  150. package/src/structures/ForumChannel.js +30 -140
  151. package/src/structures/Guild.js +117 -697
  152. package/src/structures/GuildAuditLogs.js +7 -32
  153. package/src/structures/GuildAuditLogsEntry.js +27 -135
  154. package/src/structures/GuildBan.js +6 -26
  155. package/src/structures/GuildChannel.js +36 -188
  156. package/src/structures/GuildEmoji.js +13 -67
  157. package/src/structures/GuildMember.js +47 -270
  158. package/src/structures/GuildPreview.js +19 -84
  159. package/src/structures/GuildPreviewEmoji.js +3 -13
  160. package/src/structures/GuildScheduledEvent.js +46 -250
  161. package/src/structures/GuildTemplate.js +24 -108
  162. package/src/structures/Integration.js +25 -103
  163. package/src/structures/IntegrationApplication.js +8 -32
  164. package/src/structures/InteractionCollector.js +22 -113
  165. package/src/structures/InteractionResponse.js +11 -46
  166. package/src/structures/InteractionWebhook.js +8 -33
  167. package/src/structures/Invite.js +27 -131
  168. package/src/structures/InviteGuild.js +2 -8
  169. package/src/structures/InviteStageInstance.js +9 -39
  170. package/src/structures/MentionableSelectMenuBuilder.js +3 -14
  171. package/src/structures/MentionableSelectMenuComponent.js +1 -4
  172. package/src/structures/MentionableSelectMenuInteraction.js +5 -20
  173. package/src/structures/Message.js +85 -460
  174. package/src/structures/MessageCollector.js +14 -70
  175. package/src/structures/MessageComponentInteraction.js +14 -57
  176. package/src/structures/MessageContextMenuCommandInteraction.js +2 -9
  177. package/src/structures/MessageMentions.js +25 -136
  178. package/src/structures/MessagePayload.js +24 -94
  179. package/src/structures/MessageReaction.js +13 -51
  180. package/src/structures/ModalBuilder.js +3 -13
  181. package/src/structures/ModalSubmitFields.js +5 -22
  182. package/src/structures/ModalSubmitInteraction.js +17 -61
  183. package/src/structures/NewsChannel.js +2 -16
  184. package/src/structures/OAuth2Guild.js +3 -12
  185. package/src/structures/PartialGroupDMChannel.js +7 -27
  186. package/src/structures/PermissionOverwrites.js +20 -99
  187. package/src/structures/Presence.js +45 -190
  188. package/src/structures/ReactionCollector.js +20 -108
  189. package/src/structures/ReactionEmoji.js +2 -10
  190. package/src/structures/Role.js +39 -261
  191. package/src/structures/RoleSelectMenuBuilder.js +3 -13
  192. package/src/structures/RoleSelectMenuComponent.js +1 -4
  193. package/src/structures/RoleSelectMenuInteraction.js +3 -12
  194. package/src/structures/SelectMenuBuilder.js +1 -4
  195. package/src/structures/SelectMenuComponent.js +1 -4
  196. package/src/structures/SelectMenuInteraction.js +1 -4
  197. package/src/structures/SelectMenuOptionBuilder.js +1 -4
  198. package/src/structures/StageChannel.js +12 -84
  199. package/src/structures/StageInstance.js +16 -87
  200. package/src/structures/Sticker.js +25 -124
  201. package/src/structures/StickerPack.js +12 -52
  202. package/src/structures/StringSelectMenuBuilder.js +6 -29
  203. package/src/structures/StringSelectMenuComponent.js +2 -9
  204. package/src/structures/StringSelectMenuInteraction.js +2 -8
  205. package/src/structures/StringSelectMenuOptionBuilder.js +4 -18
  206. package/src/structures/Team.js +11 -52
  207. package/src/structures/TeamMember.js +7 -33
  208. package/src/structures/TextChannel.js +3 -14
  209. package/src/structures/TextInputBuilder.js +3 -13
  210. package/src/structures/TextInputComponent.js +3 -14
  211. package/src/structures/ThreadChannel.js +59 -305
  212. package/src/structures/ThreadMember.js +12 -55
  213. package/src/structures/Typing.js +8 -35
  214. package/src/structures/User.js +29 -151
  215. package/src/structures/UserContextMenuCommandInteraction.js +3 -14
  216. package/src/structures/UserSelectMenuBuilder.js +3 -13
  217. package/src/structures/UserSelectMenuComponent.js +1 -4
  218. package/src/structures/UserSelectMenuInteraction.js +4 -16
  219. package/src/structures/VoiceChannel.js +8 -67
  220. package/src/structures/VoiceRegion.js +6 -23
  221. package/src/structures/VoiceState.js +28 -140
  222. package/src/structures/Webhook.js +37 -227
  223. package/src/structures/WelcomeChannel.js +7 -29
  224. package/src/structures/WelcomeScreen.js +5 -20
  225. package/src/structures/Widget.js +9 -40
  226. package/src/structures/WidgetMember.js +15 -61
  227. package/src/structures/interfaces/Application.js +10 -49
  228. package/src/structures/interfaces/Collector.js +34 -155
  229. package/src/structures/interfaces/InteractionResponses.js +25 -164
  230. package/src/structures/interfaces/TextBasedChannel.js +37 -232
  231. package/src/util/APITypes.js +183 -456
  232. package/src/util/ActivityFlagsBitField.js +3 -15
  233. package/src/util/ApplicationFlagsBitField.js +3 -15
  234. package/src/util/BitField.js +17 -82
  235. package/src/util/ChannelFlagsBitField.js +7 -30
  236. package/src/util/Channels.js +5 -35
  237. package/src/util/Colors.js +3 -38
  238. package/src/util/Components.js +21 -75
  239. package/src/util/Constants.js +17 -144
  240. package/src/util/DataResolver.js +20 -77
  241. package/src/util/Events.js +3 -81
  242. package/src/util/Formatters.js +58 -305
  243. package/src/util/GuildMemberFlagsBitField.js +7 -30
  244. package/src/util/IntentsBitField.js +4 -23
  245. package/src/util/LimitedCollection.js +4 -21
  246. package/src/util/MessageFlagsBitField.js +5 -21
  247. package/src/util/Options.js +24 -137
  248. package/src/util/Partials.js +3 -30
  249. package/src/util/PermissionsBitField.js +12 -67
  250. package/src/util/ShardEvents.js +3 -15
  251. package/src/util/Status.js +3 -17
  252. package/src/util/Sweepers.js +35 -184
  253. package/src/util/SystemChannelFlagsBitField.js +7 -32
  254. package/src/util/ThreadMemberFlagsBitField.js +5 -21
  255. package/src/util/Transformers.js +2 -11
  256. package/src/util/UserFlagsBitField.js +5 -21
  257. package/src/util/Util.js +30 -169
  258. package/src/util/WebSocketShardEvents.js +3 -14
@@ -19,10 +19,10 @@ class InteractionCreateAction extends Action {
19
19
  handle(data) {
20
20
  const client = this.client;
21
21
 
22
- // Resolve and cache partial channels for Interaction#channel getter
22
+
23
23
  const channel = data.channel && this.getChannel(data.channel);
24
24
 
25
- // Do not emit this for interactions that cache messages that are non-text-based.
25
+
26
26
  let InteractionClass;
27
27
 
28
28
  switch (data.type) {
@@ -89,11 +89,7 @@ class InteractionCreateAction extends Action {
89
89
 
90
90
  const interaction = new InteractionClass(client, data);
91
91
 
92
- /**
93
- * Emitted when an interaction is created.
94
- * @event Client#interactionCreate
95
- * @param {BaseInteraction} interaction The interaction which was created
96
- */
92
+
97
93
  client.emit(Events.InteractionCreate, interaction);
98
94
  }
99
95
  }
@@ -13,13 +13,7 @@ class InviteCreateAction extends Action {
13
13
  const inviteData = Object.assign(data, { channel, guild });
14
14
  const invite = guild.invites._add(inviteData);
15
15
 
16
- /**
17
- * Emitted when an invite is created.
18
- * <info>This event requires either the {@link PermissionFlagsBits.ManageGuild} permission or the
19
- * {@link PermissionFlagsBits.ManageChannels} permission for the channel.</info>
20
- * @event Client#inviteCreate
21
- * @param {Invite} invite The invite that was created
22
- */
16
+
23
17
  client.emit(Events.InviteCreate, invite);
24
18
  return { invite };
25
19
  }
@@ -15,13 +15,7 @@ class InviteDeleteAction extends Action {
15
15
  const invite = new Invite(client, inviteData);
16
16
  guild.invites.cache.delete(invite.code);
17
17
 
18
- /**
19
- * Emitted when an invite is deleted.
20
- * <info>This event requires either the {@link PermissionFlagsBits.ManageGuild} permission or the
21
- * {@link PermissionFlagsBits.ManageChannels} permission for the channel.</info>
22
- * @event Client#inviteDelete
23
- * @param {Invite} invite The invite that was deleted
24
- */
18
+
25
19
  client.emit(Events.InviteDelete, invite);
26
20
  return { invite };
27
21
  }
@@ -20,11 +20,7 @@ class MessageCreateAction extends Action {
20
20
  const message = channel.messages._add(data);
21
21
  channel.lastMessageId = data.id;
22
22
 
23
- /**
24
- * Emitted whenever a message is created.
25
- * @event Client#messageCreate
26
- * @param {Message} message The created message
27
- */
23
+
28
24
  client.emit(Events.MessageCreate, message);
29
25
 
30
26
  return { message };
@@ -16,11 +16,7 @@ class MessageDeleteAction extends Action {
16
16
  message = this.getMessage(data, channel);
17
17
  if (message) {
18
18
  channel.messages.cache.delete(message.id);
19
- /**
20
- * Emitted whenever a message is deleted.
21
- * @event Client#messageDelete
22
- * @param {Message} message The deleted message
23
- */
19
+
24
20
  client.emit(Events.MessageDelete, message);
25
21
  }
26
22
  }
@@ -31,12 +31,7 @@ class MessageDeleteBulkAction extends Action {
31
31
  }
32
32
  }
33
33
 
34
- /**
35
- * Emitted whenever messages are deleted in bulk.
36
- * @event Client#messageDeleteBulk
37
- * @param {Collection<Snowflake, Message>} messages The deleted messages, mapped by their id
38
- * @param {GuildTextBasedChannel} channel The channel that the messages were deleted in
39
- */
34
+
40
35
  if (messages.size > 0) client.emit(Events.MessageBulkDelete, messages, channel);
41
36
  return { messages };
42
37
  }
@@ -4,15 +4,7 @@ const Action = require('./Action');
4
4
  const Events = require('../../util/Events');
5
5
  const Partials = require('../../util/Partials');
6
6
 
7
- /*
8
- { user_id: 'id',
9
- message_id: 'id',
10
- emoji: { name: '�', id: null },
11
- channel_id: 'id',
12
- // If originating from a guild
13
- guild_id: 'id',
14
- member: { ..., user: { ... } } }
15
- */
7
+
16
8
 
17
9
  class MessageReactionAdd extends Action {
18
10
  handle(data, fromStructure = false) {
@@ -21,15 +13,15 @@ class MessageReactionAdd extends Action {
21
13
  const user = this.getUserFromMember(data);
22
14
  if (!user) return false;
23
15
 
24
- // Verify channel
16
+
25
17
  const channel = this.getChannel(data);
26
18
  if (!channel?.isTextBased()) return false;
27
19
 
28
- // Verify message
20
+
29
21
  const message = this.getMessage(data, channel);
30
22
  if (!message) return false;
31
23
 
32
- // Verify reaction
24
+
33
25
  const includePartial = this.client.options.partials.includes(Partials.Reaction);
34
26
  if (message.partial && !includePartial) return false;
35
27
  const reaction = message.reactions._add({
@@ -40,12 +32,7 @@ class MessageReactionAdd extends Action {
40
32
  if (!reaction) return false;
41
33
  reaction._add(user);
42
34
  if (fromStructure) return { message, reaction, user };
43
- /**
44
- * Emitted whenever a reaction is added to a cached message.
45
- * @event Client#messageReactionAdd
46
- * @param {MessageReaction} messageReaction The reaction object
47
- * @param {User} user The user that applied the guild or reaction emoji
48
- */
35
+
49
36
  this.client.emit(Events.MessageReactionAdd, reaction, user);
50
37
 
51
38
  return { message, reaction, user };
@@ -3,13 +3,7 @@
3
3
  const Action = require('./Action');
4
4
  const Events = require('../../util/Events');
5
5
 
6
- /*
7
- { user_id: 'id',
8
- message_id: 'id',
9
- emoji: { name: '�', id: null },
10
- channel_id: 'id',
11
- guild_id: 'id' }
12
- */
6
+
13
7
 
14
8
  class MessageReactionRemove extends Action {
15
9
  handle(data) {
@@ -18,24 +12,19 @@ class MessageReactionRemove extends Action {
18
12
  const user = this.getUser(data);
19
13
  if (!user) return false;
20
14
 
21
- // Verify channel
15
+
22
16
  const channel = this.getChannel(data);
23
17
  if (!channel?.isTextBased()) return false;
24
18
 
25
- // Verify message
19
+
26
20
  const message = this.getMessage(data, channel);
27
21
  if (!message) return false;
28
22
 
29
- // Verify reaction
23
+
30
24
  const reaction = this.getReaction(data, message, user);
31
25
  if (!reaction) return false;
32
26
  reaction._remove(user);
33
- /**
34
- * Emitted whenever a reaction is removed from a cached message.
35
- * @event Client#messageReactionRemove
36
- * @param {MessageReaction} messageReaction The reaction object
37
- * @param {User} user The user whose emoji or reaction emoji was removed
38
- */
27
+
39
28
  this.client.emit(Events.MessageReactionRemove, reaction, user);
40
29
 
41
30
  return { message, reaction, user };
@@ -5,15 +5,15 @@ const Events = require('../../util/Events');
5
5
 
6
6
  class MessageReactionRemoveAll extends Action {
7
7
  handle(data) {
8
- // Verify channel
8
+
9
9
  const channel = this.getChannel(data);
10
10
  if (!channel?.isTextBased()) return false;
11
11
 
12
- // Verify message
12
+
13
13
  const message = this.getMessage(data, channel);
14
14
  if (!message) return false;
15
15
 
16
- // Copy removed reactions to emit for the event.
16
+
17
17
  const removed = message.reactions.cache.clone();
18
18
 
19
19
  message.reactions.cache.clear();
@@ -23,11 +23,6 @@ class MessageReactionRemoveAll extends Action {
23
23
  }
24
24
  }
25
25
 
26
- /**
27
- * Emitted whenever all reactions are removed from a cached message.
28
- * @event Client#messageReactionRemoveAll
29
- * @param {Message} message The message the reactions were removed from
30
- * @param {Collection<string|Snowflake, MessageReaction>} reactions The cached message reactions that were removed.
31
- */
26
+
32
27
 
33
28
  module.exports = MessageReactionRemoveAll;
@@ -15,11 +15,7 @@ class MessageReactionRemoveEmoji extends Action {
15
15
  if (!reaction) return false;
16
16
  if (!message.partial) message.reactions.cache.delete(reaction.emoji.id ?? reaction.emoji.name);
17
17
 
18
- /**
19
- * Emitted when a bot removes an emoji reaction from a cached message.
20
- * @event Client#messageReactionRemoveEmoji
21
- * @param {MessageReaction} reaction The reaction that was removed
22
- */
18
+
23
19
  this.client.emit(Events.MessageReactionRemoveEmoji, reaction);
24
20
  return { reaction };
25
21
  }
@@ -28,12 +28,7 @@ class PresenceUpdateAction extends Action {
28
28
  }
29
29
  const newPresence = guild.presences._add(Object.assign(data, { guild }));
30
30
  if (this.client.listenerCount(Events.PresenceUpdate) && !newPresence.equals(oldPresence)) {
31
- /**
32
- * Emitted whenever a guild member's presence (e.g. status, activity) is changed.
33
- * @event Client#presenceUpdate
34
- * @param {?Presence} oldPresence The presence before the update, if one at all
35
- * @param {Presence} newPresence The presence after the update
36
- */
31
+
37
32
  this.client.emit(Events.PresenceUpdate, oldPresence, newPresence);
38
33
  }
39
34
  }
@@ -11,11 +11,7 @@ class StageInstanceCreateAction extends Action {
11
11
  if (channel) {
12
12
  const stageInstance = channel.guild.stageInstances._add(data);
13
13
 
14
- /**
15
- * Emitted whenever a stage instance is created.
16
- * @event Client#stageInstanceCreate
17
- * @param {StageInstance} stageInstance The created stage instance
18
- */
14
+
19
15
  client.emit(Events.StageInstanceCreate, stageInstance);
20
16
 
21
17
  return { stageInstance };
@@ -13,11 +13,7 @@ class StageInstanceDeleteAction extends Action {
13
13
  if (stageInstance) {
14
14
  channel.guild.stageInstances.cache.delete(stageInstance.id);
15
15
 
16
- /**
17
- * Emitted whenever a stage instance is deleted.
18
- * @event Client#stageInstanceDelete
19
- * @param {StageInstance} stageInstance The deleted stage instance
20
- */
16
+
21
17
  client.emit(Events.StageInstanceDelete, stageInstance);
22
18
 
23
19
  return { stageInstance };
@@ -12,12 +12,7 @@ class StageInstanceUpdateAction extends Action {
12
12
  const oldStageInstance = channel.guild.stageInstances.cache.get(data.id)?._clone() ?? null;
13
13
  const newStageInstance = channel.guild.stageInstances._add(data);
14
14
 
15
- /**
16
- * Emitted whenever a stage instance gets updated - e.g. change in topic or privacy level
17
- * @event Client#stageInstanceUpdate
18
- * @param {?StageInstance} oldStageInstance The stage instance before the update
19
- * @param {StageInstance} newStageInstance The stage instance after the update
20
- */
15
+
21
16
  client.emit(Events.StageInstanceUpdate, oldStageInstance, newStageInstance);
22
17
 
23
18
  return { oldStageInstance, newStageInstance };
@@ -9,12 +9,7 @@ class ThreadCreateAction extends Action {
9
9
  const existing = client.channels.cache.has(data.id);
10
10
  const thread = client.channels._add(data);
11
11
  if (!existing && thread) {
12
- /**
13
- * Emitted whenever a thread is created or when the client user is added to a thread.
14
- * @event Client#threadCreate
15
- * @param {ThreadChannel} thread The thread that was created
16
- * @param {boolean} newlyCreated Whether the thread was newly created
17
- */
12
+
18
13
  client.emit(Events.ThreadCreate, thread, data.newly_created ?? false);
19
14
  }
20
15
  return { thread };
@@ -11,11 +11,7 @@ class ThreadDeleteAction extends Action {
11
11
  if (thread) {
12
12
  client.channels._remove(thread.id);
13
13
 
14
- /**
15
- * Emitted whenever a thread is deleted.
16
- * @event Client#threadDelete
17
- * @param {ThreadChannel} thread The thread that was deleted
18
- */
14
+
19
15
  client.emit(Events.ThreadDelete, thread);
20
16
  }
21
17
 
@@ -28,19 +28,14 @@ class ThreadListSyncAction extends Action {
28
28
  }, new Collection());
29
29
 
30
30
  for (const rawMember of Object.values(data.members)) {
31
- // Discord sends the thread id as id in this object
31
+
32
32
  const thread = client.channels.cache.get(rawMember.id);
33
33
  if (thread) {
34
34
  thread.members._add(rawMember);
35
35
  }
36
36
  }
37
37
 
38
- /**
39
- * Emitted whenever the client user gains access to a text or news channel that contains threads
40
- * @event Client#threadListSync
41
- * @param {Collection<Snowflake, ThreadChannel>} threads The threads that were synced
42
- * @param {Guild} guild The guild that the threads were synced in
43
- */
38
+
44
39
  client.emit(Events.ThreadListSync, syncedThreads, guild);
45
40
 
46
41
  return {
@@ -6,7 +6,7 @@ const Events = require('../../util/Events');
6
6
  class ThreadMemberUpdateAction extends Action {
7
7
  handle(data) {
8
8
  const client = this.client;
9
- // Discord sends the thread id as id in this object
9
+
10
10
  const thread = client.channels.cache.get(data.id);
11
11
  if (thread) {
12
12
  const member = thread.members.cache.get(data.user_id);
@@ -15,12 +15,7 @@ class ThreadMemberUpdateAction extends Action {
15
15
  return { newMember };
16
16
  }
17
17
  const old = member._update(data);
18
- /**
19
- * Emitted whenever the client user's thread member is updated.
20
- * @event Client#threadMemberUpdate
21
- * @param {ThreadMember} oldMember The member before the update
22
- * @param {ThreadMember} newMember The member after the update
23
- */
18
+
24
19
  client.emit(Events.ThreadMemberUpdate, old, member);
25
20
  }
26
21
  return {};
@@ -26,18 +26,11 @@ class ThreadMembersUpdateAction extends Action {
26
26
  }, removedMembers);
27
27
 
28
28
  if (addedMembers.size === 0 && removedMembers.size === 0) {
29
- // Uncached thread member(s) left.
29
+
30
30
  return {};
31
31
  }
32
32
 
33
- /**
34
- * Emitted whenever members are added or removed from a thread.
35
- * <info>This event requires the {@link GatewayIntentBits.GuildMembers} privileged gateway intent.</info>
36
- * @event Client#threadMembersUpdate
37
- * @param {Collection<Snowflake, ThreadMember>} addedMembers The members that were added
38
- * @param {Collection<Snowflake, ThreadMember>} removedMembers The members that were removed
39
- * @param {ThreadChannel} thread The thread where members got updated
40
- */
33
+
41
34
  client.emit(Events.ThreadMembersUpdate, addedMembers, removedMembers, thread);
42
35
  }
43
36
  return {};
@@ -16,11 +16,7 @@ class TypingStart extends Action {
16
16
 
17
17
  const user = this.getUserFromMember(data);
18
18
  if (user) {
19
- /**
20
- * Emitted whenever a user starts typing in a channel.
21
- * @event Client#typingStart
22
- * @param {Typing} typing The typing state
23
- */
19
+
24
20
  this.client.emit(Events.TypingStart, new Typing(channel, user, data));
25
21
  }
26
22
  }
@@ -11,14 +11,7 @@ class UserUpdateAction extends Action {
11
11
  const oldUser = newUser._update(data);
12
12
 
13
13
  if (!oldUser.equals(newUser)) {
14
- /**
15
- * Emitted whenever a user's details (e.g. username) are changed.
16
- * Triggered by the Discord gateway events {@link Events.UserUpdate},
17
- * {@link Events.GuildMemberUpdate}, and {@link Events.PresenceUpdate}.
18
- * @event Client#userUpdate
19
- * @param {User} oldUser The user before the update
20
- * @param {User} newUser The user after the update
21
- */
14
+
22
15
  client.emit(Events.UserUpdate, oldUser, newUser);
23
16
  return {
24
17
  old: oldUser,
@@ -9,13 +9,13 @@ class VoiceStateUpdate extends Action {
9
9
  const client = this.client;
10
10
  const guild = client.guilds.cache.get(data.guild_id);
11
11
  if (guild) {
12
- // Update the state
12
+
13
13
  const oldState =
14
14
  guild.voiceStates.cache.get(data.user_id)?._clone() ?? new VoiceState(guild, { user_id: data.user_id });
15
15
 
16
16
  const newState = guild.voiceStates._add(data);
17
17
 
18
- // Get the member
18
+
19
19
  let member = guild.members.cache.get(data.user_id);
20
20
  if (member && data.member) {
21
21
  member._patch(data.member);
@@ -23,18 +23,13 @@ class VoiceStateUpdate extends Action {
23
23
  member = guild.members._add(data.member);
24
24
  }
25
25
 
26
- // Emit event
26
+
27
27
  if (member?.user.id === client.user.id) {
28
28
  client.emit('debug', `[VOICE] received voice state update: ${JSON.stringify(data)}`);
29
29
  client.voice.onVoiceStateUpdate(data);
30
30
  }
31
31
 
32
- /**
33
- * Emitted whenever a member changes voice state - e.g. joins/leaves a channel, mutes/unmutes.
34
- * @event Client#voiceStateUpdate
35
- * @param {VoiceState} oldState The voice state before the update
36
- * @param {VoiceState} newState The voice state after the update
37
- */
32
+
38
33
  client.emit(Events.VoiceStateUpdate, oldState, newState);
39
34
  }
40
35
  }
@@ -7,12 +7,7 @@ class WebhooksUpdate extends Action {
7
7
  handle(data) {
8
8
  const client = this.client;
9
9
  const channel = client.channels.cache.get(data.channel_id);
10
- /**
11
- * Emitted whenever a channel has its webhooks changed.
12
- * @event Client#webhookUpdate
13
- * @param {TextChannel|NewsChannel|VoiceChannel|StageChannel|ForumChannel} channel
14
- * The channel that had a webhook update
15
- */
10
+
16
11
  if (channel) client.emit(Events.WebhooksUpdate, channel);
17
12
  }
18
13
  }
@@ -2,23 +2,13 @@
2
2
 
3
3
  const Events = require('../../util/Events');
4
4
 
5
- /**
6
- * Manages voice connections for the client
7
- */
5
+
8
6
  class ClientVoiceManager {
9
7
  constructor(client) {
10
- /**
11
- * The client that instantiated this voice manager
12
- * @type {Client}
13
- * @readonly
14
- * @name ClientVoiceManager#client
15
- */
8
+
16
9
  Object.defineProperty(this, 'client', { value: client });
17
10
 
18
- /**
19
- * Maps guild ids to voice adapters created for use with @discordjs/voice.
20
- * @type {Map<Snowflake, Object>}
21
- */
11
+
22
12
  this.adapters = new Map();
23
13
 
24
14
  client.on(Events.ShardDisconnect, (_, shardId) => {