@velliajs/discord 1.0.3 → 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 (257) hide show
  1. package/package.json +1 -1
  2. package/src/client/BaseClient.js +7 -28
  3. package/src/client/Client.js +116 -283
  4. package/src/client/WebhookClient.js +17 -59
  5. package/src/client/actions/Action.js +0 -10
  6. package/src/client/actions/ActionsManager.js +3 -3
  7. package/src/client/actions/ApplicationCommandPermissionsUpdate.js +2 -15
  8. package/src/client/actions/AutoModerationActionExecution.js +1 -6
  9. package/src/client/actions/AutoModerationRuleCreate.js +1 -6
  10. package/src/client/actions/AutoModerationRuleDelete.js +1 -6
  11. package/src/client/actions/AutoModerationRuleUpdate.js +1 -7
  12. package/src/client/actions/ChannelCreate.js +1 -5
  13. package/src/client/actions/ChannelDelete.js +1 -5
  14. package/src/client/actions/GuildAuditLogEntryCreate.js +1 -6
  15. package/src/client/actions/GuildBanAdd.js +1 -5
  16. package/src/client/actions/GuildBanRemove.js +1 -5
  17. package/src/client/actions/GuildDelete.js +6 -14
  18. package/src/client/actions/GuildEmojiCreate.js +1 -5
  19. package/src/client/actions/GuildEmojiDelete.js +1 -5
  20. package/src/client/actions/GuildEmojiUpdate.js +1 -6
  21. package/src/client/actions/GuildEmojisUpdate.js +4 -4
  22. package/src/client/actions/GuildIntegrationsUpdate.js +1 -5
  23. package/src/client/actions/GuildMemberRemove.js +1 -5
  24. package/src/client/actions/GuildMemberUpdate.js +2 -11
  25. package/src/client/actions/GuildRoleCreate.js +1 -5
  26. package/src/client/actions/GuildRoleDelete.js +1 -5
  27. package/src/client/actions/GuildRoleUpdate.js +1 -6
  28. package/src/client/actions/GuildScheduledEventCreate.js +1 -5
  29. package/src/client/actions/GuildScheduledEventDelete.js +1 -5
  30. package/src/client/actions/GuildScheduledEventUpdate.js +1 -6
  31. package/src/client/actions/GuildScheduledEventUserAdd.js +1 -6
  32. package/src/client/actions/GuildScheduledEventUserRemove.js +1 -6
  33. package/src/client/actions/GuildStickerCreate.js +1 -5
  34. package/src/client/actions/GuildStickerDelete.js +1 -5
  35. package/src/client/actions/GuildStickerUpdate.js +1 -6
  36. package/src/client/actions/GuildStickersUpdate.js +4 -4
  37. package/src/client/actions/GuildUpdate.js +1 -6
  38. package/src/client/actions/InteractionCreate.js +3 -7
  39. package/src/client/actions/InviteCreate.js +1 -7
  40. package/src/client/actions/InviteDelete.js +1 -7
  41. package/src/client/actions/MessageCreate.js +1 -5
  42. package/src/client/actions/MessageDelete.js +1 -5
  43. package/src/client/actions/MessageDeleteBulk.js +1 -6
  44. package/src/client/actions/MessageReactionAdd.js +5 -18
  45. package/src/client/actions/MessageReactionRemove.js +5 -16
  46. package/src/client/actions/MessageReactionRemoveAll.js +4 -9
  47. package/src/client/actions/MessageReactionRemoveEmoji.js +1 -5
  48. package/src/client/actions/PresenceUpdate.js +1 -6
  49. package/src/client/actions/StageInstanceCreate.js +1 -5
  50. package/src/client/actions/StageInstanceDelete.js +1 -5
  51. package/src/client/actions/StageInstanceUpdate.js +1 -6
  52. package/src/client/actions/ThreadCreate.js +1 -6
  53. package/src/client/actions/ThreadDelete.js +1 -5
  54. package/src/client/actions/ThreadListSync.js +2 -7
  55. package/src/client/actions/ThreadMemberUpdate.js +2 -7
  56. package/src/client/actions/ThreadMembersUpdate.js +2 -9
  57. package/src/client/actions/TypingStart.js +1 -5
  58. package/src/client/actions/UserUpdate.js +1 -8
  59. package/src/client/actions/VoiceStateUpdate.js +4 -9
  60. package/src/client/actions/WebhooksUpdate.js +1 -6
  61. package/src/client/voice/ClientVoiceManager.js +3 -13
  62. package/src/client/websocket/WebSocketManager.js +25 -117
  63. package/src/client/websocket/WebSocketShard.js +29 -116
  64. package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +2 -8
  65. package/src/client/websocket/handlers/CHANNEL_UPDATE.js +1 -6
  66. package/src/client/websocket/handlers/GUILD_CREATE.js +3 -7
  67. package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +2 -16
  68. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +1 -5
  69. package/src/client/websocket/handlers/MESSAGE_UPDATE.js +1 -6
  70. package/src/client/websocket/handlers/RESUMED.js +1 -6
  71. package/src/client/websocket/handlers/THREAD_UPDATE.js +1 -6
  72. package/src/errors/DJSError.js +3 -14
  73. package/src/errors/ErrorCodes.js +2 -164
  74. package/src/index.js +6 -6
  75. package/src/managers/ApplicationCommandManager.js +14 -130
  76. package/src/managers/ApplicationCommandPermissionsManager.js +31 -202
  77. package/src/managers/AutoModerationRuleManager.js +17 -145
  78. package/src/managers/BaseGuildEmojiManager.js +7 -38
  79. package/src/managers/BaseManager.js +2 -10
  80. package/src/managers/CachedManager.js +3 -17
  81. package/src/managers/CategoryChannelChildManager.js +6 -48
  82. package/src/managers/ChannelManager.js +11 -52
  83. package/src/managers/DataManager.js +5 -27
  84. package/src/managers/GuildApplicationCommandManager.js +3 -12
  85. package/src/managers/GuildBanManager.js +16 -105
  86. package/src/managers/GuildChannelManager.js +31 -226
  87. package/src/managers/GuildEmojiManager.js +9 -65
  88. package/src/managers/GuildEmojiRoleManager.js +8 -47
  89. package/src/managers/GuildForumThreadManager.js +5 -39
  90. package/src/managers/GuildInviteManager.js +18 -117
  91. package/src/managers/GuildManager.js +14 -115
  92. package/src/managers/GuildMemberManager.js +38 -256
  93. package/src/managers/GuildMemberRoleManager.js +13 -76
  94. package/src/managers/GuildScheduledEventManager.js +25 -128
  95. package/src/managers/GuildStickerManager.js +16 -96
  96. package/src/managers/GuildTextThreadManager.js +4 -47
  97. package/src/managers/MessageManager.js +23 -137
  98. package/src/managers/PermissionOverwriteManager.js +10 -78
  99. package/src/managers/PresenceManager.js +6 -27
  100. package/src/managers/ReactionManager.js +7 -40
  101. package/src/managers/ReactionUserManager.js +6 -29
  102. package/src/managers/RoleManager.js +29 -177
  103. package/src/managers/StageInstanceManager.js +14 -77
  104. package/src/managers/ThreadManager.js +23 -113
  105. package/src/managers/ThreadMemberManager.js +20 -89
  106. package/src/managers/UserManager.js +13 -65
  107. package/src/managers/VoiceStateManager.js +3 -13
  108. package/src/sharding/Shard.js +42 -158
  109. package/src/sharding/ShardClientUtil.js +17 -101
  110. package/src/sharding/ShardingManager.js +34 -151
  111. package/src/structures/ActionRow.js +4 -21
  112. package/src/structures/ActionRowBuilder.js +3 -13
  113. package/src/structures/AnonymousGuild.js +10 -43
  114. package/src/structures/ApplicationCommand.js +54 -308
  115. package/src/structures/ApplicationRoleConnectionMetadata.js +7 -27
  116. package/src/structures/Attachment.js +16 -65
  117. package/src/structures/AttachmentBuilder.js +13 -58
  118. package/src/structures/AutoModerationActionExecution.js +16 -69
  119. package/src/structures/AutoModerationRule.js +32 -164
  120. package/src/structures/AutocompleteInteraction.js +10 -52
  121. package/src/structures/Base.js +2 -10
  122. package/src/structures/BaseChannel.js +16 -80
  123. package/src/structures/BaseGuild.js +13 -59
  124. package/src/structures/BaseGuildEmoji.js +5 -21
  125. package/src/structures/BaseGuildTextChannel.js +19 -100
  126. package/src/structures/BaseGuildVoiceChannel.js +21 -110
  127. package/src/structures/BaseInteraction.js +40 -196
  128. package/src/structures/BaseSelectMenuComponent.js +6 -29
  129. package/src/structures/ButtonBuilder.js +4 -18
  130. package/src/structures/ButtonComponent.js +7 -34
  131. package/src/structures/ButtonInteraction.js +1 -4
  132. package/src/structures/CategoryChannel.js +5 -30
  133. package/src/structures/ChannelSelectMenuBuilder.js +3 -13
  134. package/src/structures/ChannelSelectMenuComponent.js +2 -9
  135. package/src/structures/ChannelSelectMenuInteraction.js +3 -12
  136. package/src/structures/ChatInputCommandInteraction.js +3 -13
  137. package/src/structures/ClientApplication.js +20 -83
  138. package/src/structures/ClientPresence.js +5 -20
  139. package/src/structures/ClientUser.js +21 -118
  140. package/src/structures/CommandInteraction.js +21 -96
  141. package/src/structures/CommandInteractionOptionResolver.js +26 -147
  142. package/src/structures/Component.js +5 -21
  143. package/src/structures/ContextMenuCommandInteraction.js +4 -18
  144. package/src/structures/DMChannel.js +17 -52
  145. package/src/structures/DirectoryChannel.js +4 -16
  146. package/src/structures/Embed.js +21 -107
  147. package/src/structures/EmbedBuilder.js +4 -18
  148. package/src/structures/Emoji.js +12 -60
  149. package/src/structures/ForumChannel.js +30 -140
  150. package/src/structures/Guild.js +117 -697
  151. package/src/structures/GuildAuditLogs.js +7 -32
  152. package/src/structures/GuildAuditLogsEntry.js +27 -135
  153. package/src/structures/GuildBan.js +6 -26
  154. package/src/structures/GuildChannel.js +36 -188
  155. package/src/structures/GuildEmoji.js +13 -67
  156. package/src/structures/GuildMember.js +47 -270
  157. package/src/structures/GuildPreview.js +19 -84
  158. package/src/structures/GuildPreviewEmoji.js +3 -13
  159. package/src/structures/GuildScheduledEvent.js +46 -250
  160. package/src/structures/GuildTemplate.js +24 -108
  161. package/src/structures/Integration.js +25 -103
  162. package/src/structures/IntegrationApplication.js +8 -32
  163. package/src/structures/InteractionCollector.js +22 -113
  164. package/src/structures/InteractionResponse.js +11 -46
  165. package/src/structures/InteractionWebhook.js +8 -33
  166. package/src/structures/Invite.js +27 -131
  167. package/src/structures/InviteGuild.js +2 -8
  168. package/src/structures/InviteStageInstance.js +9 -39
  169. package/src/structures/MentionableSelectMenuBuilder.js +3 -14
  170. package/src/structures/MentionableSelectMenuComponent.js +1 -4
  171. package/src/structures/MentionableSelectMenuInteraction.js +5 -20
  172. package/src/structures/Message.js +85 -460
  173. package/src/structures/MessageCollector.js +14 -70
  174. package/src/structures/MessageComponentInteraction.js +14 -57
  175. package/src/structures/MessageContextMenuCommandInteraction.js +2 -9
  176. package/src/structures/MessageMentions.js +25 -136
  177. package/src/structures/MessagePayload.js +24 -94
  178. package/src/structures/MessageReaction.js +13 -51
  179. package/src/structures/ModalBuilder.js +3 -13
  180. package/src/structures/ModalSubmitFields.js +5 -22
  181. package/src/structures/ModalSubmitInteraction.js +17 -61
  182. package/src/structures/NewsChannel.js +2 -16
  183. package/src/structures/OAuth2Guild.js +3 -12
  184. package/src/structures/PartialGroupDMChannel.js +7 -27
  185. package/src/structures/PermissionOverwrites.js +20 -99
  186. package/src/structures/Presence.js +45 -190
  187. package/src/structures/ReactionCollector.js +20 -108
  188. package/src/structures/ReactionEmoji.js +2 -10
  189. package/src/structures/Role.js +39 -261
  190. package/src/structures/RoleSelectMenuBuilder.js +3 -13
  191. package/src/structures/RoleSelectMenuComponent.js +1 -4
  192. package/src/structures/RoleSelectMenuInteraction.js +3 -12
  193. package/src/structures/SelectMenuBuilder.js +1 -4
  194. package/src/structures/SelectMenuComponent.js +1 -4
  195. package/src/structures/SelectMenuInteraction.js +1 -4
  196. package/src/structures/SelectMenuOptionBuilder.js +1 -4
  197. package/src/structures/StageChannel.js +12 -84
  198. package/src/structures/StageInstance.js +16 -87
  199. package/src/structures/Sticker.js +25 -124
  200. package/src/structures/StickerPack.js +12 -52
  201. package/src/structures/StringSelectMenuBuilder.js +6 -29
  202. package/src/structures/StringSelectMenuComponent.js +2 -9
  203. package/src/structures/StringSelectMenuInteraction.js +2 -8
  204. package/src/structures/StringSelectMenuOptionBuilder.js +4 -18
  205. package/src/structures/Team.js +11 -52
  206. package/src/structures/TeamMember.js +7 -33
  207. package/src/structures/TextChannel.js +3 -14
  208. package/src/structures/TextInputBuilder.js +3 -13
  209. package/src/structures/TextInputComponent.js +3 -14
  210. package/src/structures/ThreadChannel.js +59 -305
  211. package/src/structures/ThreadMember.js +12 -55
  212. package/src/structures/Typing.js +8 -35
  213. package/src/structures/User.js +29 -151
  214. package/src/structures/UserContextMenuCommandInteraction.js +3 -14
  215. package/src/structures/UserSelectMenuBuilder.js +3 -13
  216. package/src/structures/UserSelectMenuComponent.js +1 -4
  217. package/src/structures/UserSelectMenuInteraction.js +4 -16
  218. package/src/structures/VoiceChannel.js +8 -67
  219. package/src/structures/VoiceRegion.js +6 -23
  220. package/src/structures/VoiceState.js +28 -140
  221. package/src/structures/Webhook.js +37 -227
  222. package/src/structures/WelcomeChannel.js +7 -29
  223. package/src/structures/WelcomeScreen.js +5 -20
  224. package/src/structures/Widget.js +9 -40
  225. package/src/structures/WidgetMember.js +15 -61
  226. package/src/structures/interfaces/Application.js +10 -49
  227. package/src/structures/interfaces/Collector.js +34 -155
  228. package/src/structures/interfaces/InteractionResponses.js +25 -164
  229. package/src/structures/interfaces/TextBasedChannel.js +37 -232
  230. package/src/util/APITypes.js +183 -456
  231. package/src/util/ActivityFlagsBitField.js +3 -15
  232. package/src/util/ApplicationFlagsBitField.js +3 -15
  233. package/src/util/BitField.js +17 -82
  234. package/src/util/ChannelFlagsBitField.js +7 -30
  235. package/src/util/Channels.js +5 -35
  236. package/src/util/Colors.js +3 -38
  237. package/src/util/Components.js +21 -75
  238. package/src/util/Constants.js +17 -144
  239. package/src/util/DataResolver.js +20 -77
  240. package/src/util/Events.js +3 -81
  241. package/src/util/Formatters.js +58 -305
  242. package/src/util/GuildMemberFlagsBitField.js +7 -30
  243. package/src/util/IntentsBitField.js +4 -23
  244. package/src/util/LimitedCollection.js +4 -21
  245. package/src/util/MessageFlagsBitField.js +5 -21
  246. package/src/util/Options.js +24 -137
  247. package/src/util/Partials.js +3 -30
  248. package/src/util/PermissionsBitField.js +12 -67
  249. package/src/util/ShardEvents.js +3 -15
  250. package/src/util/Status.js +3 -17
  251. package/src/util/Sweepers.js +35 -184
  252. package/src/util/SystemChannelFlagsBitField.js +7 -32
  253. package/src/util/ThreadMemberFlagsBitField.js +5 -21
  254. package/src/util/Transformers.js +2 -11
  255. package/src/util/UserFlagsBitField.js +5 -21
  256. package/src/util/Util.js +30 -169
  257. package/src/util/WebSocketShardEvents.js +3 -14
