@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
@@ -6,24 +6,14 @@ const GuildChannel = require('./GuildChannel');
6
6
  const TextBasedChannel = require('./interfaces/TextBasedChannel');
7
7
  const MessageManager = require('../managers/MessageManager');
8
8
 
9
- /**
10
- * Represents a voice-based guild channel on Discord.
11
- * @extends {GuildChannel}
12
- * @implements {TextBasedChannel}
13
- */
9
+
14
10
  class BaseGuildVoiceChannel extends GuildChannel {
15
11
  constructor(guild, data, client) {
16
12
  super(guild, data, client, false);
17
- /**
18
- * A manager of the messages sent to this channel
19
- * @type {MessageManager}
20
- */
13
+
21
14
  this.messages = new MessageManager(this);
22
15
 
23
- /**
24
- * If the guild considers this channel NSFW
25
- * @type {boolean}
26
- */
16
+
27
17
  this.nsfw = Boolean(data.nsfw);
28
18
 
29
19
  this._patch(data);
@@ -33,44 +23,29 @@ class BaseGuildVoiceChannel extends GuildChannel {
33
23
  super._patch(data);
34
24
 
35
25
  if ('rtc_region' in data) {
36
- /**
37
- * The RTC region for this voice-based channel. This region is automatically selected if `null`.
38
- * @type {?string}
39
- */
26
+
40
27
  this.rtcRegion = data.rtc_region;
41
28
  }
42
29
 
43
30
  if ('bitrate' in data) {
44
- /**
45
- * The bitrate of this voice-based channel
46
- * @type {number}
47
- */
31
+
48
32
  this.bitrate = data.bitrate;
49
33
  }
50
34
 
51
35
  if ('user_limit' in data) {
52
- /**
53
- * The maximum amount of users allowed in this channel.
54
- * @type {number}
55
- */
36
+
56
37
  this.userLimit = data.user_limit;
57
38
  }
58
39
 
59
40
  if ('video_quality_mode' in data) {
60
- /**
61
- * The camera video quality mode of the channel.
62
- * @type {?VideoQualityMode}
63
- */
41
+
64
42
  this.videoQualityMode = data.video_quality_mode;
65
43
  } else {
66
44
  this.videoQualityMode ??= null;
67
45
  }
68
46
 
69
47
  if ('last_message_id' in data) {
70
- /**
71
- * The last message id sent in the channel, if one was sent
72
- * @type {?Snowflake}
73
- */
48
+
74
49
  this.lastMessageId = data.last_message_id;
75
50
  }
76
51
 
@@ -79,10 +54,7 @@ class BaseGuildVoiceChannel extends GuildChannel {
79
54
  }
80
55
 
81
56
  if ('rate_limit_per_user' in data) {
82
- /**
83
- * The rate limit per user (slowmode) for this channel in seconds
84
- * @type {number}
85
- */
57
+
86
58
  this.rateLimitPerUser = data.rate_limit_per_user;
87
59
  }
88
60
 
@@ -91,11 +63,7 @@ class BaseGuildVoiceChannel extends GuildChannel {
91
63
  }
92
64
  }
93
65
 
94
- /**
95
- * The members in this voice-based channel
96
- * @type {Collection<Snowflake, GuildMember>}
97
- * @readonly
98
- */
66
+
99
67
  get members() {
100
68
  const coll = new Collection();
101
69
  for (const state of this.guild.voiceStates.cache.values()) {
@@ -106,26 +74,18 @@ class BaseGuildVoiceChannel extends GuildChannel {
106
74
  return coll;
107
75
  }
108
76
 
109
- /**
110
- * Checks if the voice-based channel is full
111
- * @type {boolean}
112
- * @readonly
113
- */
77
+
114
78
  get full() {
115
79
  return this.userLimit > 0 && this.members.size >= this.userLimit;
116
80
  }
117
81
 
118
- /**
119
- * Whether the channel is joinable by the client user
120
- * @type {boolean}
121
- * @readonly
122
- */
82
+
123
83
  get joinable() {
124
84
  if (!this.viewable) return false;
125
85
  const permissions = this.permissionsFor(this.client.user);
126
86
  if (!permissions) return false;
127
87
 
128
- // This flag allows joining even if timed out
88
+
129
89
  if (permissions.has(PermissionFlagsBits.Administrator, false)) return true;
130
90
 
131
91
  return (
@@ -134,87 +94,38 @@ class BaseGuildVoiceChannel extends GuildChannel {
134
94
  );
135
95
  }
136
96
 
137
- /**
138
- * Creates an invite to this guild channel.
139
- * @param {InviteCreateOptions} [options={}] The options for creating the invite
140
- * @returns {Promise<Invite>}
141
- * @example
142
- * // Create an invite to a channel
143
- * channel.createInvite()
144
- * .then(invite => console.log(`Created an invite with a code of ${invite.code}`))
145
- * .catch(console.error);
146
- */
97
+
147
98
  createInvite(options) {
148
99
  return this.guild.invites.create(this.id, options);
149
100
  }
150
101
 
151
- /**
152
- * Fetches a collection of invites to this guild channel.
153
- * @param {boolean} [cache=true] Whether to cache the fetched invites
154
- * @returns {Promise<Collection<string, Invite>>}
155
- */
102
+
156
103
  fetchInvites(cache = true) {
157
104
  return this.guild.invites.fetch({ channelId: this.id, cache });
158
105
  }
159
106
 
160
- /**
161
- * Sets the bitrate of the channel.
162
- * @param {number} bitrate The new bitrate
163
- * @param {string} [reason] Reason for changing the channel's bitrate
164
- * @returns {Promise<BaseGuildVoiceChannel>}
165
- * @example
166
- * // Set the bitrate of a voice channel
167
- * channel.setBitrate(48_000)
168
- * .then(channel => console.log(`Set bitrate to ${channel.bitrate}bps for ${channel.name}`))
169
- * .catch(console.error);
170
- */
107
+
171
108
  setBitrate(bitrate, reason) {
172
109
  return this.edit({ bitrate, reason });
173
110
  }
174
111
 
175
- /**
176
- * Sets the RTC region of the channel.
177
- * @param {?string} rtcRegion The new region of the channel. Set to `null` to remove a specific region for the channel
178
- * @param {string} [reason] The reason for modifying this region.
179
- * @returns {Promise<BaseGuildVoiceChannel>}
180
- * @example
181
- * // Set the RTC region to sydney
182
- * channel.setRTCRegion('sydney');
183
- * @example
184
- * // Remove a fixed region for this channel - let Discord decide automatically
185
- * channel.setRTCRegion(null, 'We want to let Discord decide.');
186
- */
112
+
187
113
  setRTCRegion(rtcRegion, reason) {
188
114
  return this.edit({ rtcRegion, reason });
189
115
  }
190
116
 
191
- /**
192
- * Sets the user limit of the channel.
193
- * @param {number} userLimit The new user limit
194
- * @param {string} [reason] Reason for changing the user limit
195
- * @returns {Promise<BaseGuildVoiceChannel>}
196
- * @example
197
- * // Set the user limit of a voice channel
198
- * channel.setUserLimit(42)
199
- * .then(channel => console.log(`Set user limit to ${channel.userLimit} for ${channel.name}`))
200
- * .catch(console.error);
201
- */
117
+
202
118
  setUserLimit(userLimit, reason) {
203
119
  return this.edit({ userLimit, reason });
204
120
  }
205
121
 
206
- /**
207
- * Sets the camera video quality mode of the channel.
208
- * @param {VideoQualityMode} videoQualityMode The new camera video quality mode.
209
- * @param {string} [reason] Reason for changing the camera video quality mode.
210
- * @returns {Promise<BaseGuildVoiceChannel>}
211
- */
122
+
212
123
  setVideoQualityMode(videoQualityMode, reason) {
213
124
  return this.edit({ videoQualityMode, reason });
214
125
  }
215
126
 
216
- // These are here only for documentation purposes - they are implemented by TextBasedChannel
217
- /* eslint-disable no-empty-function */
127
+
128
+
218
129
  get lastMessage() {}
219
130
  send() {}
220
131
  sendTyping() {}
@@ -7,222 +7,106 @@ const Base = require('./Base');
7
7
  const { SelectMenuTypes } = require('../util/Constants');
8
8
  const PermissionsBitField = require('../util/PermissionsBitField');
9
9
 
10
- /**
11
- * Represents an interaction.
12
- * @extends {Base}
13
- * @abstract
14
- */
10
+
15
11
  class BaseInteraction extends Base {
16
12
  constructor(client, data) {
17
13
  super(client);
18
14
 
19
- /**
20
- * The interaction's type
21
- * @type {InteractionType}
22
- */
15
+
23
16
  this.type = data.type;
24
17
 
25
- /**
26
- * The interaction's id
27
- * @type {Snowflake}
28
- */
18
+
29
19
  this.id = data.id;
30
20
 
31
- /**
32
- * The interaction's token
33
- * @type {string}
34
- * @name BaseInteraction#token
35
- * @readonly
36
- */
21
+
37
22
  Object.defineProperty(this, 'token', { value: data.token });
38
23
 
39
- /**
40
- * The application's id
41
- * @type {Snowflake}
42
- */
24
+
43
25
  this.applicationId = data.application_id;
44
26
 
45
- /**
46
- * The id of the channel this interaction was sent in
47
- * @type {?Snowflake}
48
- */
27
+
49
28
  this.channelId = data.channel?.id ?? null;
50
29
 
51
- /**
52
- * The id of the guild this interaction was sent in
53
- * @type {?Snowflake}
54
- */
30
+
55
31
  this.guildId = data.guild_id ?? null;
56
32
 
57
- /**
58
- * The user who created this interaction
59
- * @type {User}
60
- */
33
+
61
34
  this.user = this.client.users._add(data.user ?? data.member.user);
62
35
 
63
- /**
64
- * If this interaction was sent in a guild, the member which sent it
65
- * @type {?(GuildMember|APIGuildMember)}
66
- */
36
+
67
37
  this.member = data.member ? this.guild?.members._add(data.member) ?? data.member : null;
68
38
 
69
- /**
70
- * The version
71
- * @type {number}
72
- */
39
+
73
40
  this.version = data.version;
74
41
 
75
- /**
76
- * Set of permissions the application or bot has within the channel the interaction was sent from
77
- * @type {?Readonly<PermissionsBitField>}
78
- */
42
+
79
43
  this.appPermissions = data.app_permissions ? new PermissionsBitField(data.app_permissions).freeze() : null;
80
44
 
81
- /**
82
- * The permissions of the member, if one exists, in the channel this interaction was executed in
83
- * @type {?Readonly<PermissionsBitField>}
84
- */
45
+
85
46
  this.memberPermissions = data.member?.permissions
86
47
  ? new PermissionsBitField(data.member.permissions).freeze()
87
48
  : null;
88
49
 
89
- /**
90
- * A Discord locale string, possible values are:
91
- * * en-US (English, US)
92
- * * en-GB (English, UK)
93
- * * bg (Bulgarian)
94
- * * zh-CN (Chinese, China)
95
- * * zh-TW (Chinese, Taiwan)
96
- * * hr (Croatian)
97
- * * cs (Czech)
98
- * * da (Danish)
99
- * * nl (Dutch)
100
- * * fi (Finnish)
101
- * * fr (French)
102
- * * de (German)
103
- * * el (Greek)
104
- * * hi (Hindi)
105
- * * hu (Hungarian)
106
- * * it (Italian)
107
- * * ja (Japanese)
108
- * * ko (Korean)
109
- * * lt (Lithuanian)
110
- * * no (Norwegian)
111
- * * pl (Polish)
112
- * * pt-BR (Portuguese, Brazilian)
113
- * * ro (Romanian, Romania)
114
- * * ru (Russian)
115
- * * es-ES (Spanish)
116
- * * sv-SE (Swedish)
117
- * * th (Thai)
118
- * * tr (Turkish)
119
- * * uk (Ukrainian)
120
- * * vi (Vietnamese)
121
- * @see {@link https://discord.com/developers/docs/reference#locales}
122
- * @typedef {string} Locale
123
- */
124
-
125
- /**
126
- * The locale of the user who invoked this interaction
127
- * @type {Locale}
128
- */
50
+
51
+
52
+
129
53
  this.locale = data.locale;
130
54
 
131
- /**
132
- * The preferred locale from the guild this interaction was sent in
133
- * @type {?Locale}
134
- */
55
+
135
56
  this.guildLocale = data.guild_locale ?? null;
136
57
  }
137
58
 
138
- /**
139
- * The timestamp the interaction was created at
140
- * @type {number}
141
- * @readonly
142
- */
59
+
143
60
  get createdTimestamp() {
144
61
  return DiscordSnowflake.timestampFrom(this.id);
145
62
  }
146
63
 
147
- /**
148
- * The time the interaction was created at
149
- * @type {Date}
150
- * @readonly
151
- */
64
+
152
65
  get createdAt() {
153
66
  return new Date(this.createdTimestamp);
154
67
  }
155
68
 
156
- /**
157
- * The channel this interaction was sent in
158
- * @type {?TextBasedChannels}
159
- * @readonly
160
- */
69
+
161
70
  get channel() {
162
71
  return this.client.channels.cache.get(this.channelId) ?? null;
163
72
  }
164
73
 
165
- /**
166
- * The guild this interaction was sent in
167
- * @type {?Guild}
168
- * @readonly
169
- */
74
+
170
75
  get guild() {
171
76
  return this.client.guilds.cache.get(this.guildId) ?? null;
172
77
  }
173
78
 
174
- /**
175
- * Indicates whether this interaction is received from a guild.
176
- * @returns {boolean}
177
- */
79
+
178
80
  inGuild() {
179
81
  return Boolean(this.guildId && this.member);
180
82
  }
181
83
 
182
- /**
183
- * Indicates whether or not this interaction is both cached and received from a guild.
184
- * @returns {boolean}
185
- */
84
+
186
85
  inCachedGuild() {
187
86
  return Boolean(this.guild && this.member);
188
87
  }
189
88
 
190
- /**
191
- * Indicates whether or not this interaction is received from an uncached guild.
192
- * @returns {boolean}
193
- */
89
+
194
90
  inRawGuild() {
195
91
  return Boolean(this.guildId && !this.guild && this.member);
196
92
  }
197
93
 
198
- /**
199
- * Indicates whether this interaction is an {@link AutocompleteInteraction}
200
- * @returns {boolean}
201
- */
94
+
202
95
  isAutocomplete() {
203
96
  return this.type === InteractionType.ApplicationCommandAutocomplete;
204
97
  }
205
98
 
206
- /**
207
- * Indicates whether this interaction is a {@link CommandInteraction}
208
- * @returns {boolean}
209
- */
99
+
210
100
  isCommand() {
211
101
  return this.type === InteractionType.ApplicationCommand;
212
102
  }
213
103
 
214
- /**
215
- * Indicates whether this interaction is a {@link ChatInputCommandInteraction}.
216
- * @returns {boolean}
217
- */
104
+
218
105
  isChatInputCommand() {
219
106
  return this.type === InteractionType.ApplicationCommand && this.commandType === ApplicationCommandType.ChatInput;
220
107
  }
221
108
 
222
- /**
223
- * Indicates whether this interaction is a {@link ContextMenuCommandInteraction}
224
- * @returns {boolean}
225
- */
109
+
226
110
  isContextMenuCommand() {
227
111
  return (
228
112
  this.type === InteractionType.ApplicationCommand &&
@@ -230,107 +114,67 @@ class BaseInteraction extends Base {
230
114
  );
231
115
  }
232
116
 
233
- /**
234
- * Indicates whether this interaction is a {@link MessageComponentInteraction}
235
- * @returns {boolean}
236
- */
117
+
237
118
  isMessageComponent() {
238
119
  return this.type === InteractionType.MessageComponent;
239
120
  }
240
121
 
241
- /**
242
- * Indicates whether this interaction is a {@link ModalSubmitInteraction}
243
- * @returns {boolean}
244
- */
122
+
245
123
  isModalSubmit() {
246
124
  return this.type === InteractionType.ModalSubmit;
247
125
  }
248
126
 
249
- /**
250
- * Indicates whether this interaction is a {@link UserContextMenuCommandInteraction}
251
- * @returns {boolean}
252
- */
127
+
253
128
  isUserContextMenuCommand() {
254
129
  return this.isContextMenuCommand() && this.commandType === ApplicationCommandType.User;
255
130
  }
256
131
 
257
- /**
258
- * Indicates whether this interaction is a {@link MessageContextMenuCommandInteraction}
259
- * @returns {boolean}
260
- */
132
+
261
133
  isMessageContextMenuCommand() {
262
134
  return this.isContextMenuCommand() && this.commandType === ApplicationCommandType.Message;
263
135
  }
264
136
 
265
- /**
266
- * Indicates whether this interaction is a {@link ButtonInteraction}.
267
- * @returns {boolean}
268
- */
137
+
269
138
  isButton() {
270
139
  return this.type === InteractionType.MessageComponent && this.componentType === ComponentType.Button;
271
140
  }
272
141
 
273
- /**
274
- * Indicates whether this interaction is a {@link StringSelectMenuInteraction}.
275
- * @returns {boolean}
276
- * @deprecated Use {@link BaseInteraction#isStringSelectMenu} instead.
277
- */
142
+
278
143
  isSelectMenu() {
279
144
  return this.isStringSelectMenu();
280
145
  }
281
146
 
282
- /**
283
- * Indicates whether this interaction is a select menu of any known type.
284
- * @returns {boolean}
285
- */
147
+
286
148
  isAnySelectMenu() {
287
149
  return this.type === InteractionType.MessageComponent && SelectMenuTypes.includes(this.componentType);
288
150
  }
289
151
 
290
- /**
291
- * Indicates whether this interaction is a {@link StringSelectMenuInteraction}.
292
- * @returns {boolean}
293
- */
152
+
294
153
  isStringSelectMenu() {
295
154
  return this.type === InteractionType.MessageComponent && this.componentType === ComponentType.StringSelect;
296
155
  }
297
156
 
298
- /**
299
- * Indicates whether this interaction is a {@link UserSelectMenuInteraction}
300
- * @returns {boolean}
301
- */
157
+
302
158
  isUserSelectMenu() {
303
159
  return this.type === InteractionType.MessageComponent && this.componentType === ComponentType.UserSelect;
304
160
  }
305
161
 
306
- /**
307
- * Indicates whether this interaction is a {@link RoleSelectMenuInteraction}
308
- * @returns {boolean}
309
- */
162
+
310
163
  isRoleSelectMenu() {
311
164
  return this.type === InteractionType.MessageComponent && this.componentType === ComponentType.RoleSelect;
312
165
  }
313
166
 
314
- /**
315
- * Indicates whether this interaction is a {@link ChannelSelectMenuInteraction}
316
- * @returns {boolean}
317
- */
167
+
318
168
  isChannelSelectMenu() {
319
169
  return this.type === InteractionType.MessageComponent && this.componentType === ComponentType.ChannelSelect;
320
170
  }
321
171
 
322
- /**
323
- * Indicates whether this interaction is a {@link MentionableSelectMenuInteraction}
324
- * @returns {boolean}
325
- */
172
+
326
173
  isMentionableSelectMenu() {
327
174
  return this.type === InteractionType.MessageComponent && this.componentType === ComponentType.MentionableSelect;
328
175
  }
329
176
 
330
- /**
331
- * Indicates whether this interaction can be replied to.
332
- * @returns {boolean}
333
- */
177
+
334
178
  isRepliable() {
335
179
  return ![InteractionType.Ping, InteractionType.ApplicationCommandAutocomplete].includes(this.type);
336
180
  }
@@ -2,52 +2,29 @@
2
2
 
3
3
  const Component = require('./Component');
4
4
 
5
- /**
6
- * Represents a select menu component
7
- * @extends {Component}
8
- */
5
+
9
6
  class BaseSelectMenuComponent extends Component {
10
- /**
11
- * The placeholder for this select menu
12
- * @type {?string}
13
- * @readonly
14
- */
7
+
15
8
  get placeholder() {
16
9
  return this.data.placeholder ?? null;
17
10
  }
18
11
 
19
- /**
20
- * The maximum amount of options that can be selected
21
- * @type {?number}
22
- * @readonly
23
- */
12
+
24
13
  get maxValues() {
25
14
  return this.data.max_values ?? null;
26
15
  }
27
16
 
28
- /**
29
- * The minimum amount of options that must be selected
30
- * @type {?number}
31
- * @readonly
32
- */
17
+
33
18
  get minValues() {
34
19
  return this.data.min_values ?? null;
35
20
  }
36
21
 
37
- /**
38
- * The custom id of this select menu
39
- * @type {string}
40
- * @readonly
41
- */
22
+
42
23
  get customId() {
43
24
  return this.data.custom_id;
44
25
  }
45
26
 
46
- /**
47
- * Whether this select menu is disabled
48
- * @type {boolean}
49
- * @readonly
50
- */
27
+
51
28
  get disabled() {
52
29
  return this.data.disabled ?? false;
53
30
  }
@@ -5,20 +5,13 @@ const { isJSONEncodable } = require('@discordjs/util');
5
5
  const { toSnakeCase } = require('../util/Transformers');
6
6
  const { resolvePartialEmoji } = require('../util/Util');
7
7
 
8
- /**
9
- * Represents a button builder.
10
- * @extends {BuildersButton}
11
- */
8
+
12
9
  class ButtonBuilder extends BuildersButton {
13
10
  constructor({ emoji, ...data } = {}) {
14
11
  super(toSnakeCase({ ...data, emoji: emoji && typeof emoji === 'string' ? resolvePartialEmoji(emoji) : emoji }));
15
12
  }
16
13
 
17
- /**
18
- * Sets the emoji to display on this button
19
- * @param {string|APIMessageComponentEmoji} emoji The emoji to display on this button
20
- * @returns {ButtonBuilder}
21
- */
14
+
22
15
  setEmoji(emoji) {
23
16
  if (typeof emoji === 'string') {
24
17
  return super.setEmoji(resolvePartialEmoji(emoji));
@@ -26,11 +19,7 @@ class ButtonBuilder extends BuildersButton {
26
19
  return super.setEmoji(emoji);
27
20
  }
28
21
 
29
- /**
30
- * Creates a new button builder from JSON data
31
- * @param {ButtonBuilder|ButtonComponent|APIButtonComponent} other The other data
32
- * @returns {ButtonBuilder}
33
- */
22
+
34
23
  static from(other) {
35
24
  return new this(isJSONEncodable(other) ? other.toJSON() : other);
36
25
  }
@@ -38,7 +27,4 @@ class ButtonBuilder extends BuildersButton {
38
27
 
39
28
  module.exports = ButtonBuilder;
40
29
 
41
- /**
42
- * @external BuildersButton
43
- * @see {@link https://discord.js.org/docs/packages/builders/stable/ButtonBuilder:Class}
44
- */
30
+