@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
@@ -7,62 +7,19 @@ const InteractionCollector = require('../InteractionCollector');
7
7
  const InteractionResponse = require('../InteractionResponse');
8
8
  const MessagePayload = require('../MessagePayload');
9
9
 
10
- /**
11
- * @typedef {Object} ModalComponentData
12
- * @property {string} title The title of the modal
13
- * @property {string} customId The custom id of the modal
14
- * @property {ActionRow[]} components The components within this modal
15
- */
16
-
17
- /**
18
- * Interface for classes that support shared interaction response types.
19
- * @interface
20
- */
10
+
11
+
12
+
21
13
  class InteractionResponses {
22
- /**
23
- * Options for deferring the reply to an {@link BaseInteraction}.
24
- * @typedef {Object} InteractionDeferReplyOptions
25
- * @property {boolean} [ephemeral] Whether the reply should be ephemeral
26
- * @property {boolean} [fetchReply] Whether to fetch the reply
27
- */
28
-
29
- /**
30
- * Options for deferring and updating the reply to a {@link MessageComponentInteraction}.
31
- * @typedef {Object} InteractionDeferUpdateOptions
32
- * @property {boolean} [fetchReply] Whether to fetch the reply
33
- */
34
-
35
- /**
36
- * Options for a reply to a {@link BaseInteraction}.
37
- * @typedef {BaseMessageOptions} InteractionReplyOptions
38
- * @property {boolean} [tts=false] Whether the message should be spoken aloud
39
- * @property {boolean} [ephemeral] Whether the reply should be ephemeral
40
- * @property {boolean} [fetchReply] Whether to fetch the reply
41
- * @property {MessageFlags} [flags] Which flags to set for the message.
42
- * <info>Only `MessageFlags.SuppressEmbeds` and `MessageFlags.Ephemeral` can be set.</info>
43
- */
44
-
45
- /**
46
- * Options for updating the message received from a {@link MessageComponentInteraction}.
47
- * @typedef {MessageEditOptions} InteractionUpdateOptions
48
- * @property {boolean} [fetchReply] Whether to fetch the reply
49
- */
50
-
51
- /**
52
- * Defers the reply to this interaction.
53
- * @param {InteractionDeferReplyOptions} [options] Options for deferring the reply to this interaction
54
- * @returns {Promise<Message|InteractionResponse>}
55
- * @example
56
- * // Defer the reply to this interaction
57
- * interaction.deferReply()
58
- * .then(console.log)
59
- * .catch(console.error)
60
- * @example
61
- * // Defer to send an ephemeral reply later
62
- * interaction.deferReply({ ephemeral: true })
63
- * .then(console.log)
64
- * .catch(console.error);
65
- */
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
66
23
  async deferReply(options = {}) {
67
24
  if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
68
25
  this.ephemeral = options.ephemeral ?? false;
@@ -80,24 +37,7 @@ class InteractionResponses {
80
37
  return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
81
38
  }
82
39
 
83
- /**
84
- * Creates a reply to this interaction.
85
- * <info>Use the `fetchReply` option to get the bot's reply message.</info>
86
- * @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
87
- * @returns {Promise<Message|InteractionResponse>}
88
- * @example
89
- * // Reply to the interaction and fetch the response
90
- * interaction.reply({ content: 'Pong!', fetchReply: true })
91
- * .then((message) => console.log(`Reply sent with content ${message.content}`))
92
- * .catch(console.error);
93
- * @example
94
- * // Create an ephemeral reply with an embed
95
- * const embed = new EmbedBuilder().setDescription('Pong!');
96
- *
97
- * interaction.reply({ embeds: [embed], ephemeral: true })
98
- * .then(() => console.log('Reply sent.'))
99
- * .catch(console.error);
100
- */
40
+
101
41
  async reply(options) {
102
42
  if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
103
43
  this.ephemeral = options.ephemeral ?? false;
@@ -121,38 +61,14 @@ class InteractionResponses {
121
61
  return options.fetchReply ? this.fetchReply() : new InteractionResponse(this);
122
62
  }
123
63
 
124
- /**
125
- * Fetches a reply to this interaction.
126
- * @see Webhook#fetchMessage
127
- * @param {Snowflake|'@original'} [message='@original'] The response to fetch
128
- * @returns {Promise<Message>}
129
- * @example
130
- * // Fetch the initial reply to this interaction
131
- * interaction.fetchReply()
132
- * .then(reply => console.log(`Replied with ${reply.content}`))
133
- * .catch(console.error);
134
- */
64
+
135
65
  fetchReply(message = '@original') {
136
66
  return this.webhook.fetchMessage(message);
137
67
  }
138
68
 
139
- /**
140
- * Options that can be passed into {@link InteractionResponses#editReply}.
141
- * @typedef {WebhookMessageEditOptions} InteractionEditReplyOptions
142
- * @property {MessageResolvable|'@original'} [message='@original'] The response to edit
143
- */
144
-
145
- /**
146
- * Edits a reply to this interaction.
147
- * @see Webhook#editMessage
148
- * @param {string|MessagePayload|InteractionEditReplyOptions} options The new options for the message
149
- * @returns {Promise<Message>}
150
- * @example
151
- * // Edit the initial reply to this interaction
152
- * interaction.editReply('New content')
153
- * .then(console.log)
154
- * .catch(console.error);
155
- */
69
+
70
+
71
+
156
72
  async editReply(options) {
157
73
  if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied);
158
74
  const msg = await this.webhook.editMessage(options.message ?? '@original', options);
@@ -160,41 +76,18 @@ class InteractionResponses {
160
76
  return msg;
161
77
  }
162
78
 
163
- /**
164
- * Deletes a reply to this interaction.
165
- * @see Webhook#deleteMessage
166
- * @param {MessageResolvable|'@original'} [message='@original'] The response to delete
167
- * @returns {Promise<void>}
168
- * @example
169
- * // Delete the initial reply to this interaction
170
- * interaction.deleteReply()
171
- * .then(console.log)
172
- * .catch(console.error);
173
- */
79
+
174
80
  async deleteReply(message = '@original') {
175
81
  await this.webhook.deleteMessage(message);
176
82
  }
177
83
 
178
- /**
179
- * Send a follow-up message to this interaction.
180
- * @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
181
- * @returns {Promise<Message>}
182
- */
84
+
183
85
  followUp(options) {
184
86
  if (!this.deferred && !this.replied) return Promise.reject(new DiscordjsError(ErrorCodes.InteractionNotReplied));
185
87
  return this.webhook.send(options);
186
88
  }
187
89
 
188
- /**
189
- * Defers an update to the message to which the component was attached.
190
- * @param {InteractionDeferUpdateOptions} [options] Options for deferring the update to this interaction
191
- * @returns {Promise<Message|InteractionResponse>}
192
- * @example
193
- * // Defer updating and reset the component's loading state
194
- * interaction.deferUpdate()
195
- * .then(console.log)
196
- * .catch(console.error);
197
- */
90
+
198
91
  async deferUpdate(options = {}) {
199
92
  if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
200
93
  await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
@@ -208,19 +101,7 @@ class InteractionResponses {
208
101
  return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message?.interaction?.id);
209
102
  }
210
103
 
211
- /**
212
- * Updates the original message of the component on which the interaction was received on.
213
- * @param {string|MessagePayload|InteractionUpdateOptions} options The options for the updated message
214
- * @returns {Promise<Message|void>}
215
- * @example
216
- * // Remove the components from the message
217
- * interaction.update({
218
- * content: "A component interaction was received",
219
- * components: []
220
- * })
221
- * .then(console.log)
222
- * .catch(console.error);
223
- */
104
+
224
105
  async update(options) {
225
106
  if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
226
107
 
@@ -243,11 +124,7 @@ class InteractionResponses {
243
124
  return options.fetchReply ? this.fetchReply() : new InteractionResponse(this, this.message.interaction?.id);
244
125
  }
245
126
 
246
- /**
247
- * Shows a modal component
248
- * @param {ModalBuilder|ModalComponentData|APIModalInteractionResponseCallbackData} modal The modal to show
249
- * @returns {Promise<void>}
250
- */
127
+
251
128
  async showModal(modal) {
252
129
  if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
253
130
  await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
@@ -260,25 +137,9 @@ class InteractionResponses {
260
137
  this.replied = true;
261
138
  }
262
139
 
263
- /**
264
- * An object containing the same properties as {@link CollectorOptions}, but a few less:
265
- * @typedef {Object} AwaitModalSubmitOptions
266
- * @property {CollectorFilter} [filter] The filter applied to this collector
267
- * @property {number} time Time in milliseconds to wait for an interaction before rejecting
268
- */
269
-
270
- /**
271
- * Collects a single modal submit interaction that passes the filter.
272
- * The Promise will reject if the time expires.
273
- * @param {AwaitModalSubmitOptions} options Options to pass to the internal collector
274
- * @returns {Promise<ModalSubmitInteraction>}
275
- * @example
276
- * // Collect a modal submit interaction
277
- * const filter = (interaction) => interaction.customId === 'modal';
278
- * interaction.awaitModalSubmit({ filter, time: 15_000 })
279
- * .then(interaction => console.log(`${interaction.customId} was submitted!`))
280
- * .catch(console.error);
281
- */
140
+
141
+
142
+
282
143
  awaitModalSubmit(options) {
283
144
  if (typeof options.time !== 'number') throw new DiscordjsError(ErrorCodes.InvalidType, 'time', 'number');
284
145
  const _options = { ...options, max: 1, interactionType: InteractionType.ModalSubmit };
@@ -9,138 +9,44 @@ const InteractionCollector = require('../InteractionCollector');
9
9
  const MessageCollector = require('../MessageCollector');
10
10
  const MessagePayload = require('../MessagePayload');
11
11
 
12
- /**
13
- * Interface for classes that have text-channel-like features.
14
- * @interface
15
- */
12
+
16
13
  class TextBasedChannel {
17
14
  constructor() {
18
- /**
19
- * A manager of the messages sent to this channel
20
- * @type {MessageManager}
21
- */
15
+
22
16
  this.messages = new MessageManager(this);
23
17
 
24
- /**
25
- * The channel's last message id, if one was sent
26
- * @type {?Snowflake}
27
- */
18
+
28
19
  this.lastMessageId = null;
29
20
 
30
- /**
31
- * The timestamp when the last pinned message was pinned, if there was one
32
- * @type {?number}
33
- */
21
+
34
22
  this.lastPinTimestamp = null;
35
23
  }
36
24
 
37
- /**
38
- * The Message object of the last message in the channel, if one was sent
39
- * @type {?Message}
40
- * @readonly
41
- */
25
+
42
26
  get lastMessage() {
43
27
  return this.messages.resolve(this.lastMessageId);
44
28
  }
45
29
 
46
- /**
47
- * The date when the last pinned message was pinned, if there was one
48
- * @type {?Date}
49
- * @readonly
50
- */
30
+
51
31
  get lastPinAt() {
52
32
  return this.lastPinTimestamp && new Date(this.lastPinTimestamp);
53
33
  }
54
34
 
55
- /**
56
- * The base message options for messages.
57
- * @typedef {Object} BaseMessageOptions
58
- * @property {string|null} [content=''] The content for the message. This can only be `null` when editing a message.
59
- * @property {Array<(EmbedBuilder|Embed|APIEmbed)>} [embeds] The embeds for the message
60
- * @property {MessageMentionOptions} [allowedMentions] Which mentions should be parsed from the message content
61
- * (see [here](https://discord.com/developers/docs/resources/channel#allowed-mentions-object) for more details)
62
- * @property {Array<(AttachmentBuilder|Attachment|AttachmentPayload|BufferResolvable)>} [files]
63
- * The files to send with the message.
64
- * @property {Array<(ActionRowBuilder|ActionRow|APIActionRowComponent)>} [components]
65
- * Action rows containing interactive components for the message (buttons, select menus)
66
- */
67
-
68
- /**
69
- * Options for sending a message with a reply.
70
- * @typedef {Object} ReplyOptions
71
- * @property {MessageResolvable} messageReference The message to reply to (must be in the same channel and not system)
72
- * @property {boolean} [failIfNotExists=this.client.options.failIfNotExists] Whether to error if the referenced
73
- * message does not exist (creates a standard message in this case when false)
74
- */
75
-
76
- /**
77
- * The options for sending a message.
78
- * @typedef {BaseMessageOptions} BaseMessageCreateOptions
79
- * @property {boolean} [tts=false] Whether the message should be spoken aloud
80
- * @property {string} [nonce=''] The nonce for the message
81
- * @property {StickerResolvable[]} [stickers=[]] The stickers to send in the message
82
- * @property {MessageFlags} [flags] Which flags to set for the message.
83
- * <info>Only `MessageFlags.SuppressEmbeds` and `MessageFlags.SuppressNotifications` can be set.</info>
84
- */
85
-
86
- /**
87
- * The options for sending a message.
88
- * @typedef {BaseMessageCreateOptions} MessageCreateOptions
89
- * @property {ReplyOptions} [reply] The options for replying to a message
90
- */
91
-
92
- /**
93
- * Options provided to control parsing of mentions by Discord
94
- * @typedef {Object} MessageMentionOptions
95
- * @property {MessageMentionTypes[]} [parse] Types of mentions to be parsed
96
- * @property {Snowflake[]} [users] Snowflakes of Users to be parsed as mentions
97
- * @property {Snowflake[]} [roles] Snowflakes of Roles to be parsed as mentions
98
- * @property {boolean} [repliedUser=true] Whether the author of the Message being replied to should be pinged
99
- */
100
-
101
- /**
102
- * Types of mentions to enable in MessageMentionOptions.
103
- * - `roles`
104
- * - `users`
105
- * - `everyone`
106
- * @typedef {string} MessageMentionTypes
107
- */
108
-
109
- /**
110
- * @typedef {Object} FileOptions
111
- * @property {BufferResolvable} attachment File to attach
112
- * @property {string} [name='file.jpg'] Filename of the attachment
113
- * @property {string} description The description of the file
114
- */
115
-
116
- /**
117
- * Sends a message to this channel.
118
- * @param {string|MessagePayload|MessageCreateOptions} options The options to provide
119
- * @returns {Promise<Message>}
120
- * @example
121
- * // Send a basic message
122
- * channel.send('hello!')
123
- * .then(message => console.log(`Sent message: ${message.content}`))
124
- * .catch(console.error);
125
- * @example
126
- * // Send a remote file
127
- * channel.send({
128
- * files: ['https://cdn.discordapp.com/icons/222078108977594368/6e1019b3179d71046e463a75915e7244.png?size=2048']
129
- * })
130
- * .then(console.log)
131
- * .catch(console.error);
132
- * @example
133
- * // Send a local file
134
- * channel.send({
135
- * files: [{
136
- * attachment: 'entire/path/to/file.jpg',
137
- * name: 'file.jpg',
138
- * description: 'A description of the file'
139
- * }]
140
- * })
141
- * .then(console.log)
142
- * .catch(console.error);
143
- */
35
+
36
+
37
+
38
+
39
+
40
+
41
+
42
+
43
+
44
+
45
+
46
+
47
+
48
+
49
+
144
50
  async send(options) {
145
51
  const User = require('../User');
146
52
  const { GuildMember } = require('../GuildMember');
@@ -164,51 +70,19 @@ class TextBasedChannel {
164
70
  return this.messages.cache.get(d.id) ?? this.messages._add(d);
165
71
  }
166
72
 
167
- /**
168
- * Sends a typing indicator in the channel.
169
- * @returns {Promise<void>} Resolves upon the typing status being sent
170
- * @example
171
- * // Start typing in a channel
172
- * channel.sendTyping();
173
- */
73
+
174
74
  async sendTyping() {
175
75
  await this.client.rest.post(Routes.channelTyping(this.id));
176
76
  }
177
77
 
178
- /**
179
- * Creates a Message Collector.
180
- * @param {MessageCollectorOptions} [options={}] The options to pass to the collector
181
- * @returns {MessageCollector}
182
- * @example
183
- * // Create a message collector
184
- * const filter = m => m.content.includes('discord');
185
- * const collector = channel.createMessageCollector({ filter, time: 15_000 });
186
- * collector.on('collect', m => console.log(`Collected ${m.content}`));
187
- * collector.on('end', collected => console.log(`Collected ${collected.size} items`));
188
- */
78
+
189
79
  createMessageCollector(options = {}) {
190
80
  return new MessageCollector(this, options);
191
81
  }
192
82
 
193
- /**
194
- * An object containing the same properties as CollectorOptions, but a few more:
195
- * @typedef {MessageCollectorOptions} AwaitMessagesOptions
196
- * @property {string[]} [errors] Stop/end reasons that cause the promise to reject
197
- */
198
-
199
- /**
200
- * Similar to createMessageCollector but in promise form.
201
- * Resolves with a collection of messages that pass the specified filter.
202
- * @param {AwaitMessagesOptions} [options={}] Optional options to pass to the internal collector
203
- * @returns {Promise<Collection<Snowflake, Message>>}
204
- * @example
205
- * // Await !vote messages
206
- * const filter = m => m.content.startsWith('!vote');
207
- * // Errors: ['time'] treats ending because of the time limit as an error
208
- * channel.awaitMessages({ filter, max: 4, time: 60_000, errors: ['time'] })
209
- * .then(collected => console.log(collected.size))
210
- * .catch(collected => console.log(`After a minute, only ${collected.size} out of 4 voted.`));
211
- */
83
+
84
+
85
+
212
86
  awaitMessages(options = {}) {
213
87
  return new Promise((resolve, reject) => {
214
88
  const collector = this.createMessageCollector(options);
@@ -222,17 +96,7 @@ class TextBasedChannel {
222
96
  });
223
97
  }
224
98
 
225
- /**
226
- * Creates a component interaction collector.
227
- * @param {MessageComponentCollectorOptions} [options={}] Options to send to the collector
228
- * @returns {InteractionCollector}
229
- * @example
230
- * // Create a button interaction collector
231
- * const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
232
- * const collector = channel.createMessageComponentCollector({ filter, time: 15_000 });
233
- * collector.on('collect', i => console.log(`Collected ${i.customId}`));
234
- * collector.on('end', collected => console.log(`Collected ${collected.size} items`));
235
- */
99
+
236
100
  createMessageComponentCollector(options = {}) {
237
101
  return new InteractionCollector(this.client, {
238
102
  ...options,
@@ -241,18 +105,7 @@ class TextBasedChannel {
241
105
  });
242
106
  }
243
107
 
244
- /**
245
- * Collects a single component interaction that passes the filter.
246
- * The Promise will reject if the time expires.
247
- * @param {AwaitMessageComponentOptions} [options={}] Options to pass to the internal collector
248
- * @returns {Promise<MessageComponentInteraction>}
249
- * @example
250
- * // Collect a message component interaction
251
- * const filter = (interaction) => interaction.customId === 'button' && interaction.user.id === 'someId';
252
- * channel.awaitMessageComponent({ filter, time: 15_000 })
253
- * .then(interaction => console.log(`${interaction.customId} was clicked!`))
254
- * .catch(console.error);
255
- */
108
+
256
109
  awaitMessageComponent(options = {}) {
257
110
  const _options = { ...options, max: 1 };
258
111
  return new Promise((resolve, reject) => {
@@ -265,18 +118,7 @@ class TextBasedChannel {
265
118
  });
266
119
  }
267
120
 
268
- /**
269
- * Bulk deletes given messages that are newer than two weeks.
270
- * @param {Collection<Snowflake, Message>|MessageResolvable[]|number} messages
271
- * Messages or number of messages to delete
272
- * @param {boolean} [filterOld=false] Filter messages to remove those which are older than two weeks automatically
273
- * @returns {Promise<Collection<Snowflake, Message|undefined>>} Returns the deleted messages
274
- * @example
275
- * // Bulk delete messages
276
- * channel.bulkDelete(5)
277
- * .then(messages => console.log(`Bulk deleted ${messages.size} messages`))
278
- * .catch(console.error);
279
- */
121
+
280
122
  async bulkDelete(messages, filterOld = false) {
281
123
  if (Array.isArray(messages) || messages instanceof Collection) {
282
124
  let messageIds = messages instanceof Collection ? [...messages.keys()] : messages.map(m => m.id ?? m);
@@ -318,61 +160,24 @@ class TextBasedChannel {
318
160
  throw new DiscordjsTypeError(ErrorCodes.MessageBulkDeleteType);
319
161
  }
320
162
 
321
- /**
322
- * Fetches all webhooks for the channel.
323
- * @returns {Promise<Collection<Snowflake, Webhook>>}
324
- * @example
325
- * // Fetch webhooks
326
- * channel.fetchWebhooks()
327
- * .then(hooks => console.log(`This channel has ${hooks.size} hooks`))
328
- * .catch(console.error);
329
- */
163
+
330
164
  fetchWebhooks() {
331
165
  return this.guild.channels.fetchWebhooks(this.id);
332
166
  }
333
167
 
334
- /**
335
- * Options used to create a {@link Webhook}.
336
- * @typedef {Object} ChannelWebhookCreateOptions
337
- * @property {string} name The name of the webhook
338
- * @property {?(BufferResolvable|Base64Resolvable)} [avatar] Avatar for the webhook
339
- * @property {string} [reason] Reason for creating the webhook
340
- */
341
-
342
- /**
343
- * Creates a webhook for the channel.
344
- * @param {ChannelWebhookCreateOptions} [options] Options for creating the webhook
345
- * @returns {Promise<Webhook>} Returns the created Webhook
346
- * @example
347
- * // Create a webhook for the current channel
348
- * channel.createWebhook({
349
- * name: 'Snek',
350
- * avatar: 'https://i.imgur.com/mI8XcpG.jpg',
351
- * reason: 'Needed a cool new Webhook'
352
- * })
353
- * .then(console.log)
354
- * .catch(console.error)
355
- */
168
+
169
+
170
+
356
171
  createWebhook(options) {
357
172
  return this.guild.channels.createWebhook({ channel: this.id, ...options });
358
173
  }
359
174
 
360
- /**
361
- * Sets the rate limit per user (slowmode) for this channel.
362
- * @param {number} rateLimitPerUser The new rate limit in seconds
363
- * @param {string} [reason] Reason for changing the channel's rate limit
364
- * @returns {Promise<this>}
365
- */
175
+
366
176
  setRateLimitPerUser(rateLimitPerUser, reason) {
367
177
  return this.edit({ rateLimitPerUser, reason });
368
178
  }
369
179
 
370
- /**
371
- * Sets whether this channel is flagged as NSFW.
372
- * @param {boolean} [nsfw=true] Whether the channel should be considered NSFW
373
- * @param {string} [reason] Reason for changing the channel's NSFW flag
374
- * @returns {Promise<this>}
375
- */
180
+
376
181
  setNSFW(nsfw = true, reason) {
377
182
  return this.edit({ nsfw, reason });
378
183
  }
@@ -408,6 +213,6 @@ class TextBasedChannel {
408
213
 
409
214
  module.exports = TextBasedChannel;
410
215
 
411
- // Fixes Circular
412
- // eslint-disable-next-line import/order
216
+
217
+
413
218
  const MessageManager = require('../../managers/MessageManager');