@@ -5,41 +5,17 @@ const { DiscordjsError, ErrorCodes } = require('../errors');
5
5
  const Webhook = require('../structures/Webhook');
6
6
  const { parseWebhookURL } = require('../util/Util');
7
7
 
8
- /**
9
- * The webhook client.
10
- * @implements {Webhook}
11
- * @extends {BaseClient}
12
- */
8
+
13
9
  class WebhookClient extends BaseClient {
14
- /**
15
- * Represents the credentials used for a webhook in the form of its id and token.
16
- * @typedef {Object} WebhookClientDataIdWithToken
17
- * @property {Snowflake} id The webhook's id
18
- * @property {string} token The webhook's token
19
- */
20
-
21
- /**
22
- * Represents the credentials used for a webhook in the form of a URL.
23
- * @typedef {Object} WebhookClientDataURL
24
- * @property {string} url The full URL for the webhook
25
- */
26
-
27
- /**
28
- * Represents the credentials used for a webhook.
29
- * @typedef {WebhookClientDataIdWithToken|WebhookClientDataURL} WebhookClientData
30
- */
31
-
32
- /**
33
- * Options for a webhook client.
34
- * @typedef {Object} WebhookClientOptions
35
- * @property {MessageMentionOptions} [allowedMentions] Default value for {@link BaseMessageOptions#allowedMentions}
36
- * @property {RESTOptions} [rest] Options for the REST manager
37
- */
38
-
39
- /**
40
- * @param {WebhookClientData} data The data of the webhook
41
- * @param {WebhookClientOptions} [options] Options for the webhook client
42
- */
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
43
19
  constructor(data, options) {
44
20
  super(options);
45
21
  Object.defineProperty(this, 'client', { value: this });
@@ -58,35 +34,17 @@ class WebhookClient extends BaseClient {
58
34
  Object.defineProperty(this, 'token', { value: token, writable: true, configurable: true });
59
35
  }
60
36
 
61
- /**
62
- * The options the webhook client was instantiated with.
63
- * @type {WebhookClientOptions}
64
- * @name WebhookClient#options
65
- */
66
-
67
- // These are here only for documentation purposes - they are implemented by Webhook
68
- /* eslint-disable no-empty-function, valid-jsdoc */
69
- /**
70
- * Sends a message with this webhook.
71
- * @param {string|MessagePayload|WebhookMessageCreateOptions} options The content for the reply
72
- * @returns {Promise<APIMessage>}
73
- */
37
+
38
+
39
+
40
+
41
+
74
42
  send() {}
75
43
 
76
- /**
77
- * Gets a message that was sent by this webhook.
78
- * @param {Snowflake} message The id of the message to fetch
79
- * @param {WebhookFetchMessageOptions} [options={}] The options to provide to fetch the message.
80
- * @returns {Promise<APIMessage>} Returns the message sent by this webhook
81
- */
44
+
82
45
  fetchMessage() {}
83
46
 
84
- /**
85
- * Edits a message that was sent by this webhook.
86
- * @param {MessageResolvable} message The message to edit
87
- * @param {string|MessagePayload|WebhookMessageEditOptions} options The options to provide
88
- * @returns {Promise<APIMessage>} Returns the message edited by this webhook
89
- */
47
+
90
48
  editMessage() {}
91
49
 
92
50
  sendSlackMessage() {}
@@ -2,17 +2,7 @@
2
2
 
3
3
  const Partials = require('../../util/Partials');
4
4
 
5
- /*
6
5
 
7
- ABOUT ACTIONS
8
-
9
- Actions are similar to WebSocket Packet Handlers, but since introducing
10
- the REST API methods, in order to prevent rewriting code to handle data,
11
- "actions" have been introduced. They're basically what Packet Handlers
12
- used to be but they're strictly for manipulating data and making sure
13
- that WebSocket events don't clash with REST methods.
14
-
15
- */
16
6
 
17
7
  class GenericAction {
18
8
  constructor(client) {
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  class ActionsManager {
4
- // These symbols represent fully built data that we inject at times when calling actions manually.
5
- // Action#getUser, for example, will return the injected data (which is assumed to be a built structure)
6
- // instead of trying to make it from provided data
4
+
5
+
6
+
7
7
  injectedUser = Symbol('djs.actions.injectedUser');
8
8
  injectedChannel = Symbol('djs.actions.injectedChannel');
9
9
  injectedMessage = Symbol('djs.actions.injectedMessage');
@@ -3,25 +3,12 @@
3
3
  const Action = require('./Action');
4
4
  const Events = require('../../util/Events');
5
5
 
6
- /**
7
- * The data received in the {@link Client#event:applicationCommandPermissionsUpdate} event
8
- * @typedef {Object} ApplicationCommandPermissionsUpdateData
9
- * @property {Snowflake} id The id of the command or global entity that was updated
10
- * @property {Snowflake} guildId The id of the guild in which permissions were updated
11
- * @property {Snowflake} applicationId The id of the application that owns the command or entity being updated
12
- * @property {ApplicationCommandPermissions[]} permissions The updated permissions
13
- */
6
+
14
7
 
15
8
  class ApplicationCommandPermissionsUpdateAction extends Action {
16
9
  handle(data) {
17
10
  const client = this.client;
18
- /**
19
- * Emitted whenever permissions for an application command in a guild were updated.
20
- * <warn>This includes permission updates for other applications in addition to the logged in client,
21
- * check `data.applicationId` to verify which application the update is for</warn>
22
- * @event Client#applicationCommandPermissionsUpdate
23
- * @param {ApplicationCommandPermissionsUpdateData} data The updated permissions
24
- */
11
+
25
12
  client.emit(Events.ApplicationCommandPermissionsUpdate, {
26
13
  permissions: data.permissions,
27
14
  id: data.id,
@@ -10,12 +10,7 @@ class AutoModerationActionExecutionAction extends Action {
10
10
  const guild = client.guilds.cache.get(data.guild_id);
11
11
 
12
12
  if (guild) {
13
- /**
14
- * Emitted whenever an auto moderation rule is triggered.
15
- * <info>This event requires the {@link PermissionFlagsBits.ManageGuild} permission.</info>
16
- * @event Client#autoModerationActionExecution
17
- * @param {AutoModerationActionExecution} autoModerationActionExecution The data of the execution
18
- */
13
+
19
14
  client.emit(Events.AutoModerationActionExecution, new AutoModerationActionExecution(data, guild));
20
15
  }
21
16
 
@@ -11,12 +11,7 @@ class AutoModerationRuleCreateAction extends Action {
11
11
  if (guild) {
12
12
  const autoModerationRule = guild.autoModerationRules._add(data);
13
13
 
14
- /**
15
- * Emitted whenever an auto moderation rule is created.
16
- * <info>This event requires the {@link PermissionFlagsBits.ManageGuild} permission.</info>
17
- * @event Client#autoModerationRuleCreate
18
- * @param {AutoModerationRule} autoModerationRule The created auto moderation rule
19
- */
14
+
20
15
  client.emit(Events.AutoModerationRuleCreate, autoModerationRule);
21
16
  }
22
17
 
@@ -14,12 +14,7 @@ class AutoModerationRuleDeleteAction extends Action {
14
14
  if (autoModerationRule) {
15
15
  guild.autoModerationRules.cache.delete(autoModerationRule.id);
16
16
 
17
- /**
18
- * Emitted whenever an auto moderation rule is deleted.
19
- * <info>This event requires the {@link PermissionFlagsBits.ManageGuild} permission.</info>
20
- * @event Client#autoModerationRuleDelete
21
- * @param {AutoModerationRule} autoModerationRule The deleted auto moderation rule
22
- */
17
+
23
18
  client.emit(Events.AutoModerationRuleDelete, autoModerationRule);
24
19
  }
25
20
  }
@@ -12,13 +12,7 @@ class AutoModerationRuleUpdateAction extends Action {
12
12
  const oldAutoModerationRule = guild.autoModerationRules.cache.get(data.id)?._clone() ?? null;
13
13
  const newAutoModerationRule = guild.autoModerationRules._add(data);
14
14
 
15
- /**
16
- * Emitted whenever an auto moderation rule gets updated.
17
- * <info>This event requires the {@link PermissionFlagsBits.ManageGuild} permission.</info>
18
- * @event Client#autoModerationRuleUpdate
19
- * @param {?AutoModerationRule} oldAutoModerationRule The auto moderation rule before the update
20
- * @param {AutoModerationRule} newAutoModerationRule The auto moderation rule after the update
21
- */
15
+
22
16
  client.emit(Events.AutoModerationRuleUpdate, oldAutoModerationRule, newAutoModerationRule);
23
17
  }
24
18
 
@@ -9,11 +9,7 @@ class ChannelCreateAction extends Action {
9
9
  const existing = client.channels.cache.has(data.id);
10
10
  const channel = client.channels._add(data);
11
11
  if (!existing && channel) {
12
- /**
13
- * Emitted whenever a guild channel is created.
14
- * @event Client#channelCreate
15
- * @param {GuildChannel} channel The channel that was created
16
- */
12
+
17
13
  client.emit(Events.ChannelCreate, channel);
18
14
  }
19
15
  return { channel };
@@ -10,11 +10,7 @@ class ChannelDeleteAction extends Action {
10
10
 
11
11
  if (channel) {
12
12
  client.channels._remove(channel.id);
13
- /**
14
- * Emitted whenever a channel is deleted.
15
- * @event Client#channelDelete
16
- * @param {DMChannel|GuildChannel} channel The channel that was deleted
17
- */
13
+
18
14
  client.emit(Events.ChannelDelete, channel);
19
15
  }
20
16
  }
@@ -13,12 +13,7 @@ class GuildAuditLogEntryCreateAction extends Action {
13
13
  if (guild) {
14
14
  auditLogEntry = new GuildAuditLogsEntry(guild, data);
15
15
 
16
- /**
17
- * Emitted whenever a guild audit log entry is created.
18
- * @event Client#guildAuditLogEntryCreate
19
- * @param {GuildAuditLogsEntry} auditLogEntry The entry that was created
20
- * @param {Guild} guild The guild where the entry was created
21
- */
16
+
22
17
  client.emit(Events.GuildAuditLogEntryCreate, auditLogEntry, guild);
23
18
  }
24
19
 
@@ -8,11 +8,7 @@ class GuildBanAdd extends Action {
8
8
  const client = this.client;
9
9
  const guild = client.guilds.cache.get(data.guild_id);
10
10
 
11
- /**
12
- * Emitted whenever a member is banned from a guild.
13
- * @event Client#guildBanAdd
14
- * @param {GuildBan} ban The ban that occurred
15
- */
11
+
16
12
  if (guild) client.emit(Events.GuildBanAdd, guild.bans._add(data));
17
13
  }
18
14
  }
@@ -9,11 +9,7 @@ class GuildBanRemove extends Action {
9
9
  const client = this.client;
10
10
  const guild = client.guilds.cache.get(data.guild_id);
11
11
 
12
- /**
13
- * Emitted whenever a member is unbanned from a guild.
14
- * @event Client#guildBanRemove
15
- * @param {GuildBan} ban The ban that was removed
16
- */
12
+
17
13
  if (guild) {
18
14
  const ban = guild.bans.cache.get(data.user.id) ?? new GuildBan(client, data, guild);
19
15
  guild.bans.cache.delete(ban.user.id);
@@ -10,32 +10,24 @@ class GuildDeleteAction extends Action {
10
10
  let guild = client.guilds.cache.get(data.id);
11
11
  if (guild) {
12
12
  if (data.unavailable) {
13
- // Guild is unavailable
13
+
14
14
  guild.available = false;
15
15
 
16
- /**
17
- * Emitted whenever a guild becomes unavailable, likely due to a server outage.
18
- * @event Client#guildUnavailable
19
- * @param {Guild} guild The guild that has become unavailable
20
- */
16
+
21
17
  client.emit(Events.GuildUnavailable, guild);
22
18
 
23
- // Stops the GuildDelete packet thinking a guild was actually deleted,
24
- // handles emitting of event itself
19
+
20
+
25
21
  return;
26
22
  }
27
23
 
28
24
  for (const channel of guild.channels.cache.values()) this.client.channels._remove(channel.id);
29
25
  client.voice.adapters.get(data.id)?.destroy();
30
26
 
31
- // Delete guild
27
+
32
28
  client.guilds.cache.delete(guild.id);
33
29
 
34
- /**
35
- * Emitted whenever a guild kicks the client or the guild is deleted/left.
36
- * @event Client#guildDelete
37
- * @param {Guild} guild The guild that was deleted
38
- */
30
+
39
31
  client.emit(Events.GuildDelete, guild);
40
32
  }
41
33
  }
@@ -7,11 +7,7 @@ class GuildEmojiCreateAction extends Action {
7
7
  handle(guild, createdEmoji) {
8
8
  const already = guild.emojis.cache.has(createdEmoji.id);
9
9
  const emoji = guild.emojis._add(createdEmoji);
10
- /**
11
- * Emitted whenever a custom emoji is created in a guild.
12
- * @event Client#emojiCreate
13
- * @param {GuildEmoji} emoji The emoji that was created
14
- */
10
+
15
11
  if (!already) this.client.emit(Events.GuildEmojiCreate, emoji);
16
12
  return { emoji };
17
13
  }
@@ -6,11 +6,7 @@ const Events = require('../../util/Events');
6
6
  class GuildEmojiDeleteAction extends Action {
7
7
  handle(emoji) {
8
8
  emoji.guild.emojis.cache.delete(emoji.id);
9
- /**
10
- * Emitted whenever a custom emoji is deleted in a guild.
11
- * @event Client#emojiDelete
12
- * @param {GuildEmoji} emoji The emoji that was deleted
13
- */
9
+
14
10
  this.client.emit(Events.GuildEmojiDelete, emoji);
15
11
  return { emoji };
16
12
  }
@@ -6,12 +6,7 @@ const Events = require('../../util/Events');
6
6
  class GuildEmojiUpdateAction extends Action {
7
7
  handle(current, data) {
8
8
  const old = current._update(data);
9
- /**
10
- * Emitted whenever a custom emoji is updated in a guild.
11
- * @event Client#emojiUpdate
12
- * @param {GuildEmoji} oldEmoji The old emoji
13
- * @param {GuildEmoji} newEmoji The new emoji
14
- */
9
+
15
10
  this.client.emit(Events.GuildEmojiUpdate, old, current);
16
11
  return { emoji: current };
17
12
  }
@@ -10,22 +10,22 @@ class GuildEmojisUpdateAction extends Action {
10
10
  const deletions = new Map(guild.emojis.cache);
11
11
 
12
12
  for (const emoji of data.emojis) {
13
- // Determine type of emoji event
13
+
14
14
  const cachedEmoji = guild.emojis.cache.get(emoji.id);
15
15
  if (cachedEmoji) {
16
16
  deletions.delete(emoji.id);
17
17
  if (!cachedEmoji.equals(emoji)) {
18
- // Emoji updated
18
+
19
19
  this.client.actions.GuildEmojiUpdate.handle(cachedEmoji, emoji);
20
20
  }
21
21
  } else {
22
- // Emoji added
22
+
23
23
  this.client.actions.GuildEmojiCreate.handle(guild, emoji);
24
24
  }
25
25
  }
26
26
 
27
27
  for (const emoji of deletions.values()) {
28
- // Emoji deleted
28
+
29
29
  this.client.actions.GuildEmojiDelete.handle(emoji);
30
30
  }
31
31
  }
@@ -7,11 +7,7 @@ class GuildIntegrationsUpdate extends Action {
7
7
  handle(data) {
8
8
  const client = this.client;
9
9
  const guild = client.guilds.cache.get(data.guild_id);
10
- /**
11
- * Emitted whenever a guild integration is updated
12
- * @event Client#guildIntegrationsUpdate
13
- * @param {Guild} guild The guild whose integrations were updated
14
- */
10
+
15
11
  if (guild) client.emit(Events.GuildIntegrationsUpdate, guild);
16
12
  }
17
13
  }
@@ -14,11 +14,7 @@ class GuildMemberRemoveAction extends Action {
14
14
  guild.memberCount--;
15
15
  if (member) {
16
16
  guild.members.cache.delete(member.id);
17
- /**
18
- * Emitted whenever a member leaves a guild, or is kicked.
19
- * @event Client#guildMemberRemove
20
- * @param {GuildMember} member The member that has left/been kicked from the guild
21
- */
17
+
22
18
  if (shard.status === Status.Ready) client.emit(Events.GuildMemberRemove, member);
23
19
  }
24
20
  guild.presences.cache.delete(data.user.id);
@@ -21,20 +21,11 @@ class GuildMemberUpdateAction extends Action {
21
21
  const member = this.getMember({ user: data.user }, guild);
22
22
  if (member) {
23
23
  const old = member._update(data);
24
- /**
25
- * Emitted whenever a guild member changes - i.e. new role, removed role, nickname.
26
- * @event Client#guildMemberUpdate
27
- * @param {GuildMember} oldMember The member before the update
28
- * @param {GuildMember} newMember The member after the update
29
- */
24
+
30
25
  if (shard.status === Status.Ready && !member.equals(old)) client.emit(Events.GuildMemberUpdate, old, member);
31
26
  } else {
32
27
  const newMember = guild.members._add(data);
33
- /**
34
- * Emitted whenever a member becomes available.
35
- * @event Client#guildMemberAvailable
36
- * @param {GuildMember} member The member that became available
37
- */
28
+
38
29
  this.client.emit(Events.GuildMemberAvailable, newMember);
39
30
  }
40
31
  }
@@ -11,11 +11,7 @@ class GuildRoleCreate extends Action {
11
11
  if (guild) {
12
12
  const already = guild.roles.cache.has(data.role.id);
13
13
  role = guild.roles._add(data.role);
14
- /**
15
- * Emitted whenever a role is created.
16
- * @event Client#roleCreate
17
- * @param {Role} role The role that was created
18
- */
14
+
19
15
  if (!already) client.emit(Events.GuildRoleCreate, role);
20
16
  }
21
17
  return { role };
@@ -13,11 +13,7 @@ class GuildRoleDeleteAction extends Action {
13
13
  role = guild.roles.cache.get(data.role_id);
14
14
  if (role) {
15
15
  guild.roles.cache.delete(data.role_id);
16
- /**
17
- * Emitted whenever a guild role is deleted.
18
- * @event Client#roleDelete
19
- * @param {Role} role The role that was deleted
20
- */
16
+
21
17
  client.emit(Events.GuildRoleDelete, role);
22
18
  }
23
19
  }
@@ -14,12 +14,7 @@ class GuildRoleUpdateAction extends Action {
14
14
  const role = guild.roles.cache.get(data.role.id);
15
15
  if (role) {
16
16
  old = role._update(data.role);
17
- /**
18
- * Emitted whenever a guild role is updated.
19
- * @event Client#roleUpdate
20
- * @param {Role} oldRole The role before the update
21
- * @param {Role} newRole The role after the update
22
- */
17
+
23
18
  client.emit(Events.GuildRoleUpdate, old, role);
24
19
  }
25
20
 
@@ -10,11 +10,7 @@ class GuildScheduledEventCreateAction extends Action {
10
10
  if (guild) {
11
11
  const guildScheduledEvent = guild.scheduledEvents._add(data);
12
12
 
13
- /**
14
- * Emitted whenever a guild scheduled event is created.
15
- * @event Client#guildScheduledEventCreate
16
- * @param {GuildScheduledEvent} guildScheduledEvent The created guild scheduled event
17
- */
13
+
18
14
  client.emit(Events.GuildScheduledEventCreate, guildScheduledEvent);
19
15
 
20
16
  return { guildScheduledEvent };
@@ -13,11 +13,7 @@ class GuildScheduledEventDeleteAction extends Action {
13
13
  if (guildScheduledEvent) {
14
14
  guild.scheduledEvents.cache.delete(guildScheduledEvent.id);
15
15
 
16
- /**
17
- * Emitted whenever a guild scheduled event is deleted.
18
- * @event Client#guildScheduledEventDelete
19
- * @param {GuildScheduledEvent} guildScheduledEvent The deleted guild scheduled event
20
- */
16
+
21
17
  client.emit(Events.GuildScheduledEventDelete, guildScheduledEvent);
22
18
 
23
19
  return { guildScheduledEvent };
@@ -12,12 +12,7 @@ class GuildScheduledEventUpdateAction extends Action {
12
12
  const oldGuildScheduledEvent = guild.scheduledEvents.cache.get(data.id)?._clone() ?? null;
13
13
  const newGuildScheduledEvent = guild.scheduledEvents._add(data);
14
14
 
15
- /**
16
- * Emitted whenever a guild scheduled event gets updated.
17
- * @event Client#guildScheduledEventUpdate
18
- * @param {?GuildScheduledEvent} oldGuildScheduledEvent The guild scheduled event object before the update
19
- * @param {GuildScheduledEvent} newGuildScheduledEvent The guild scheduled event object after the update
20
- */
15
+
21
16
  client.emit(Events.GuildScheduledEventUpdate, oldGuildScheduledEvent, newGuildScheduledEvent);
22
17
 
23
18
  return { oldGuildScheduledEvent, newGuildScheduledEvent };
@@ -13,12 +13,7 @@ class GuildScheduledEventUserAddAction extends Action {
13
13
  const user = this.getUser(data);
14
14
 
15
15
  if (guildScheduledEvent && user) {
16
- /**
17
- * Emitted whenever a user subscribes to a guild scheduled event
18
- * @event Client#guildScheduledEventUserAdd
19
- * @param {GuildScheduledEvent} guildScheduledEvent The guild scheduled event
20
- * @param {User} user The user who subscribed
21
- */
16
+
22
17
  client.emit(Events.GuildScheduledEventUserAdd, guildScheduledEvent, user);
23
18
 
24
19
  return { guildScheduledEvent, user };
@@ -13,12 +13,7 @@ class GuildScheduledEventUserRemoveAction extends Action {
13
13
  const user = this.getUser(data);
14
14
 
15
15
  if (guildScheduledEvent && user) {
16
- /**
17
- * Emitted whenever a user unsubscribes from a guild scheduled event
18
- * @event Client#guildScheduledEventUserRemove
19
- * @param {GuildScheduledEvent} guildScheduledEvent The guild scheduled event
20
- * @param {User} user The user who unsubscribed
21
- */
16
+
22
17
  client.emit(Events.GuildScheduledEventUserRemove, guildScheduledEvent, user);
23
18
 
24
19
  return { guildScheduledEvent, user };
@@ -7,11 +7,7 @@ class GuildStickerCreateAction extends Action {
7
7
  handle(guild, createdSticker) {
8
8
  const already = guild.stickers.cache.has(createdSticker.id);
9
9
  const sticker = guild.stickers._add(createdSticker);
10
- /**
11
- * Emitted whenever a custom sticker is created in a guild.
12
- * @event Client#stickerCreate
13
- * @param {Sticker} sticker The sticker that was created
14
- */
10
+
15
11
  if (!already) this.client.emit(Events.GuildStickerCreate, sticker);
16
12
  return { sticker };
17
13
  }
@@ -6,11 +6,7 @@ const Events = require('../../util/Events');
6
6
  class GuildStickerDeleteAction extends Action {
7
7
  handle(sticker) {
8
8
  sticker.guild.stickers.cache.delete(sticker.id);
9
- /**
10
- * Emitted whenever a custom sticker is deleted in a guild.
11
- * @event Client#stickerDelete
12
- * @param {Sticker} sticker The sticker that was deleted
13
- */
9
+
14
10
  this.client.emit(Events.GuildStickerDelete, sticker);
15
11
  return { sticker };
16
12
  }
@@ -6,12 +6,7 @@ const Events = require('../../util/Events');
6
6
  class GuildStickerUpdateAction extends Action {
7
7
  handle(current, data) {
8
8
  const old = current._update(data);
9
- /**
10
- * Emitted whenever a custom sticker is updated in a guild.
11
- * @event Client#stickerUpdate
12
- * @param {Sticker} oldSticker The old sticker
13
- * @param {Sticker} newSticker The new sticker
14
- */
9
+
15
10
  this.client.emit(Events.GuildStickerUpdate, old, current);
16
11
  return { sticker: current };
17
12
  }
@@ -10,22 +10,22 @@ class GuildStickersUpdateAction extends Action {
10
10
  const deletions = new Map(guild.stickers.cache);
11
11
 
12
12
  for (const sticker of data.stickers) {
13
- // Determine type of sticker event
13
+
14
14
  const cachedSticker = guild.stickers.cache.get(sticker.id);
15
15
  if (cachedSticker) {
16
16
  deletions.delete(sticker.id);
17
17
  if (!cachedSticker.equals(sticker)) {
18
- // Sticker updated
18
+
19
19
  this.client.actions.GuildStickerUpdate.handle(cachedSticker, sticker);
20
20
  }
21
21
  } else {
22
- // Sticker added
22
+
23
23
  this.client.actions.GuildStickerCreate.handle(guild, sticker);
24
24
  }
25
25
  }
26
26
 
27
27
  for (const sticker of deletions.values()) {
28
- // Sticker deleted
28
+
29
29
  this.client.actions.GuildStickerDelete.handle(sticker);
30
30
  }
31
31
  }
@@ -10,12 +10,7 @@ class GuildUpdateAction extends Action {
10
10
  const guild = client.guilds.cache.get(data.id);
11
11
  if (guild) {
12
12
  const old = guild._update(data);
13
- /**
14
- * Emitted whenever a guild is updated - e.g. name change.
15
- * @event Client#guildUpdate
16
- * @param {Guild} oldGuild The guild before the update
17
- * @param {Guild} newGuild The guild after the update
18
- */
13
+
19
14
  client.emit(Events.GuildUpdate, old, guild);
20
15
  return {
21
16
  old,