djs-selfbot-v13 3.2.2 → 3.7.1

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 (363) hide show
  1. package/README.md +37 -36
  2. package/package.json +89 -85
  3. package/src/WebSocket.js +39 -39
  4. package/src/client/BaseClient.js +86 -86
  5. package/src/client/Client.js +934 -836
  6. package/src/client/WebhookClient.js +61 -61
  7. package/src/client/actions/Action.js +116 -120
  8. package/src/client/actions/ActionsManager.js +80 -78
  9. package/src/client/actions/ApplicationCommandPermissionsUpdate.js +34 -34
  10. package/src/client/actions/AutoModerationActionExecution.js +27 -27
  11. package/src/client/actions/AutoModerationRuleCreate.js +28 -28
  12. package/src/client/actions/AutoModerationRuleDelete.js +32 -32
  13. package/src/client/actions/AutoModerationRuleUpdate.js +30 -30
  14. package/src/client/actions/ChannelCreate.js +23 -23
  15. package/src/client/actions/ChannelDelete.js +39 -39
  16. package/src/client/actions/ChannelUpdate.js +43 -43
  17. package/src/client/actions/GuildAuditLogEntryCreate.js +29 -29
  18. package/src/client/actions/GuildBanAdd.js +20 -20
  19. package/src/client/actions/GuildBanRemove.js +25 -25
  20. package/src/client/actions/GuildChannelsPositionUpdate.js +21 -21
  21. package/src/client/actions/GuildDelete.js +65 -65
  22. package/src/client/actions/GuildEmojiCreate.js +20 -20
  23. package/src/client/actions/GuildEmojiDelete.js +21 -21
  24. package/src/client/actions/GuildEmojiUpdate.js +20 -20
  25. package/src/client/actions/GuildEmojisUpdate.js +34 -34
  26. package/src/client/actions/GuildIntegrationsUpdate.js +19 -19
  27. package/src/client/actions/GuildMemberRemove.js +33 -32
  28. package/src/client/actions/GuildMemberUpdate.js +44 -43
  29. package/src/client/actions/GuildRoleCreate.js +25 -25
  30. package/src/client/actions/GuildRoleDelete.js +31 -31
  31. package/src/client/actions/GuildRoleUpdate.js +39 -39
  32. package/src/client/actions/GuildRolesPositionUpdate.js +21 -21
  33. package/src/client/actions/GuildScheduledEventCreate.js +27 -27
  34. package/src/client/actions/GuildScheduledEventDelete.js +31 -31
  35. package/src/client/actions/GuildScheduledEventUpdate.js +30 -30
  36. package/src/client/actions/GuildScheduledEventUserAdd.js +32 -32
  37. package/src/client/actions/GuildScheduledEventUserRemove.js +32 -32
  38. package/src/client/actions/GuildStickerCreate.js +20 -20
  39. package/src/client/actions/GuildStickerDelete.js +21 -21
  40. package/src/client/actions/GuildStickerUpdate.js +20 -20
  41. package/src/client/actions/GuildStickersUpdate.js +34 -34
  42. package/src/client/actions/GuildUpdate.js +33 -33
  43. package/src/client/actions/InviteCreate.js +28 -28
  44. package/src/client/actions/InviteDelete.js +30 -30
  45. package/src/client/actions/MessageCreate.js +50 -46
  46. package/src/client/actions/MessageDelete.js +32 -32
  47. package/src/client/actions/MessageDeleteBulk.js +46 -46
  48. package/src/client/actions/MessagePollVoteAdd.js +33 -0
  49. package/src/client/actions/MessagePollVoteRemove.js +33 -0
  50. package/src/client/actions/MessageReactionAdd.js +68 -56
  51. package/src/client/actions/MessageReactionRemove.js +50 -45
  52. package/src/client/actions/MessageReactionRemoveAll.js +33 -33
  53. package/src/client/actions/MessageReactionRemoveEmoji.js +28 -28
  54. package/src/client/actions/MessageUpdate.js +26 -26
  55. package/src/client/actions/PresenceUpdate.js +50 -46
  56. package/src/client/actions/StageInstanceCreate.js +28 -28
  57. package/src/client/actions/StageInstanceDelete.js +33 -33
  58. package/src/client/actions/StageInstanceUpdate.js +30 -30
  59. package/src/client/actions/ThreadCreate.js +24 -24
  60. package/src/client/actions/ThreadDelete.js +32 -32
  61. package/src/client/actions/ThreadListSync.js +59 -59
  62. package/src/client/actions/ThreadMemberUpdate.js +30 -30
  63. package/src/client/actions/ThreadMembersUpdate.js +34 -34
  64. package/src/client/actions/TypingStart.js +29 -29
  65. package/src/client/actions/UserUpdate.js +35 -35
  66. package/src/client/actions/VoiceStateUpdate.js +50 -57
  67. package/src/client/actions/WebhooksUpdate.js +20 -20
  68. package/src/client/voice/ClientVoiceManager.js +151 -51
  69. package/src/client/voice/VoiceConnection.js +1249 -0
  70. package/src/client/voice/dispatcher/AnnexBDispatcher.js +120 -0
  71. package/src/client/voice/dispatcher/AudioDispatcher.js +145 -0
  72. package/src/client/voice/dispatcher/BaseDispatcher.js +459 -0
  73. package/src/client/voice/dispatcher/VPxDispatcher.js +54 -0
  74. package/src/client/voice/dispatcher/VideoDispatcher.js +68 -0
  75. package/src/client/voice/networking/VoiceUDPClient.js +173 -0
  76. package/src/client/voice/networking/VoiceWebSocket.js +286 -0
  77. package/src/client/voice/player/MediaPlayer.js +321 -0
  78. package/src/client/voice/player/processing/AnnexBNalSplitter.js +244 -0
  79. package/src/client/voice/player/processing/IvfSplitter.js +106 -0
  80. package/src/client/voice/player/processing/PCMInsertSilence.js +37 -0
  81. package/src/client/voice/receiver/PacketHandler.js +260 -0
  82. package/src/client/voice/receiver/Receiver.js +96 -0
  83. package/src/client/voice/receiver/Recorder.js +173 -0
  84. package/src/client/voice/util/Function.js +116 -0
  85. package/src/client/voice/util/PlayInterface.js +122 -0
  86. package/src/client/voice/util/Secretbox.js +64 -0
  87. package/src/client/voice/util/Silence.js +16 -0
  88. package/src/client/voice/util/Socket.js +62 -0
  89. package/src/client/voice/util/VolumeInterface.js +104 -0
  90. package/src/client/websocket/WebSocketManager.js +392 -392
  91. package/src/client/websocket/WebSocketShard.js +907 -906
  92. package/src/client/websocket/handlers/APPLICATION_COMMAND_CREATE.js +18 -18
  93. package/src/client/websocket/handlers/APPLICATION_COMMAND_DELETE.js +20 -20
  94. package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.js +5 -5
  95. package/src/client/websocket/handlers/APPLICATION_COMMAND_UPDATE.js +20 -20
  96. package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.js +5 -5
  97. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.js +5 -5
  98. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.js +5 -5
  99. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.js +5 -5
  100. package/src/client/websocket/handlers/CALL_CREATE.js +14 -14
  101. package/src/client/websocket/handlers/CALL_DELETE.js +11 -11
  102. package/src/client/websocket/handlers/CALL_UPDATE.js +11 -11
  103. package/src/client/websocket/handlers/CHANNEL_CREATE.js +5 -5
  104. package/src/client/websocket/handlers/CHANNEL_DELETE.js +5 -5
  105. package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.js +22 -22
  106. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_ADD.js +19 -19
  107. package/src/client/websocket/handlers/CHANNEL_RECIPIENT_REMOVE.js +16 -16
  108. package/src/client/websocket/handlers/CHANNEL_UPDATE.js +16 -16
  109. package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.js +5 -5
  110. package/src/client/websocket/handlers/GUILD_BAN_ADD.js +5 -5
  111. package/src/client/websocket/handlers/GUILD_BAN_REMOVE.js +5 -5
  112. package/src/client/websocket/handlers/GUILD_CREATE.js +52 -52
  113. package/src/client/websocket/handlers/GUILD_DELETE.js +5 -5
  114. package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.js +5 -5
  115. package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.js +5 -5
  116. package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.js +39 -39
  117. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.js +20 -19
  118. package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.js +5 -5
  119. package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.js +5 -5
  120. package/src/client/websocket/handlers/GUILD_ROLE_CREATE.js +5 -5
  121. package/src/client/websocket/handlers/GUILD_ROLE_DELETE.js +5 -5
  122. package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.js +5 -5
  123. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.js +5 -5
  124. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.js +5 -5
  125. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.js +5 -5
  126. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.js +5 -5
  127. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.js +5 -5
  128. package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.js +5 -5
  129. package/src/client/websocket/handlers/GUILD_UPDATE.js +5 -5
  130. package/src/client/websocket/handlers/INTERACTION_MODAL_CREATE.js +12 -12
  131. package/src/client/websocket/handlers/INVITE_CREATE.js +5 -5
  132. package/src/client/websocket/handlers/INVITE_DELETE.js +5 -5
  133. package/src/client/websocket/handlers/MESSAGE_CREATE.js +5 -5
  134. package/src/client/websocket/handlers/MESSAGE_DELETE.js +5 -5
  135. package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.js +5 -5
  136. package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.js +5 -22
  137. package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.js +5 -12
  138. package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.js +5 -5
  139. package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.js +5 -5
  140. package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.js +5 -5
  141. package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.js +5 -5
  142. package/src/client/websocket/handlers/MESSAGE_UPDATE.js +16 -16
  143. package/src/client/websocket/handlers/PRESENCE_UPDATE.js +5 -5
  144. package/src/client/websocket/handlers/READY.js +121 -120
  145. package/src/client/websocket/handlers/RELATIONSHIP_ADD.js +19 -19
  146. package/src/client/websocket/handlers/RELATIONSHIP_REMOVE.js +17 -17
  147. package/src/client/websocket/handlers/RELATIONSHIP_UPDATE.js +41 -41
  148. package/src/client/websocket/handlers/RESUMED.js +14 -14
  149. package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.js +5 -5
  150. package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.js +5 -5
  151. package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.js +5 -5
  152. package/src/client/websocket/handlers/THREAD_CREATE.js +5 -5
  153. package/src/client/websocket/handlers/THREAD_DELETE.js +5 -5
  154. package/src/client/websocket/handlers/THREAD_LIST_SYNC.js +5 -5
  155. package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.js +5 -5
  156. package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.js +5 -5
  157. package/src/client/websocket/handlers/THREAD_UPDATE.js +16 -16
  158. package/src/client/websocket/handlers/TYPING_START.js +5 -5
  159. package/src/client/websocket/handlers/USER_GUILD_SETTINGS_UPDATE.js +6 -6
  160. package/src/client/websocket/handlers/USER_NOTE_UPDATE.js +5 -5
  161. package/src/client/websocket/handlers/USER_REQUIRED_ACTION_UPDATE.js +78 -78
  162. package/src/client/websocket/handlers/USER_SETTINGS_UPDATE.js +5 -5
  163. package/src/client/websocket/handlers/USER_UPDATE.js +5 -5
  164. package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.js +16 -0
  165. package/src/client/websocket/handlers/VOICE_CHANNEL_STATUS_UPDATE.js +12 -12
  166. package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.js +6 -6
  167. package/src/client/websocket/handlers/VOICE_STATE_UPDATE.js +5 -5
  168. package/src/client/websocket/handlers/WEBHOOKS_UPDATE.js +5 -5
  169. package/src/client/websocket/handlers/index.js +84 -83
  170. package/src/errors/DJSError.js +61 -61
  171. package/src/errors/Messages.js +217 -183
  172. package/src/errors/index.js +4 -4
  173. package/src/index.js +172 -159
  174. package/src/managers/ApplicationCommandManager.js +264 -264
  175. package/src/managers/ApplicationCommandPermissionsManager.js +417 -417
  176. package/src/managers/AutoModerationRuleManager.js +296 -296
  177. package/src/managers/BaseGuildEmojiManager.js +80 -80
  178. package/src/managers/BaseManager.js +19 -19
  179. package/src/managers/BillingManager.js +66 -66
  180. package/src/managers/CachedManager.js +71 -71
  181. package/src/managers/ChannelManager.js +148 -138
  182. package/src/managers/ClientUserSettingManager.js +372 -372
  183. package/src/managers/DataManager.js +61 -61
  184. package/src/managers/GuildBanManager.js +250 -250
  185. package/src/managers/GuildChannelManager.js +488 -488
  186. package/src/managers/GuildEmojiManager.js +171 -171
  187. package/src/managers/GuildEmojiRoleManager.js +118 -118
  188. package/src/managers/GuildForumThreadManager.js +108 -108
  189. package/src/managers/GuildInviteManager.js +213 -213
  190. package/src/managers/GuildManager.js +338 -304
  191. package/src/managers/GuildMemberManager.js +599 -597
  192. package/src/managers/GuildMemberRoleManager.js +195 -191
  193. package/src/managers/GuildScheduledEventManager.js +314 -296
  194. package/src/managers/GuildSettingManager.js +155 -155
  195. package/src/managers/GuildStickerManager.js +179 -179
  196. package/src/managers/GuildTextThreadManager.js +98 -98
  197. package/src/managers/InteractionManager.js +39 -39
  198. package/src/managers/MessageManager.js +423 -391
  199. package/src/managers/PermissionOverwriteManager.js +164 -166
  200. package/src/managers/PresenceManager.js +71 -58
  201. package/src/managers/ReactionManager.js +67 -67
  202. package/src/managers/ReactionUserManager.js +73 -71
  203. package/src/managers/RelationshipManager.js +278 -265
  204. package/src/managers/RoleManager.js +448 -352
  205. package/src/managers/SessionManager.js +66 -0
  206. package/src/managers/StageInstanceManager.js +162 -162
  207. package/src/managers/ThreadManager.js +175 -174
  208. package/src/managers/ThreadMemberManager.js +186 -186
  209. package/src/managers/UserManager.js +136 -146
  210. package/src/managers/UserNoteManager.js +53 -53
  211. package/src/managers/VoiceStateManager.js +59 -37
  212. package/src/rest/APIRequest.js +154 -160
  213. package/src/rest/APIRouter.js +53 -53
  214. package/src/rest/DiscordAPIError.js +119 -104
  215. package/src/rest/HTTPError.js +62 -62
  216. package/src/rest/RESTManager.js +67 -62
  217. package/src/rest/RateLimitError.js +55 -55
  218. package/src/rest/RequestHandler.js +466 -444
  219. package/src/sharding/Shard.js +444 -443
  220. package/src/sharding/ShardClientUtil.js +279 -275
  221. package/src/sharding/ShardingManager.js +319 -318
  222. package/src/structures/AnonymousGuild.js +98 -98
  223. package/src/structures/ApplicationCommand.js +593 -593
  224. package/src/structures/ApplicationRoleConnectionMetadata.js +48 -48
  225. package/src/structures/AutoModerationActionExecution.js +89 -89
  226. package/src/structures/AutoModerationRule.js +294 -294
  227. package/src/structures/AutocompleteInteraction.js +107 -107
  228. package/src/structures/Base.js +43 -43
  229. package/src/structures/BaseCommandInteraction.js +211 -211
  230. package/src/structures/BaseGuild.js +116 -116
  231. package/src/structures/BaseGuildEmoji.js +56 -56
  232. package/src/structures/BaseGuildTextChannel.js +191 -191
  233. package/src/structures/BaseGuildVoiceChannel.js +241 -241
  234. package/src/structures/BaseMessageComponent.js +181 -114
  235. package/src/structures/ButtonInteraction.js +11 -11
  236. package/src/structures/CallState.js +63 -63
  237. package/src/structures/CategoryChannel.js +85 -85
  238. package/src/structures/Channel.js +284 -270
  239. package/src/structures/ClientPresence.js +77 -85
  240. package/src/structures/ClientUser.js +479 -448
  241. package/src/structures/CommandInteraction.js +41 -41
  242. package/src/structures/CommandInteractionOptionResolver.js +276 -276
  243. package/src/structures/ContainerComponent.js +68 -0
  244. package/src/structures/ContextMenuInteraction.js +65 -65
  245. package/src/structures/DMChannel.js +219 -217
  246. package/src/structures/DirectoryChannel.js +20 -20
  247. package/src/structures/Emoji.js +148 -148
  248. package/src/structures/FileComponent.js +49 -0
  249. package/src/structures/ForumChannel.js +31 -261
  250. package/src/structures/GroupDMChannel.js +394 -387
  251. package/src/structures/Guild.js +1643 -1608
  252. package/src/structures/GuildAuditLogs.js +746 -729
  253. package/src/structures/GuildBan.js +59 -59
  254. package/src/structures/GuildBoost.js +108 -108
  255. package/src/structures/GuildChannel.js +470 -468
  256. package/src/structures/GuildEmoji.js +161 -161
  257. package/src/structures/GuildMember.js +636 -568
  258. package/src/structures/GuildPreview.js +191 -191
  259. package/src/structures/GuildPreviewEmoji.js +27 -27
  260. package/src/structures/GuildScheduledEvent.js +536 -441
  261. package/src/structures/GuildTemplate.js +236 -236
  262. package/src/structures/Integration.js +188 -188
  263. package/src/structures/IntegrationApplication.js +96 -96
  264. package/src/structures/Interaction.js +290 -290
  265. package/src/structures/InteractionCollector.js +248 -248
  266. package/src/structures/InteractionWebhook.js +43 -43
  267. package/src/structures/Invite.js +358 -358
  268. package/src/structures/InviteGuild.js +23 -23
  269. package/src/structures/InviteStageInstance.js +86 -86
  270. package/src/structures/MediaChannel.js +11 -0
  271. package/src/structures/MediaGalleryComponent.js +41 -0
  272. package/src/structures/MediaGalleryItem.js +47 -0
  273. package/src/structures/Message.js +1252 -1227
  274. package/src/structures/MessageActionRow.js +105 -103
  275. package/src/structures/MessageAttachment.js +216 -204
  276. package/src/structures/MessageButton.js +166 -165
  277. package/src/structures/MessageCollector.js +146 -146
  278. package/src/structures/MessageComponentInteraction.js +120 -120
  279. package/src/structures/MessageContextMenuInteraction.js +20 -20
  280. package/src/structures/MessageEmbed.js +596 -586
  281. package/src/structures/MessageMentions.js +273 -273
  282. package/src/structures/MessagePayload.js +354 -318
  283. package/src/structures/MessageReaction.js +181 -171
  284. package/src/structures/MessageSelectMenu.js +141 -140
  285. package/src/structures/Modal.js +161 -161
  286. package/src/structures/ModalSubmitFieldsResolver.js +53 -53
  287. package/src/structures/ModalSubmitInteraction.js +119 -119
  288. package/src/structures/NewsChannel.js +32 -32
  289. package/src/structures/OAuth2Guild.js +28 -28
  290. package/src/structures/PermissionOverwrites.js +198 -196
  291. package/src/structures/Poll.js +108 -0
  292. package/src/structures/PollAnswer.js +88 -0
  293. package/src/structures/Presence.js +1105 -1101
  294. package/src/structures/ReactionCollector.js +229 -229
  295. package/src/structures/ReactionEmoji.js +31 -31
  296. package/src/structures/Role.js +590 -531
  297. package/src/structures/SectionComponent.js +48 -0
  298. package/src/structures/SelectMenuInteraction.js +21 -21
  299. package/src/structures/SeparatorComponent.js +48 -0
  300. package/src/structures/Session.js +81 -0
  301. package/src/structures/StageChannel.js +104 -104
  302. package/src/structures/StageInstance.js +208 -208
  303. package/src/structures/Sticker.js +310 -310
  304. package/src/structures/StickerPack.js +95 -95
  305. package/src/structures/StoreChannel.js +56 -56
  306. package/src/structures/Team.js +118 -118
  307. package/src/structures/TeamMember.js +80 -71
  308. package/src/structures/TextChannel.js +33 -33
  309. package/src/structures/TextDisplayComponent.js +40 -0
  310. package/src/structures/TextInputComponent.js +132 -131
  311. package/src/structures/ThreadChannel.js +605 -607
  312. package/src/structures/ThreadMember.js +105 -105
  313. package/src/structures/ThreadOnlyChannel.js +249 -0
  314. package/src/structures/ThumbnailComponent.js +57 -0
  315. package/src/structures/Typing.js +74 -74
  316. package/src/structures/UnfurledMediaItem.js +29 -0
  317. package/src/structures/User.js +640 -543
  318. package/src/structures/UserContextMenuInteraction.js +29 -29
  319. package/src/structures/VoiceChannel.js +110 -110
  320. package/src/structures/VoiceChannelEffect.js +69 -0
  321. package/src/structures/VoiceRegion.js +53 -53
  322. package/src/structures/VoiceState.js +354 -341
  323. package/src/structures/WebEmbed.js +373 -373
  324. package/src/structures/Webhook.js +478 -467
  325. package/src/structures/WelcomeChannel.js +60 -60
  326. package/src/structures/WelcomeScreen.js +48 -48
  327. package/src/structures/Widget.js +87 -87
  328. package/src/structures/WidgetMember.js +99 -99
  329. package/src/structures/interfaces/Application.js +825 -313
  330. package/src/structures/interfaces/Collector.js +300 -300
  331. package/src/structures/interfaces/InteractionResponses.js +313 -313
  332. package/src/structures/interfaces/TextBasedChannel.js +759 -719
  333. package/src/util/APITypes.js +59 -0
  334. package/src/util/ActivityFlags.js +44 -44
  335. package/src/util/ApplicationFlags.js +76 -76
  336. package/src/util/AttachmentFlags.js +38 -38
  337. package/src/util/BitField.js +170 -170
  338. package/src/util/ChannelFlags.js +45 -45
  339. package/src/util/Constants.js +1914 -1773
  340. package/src/util/DataResolver.js +146 -145
  341. package/src/util/Formatters.js +228 -228
  342. package/src/util/GuildMemberFlags.js +43 -43
  343. package/src/util/Intents.js +74 -74
  344. package/src/util/InviteFlags.js +34 -29
  345. package/src/util/LimitedCollection.js +131 -131
  346. package/src/util/MessageFlags.js +63 -54
  347. package/src/util/Options.js +358 -336
  348. package/src/util/Permissions.js +202 -202
  349. package/src/util/PremiumUsageFlags.js +31 -31
  350. package/src/util/PurchasedFlags.js +33 -33
  351. package/src/util/RemoteAuth.js +382 -379
  352. package/src/util/RoleFlags.js +37 -37
  353. package/src/util/SnowflakeUtil.js +92 -92
  354. package/src/util/Speaking.js +33 -0
  355. package/src/util/Sweepers.js +466 -466
  356. package/src/util/SystemChannelFlags.js +55 -55
  357. package/src/util/ThreadMemberFlags.js +30 -30
  358. package/src/util/UserFlags.js +104 -104
  359. package/src/util/Util.js +1048 -889
  360. package/typings/enums.d.ts +439 -297
  361. package/typings/index.d.ts +8247 -7432
  362. package/typings/rawDataTypes.d.ts +403 -342
  363. package/src/structures/MessagePoll.js +0 -238
@@ -1,593 +1,593 @@
1
- 'use strict';
2
-
3
- const Base = require('./Base');
4
- const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
5
- const { ApplicationCommandOptionTypes, ApplicationCommandTypes, ChannelTypes } = require('../util/Constants');
6
- const Permissions = require('../util/Permissions');
7
- const SnowflakeUtil = require('../util/SnowflakeUtil');
8
-
9
- /**
10
- * Represents an application command.
11
- * @extends {Base}
12
- */
13
- class ApplicationCommand extends Base {
14
- constructor(client, data, guild, guildId) {
15
- super(client);
16
-
17
- /**
18
- * The command's id
19
- * @type {Snowflake}
20
- */
21
- this.id = data.id;
22
-
23
- /**
24
- * The parent application's id
25
- * @type {Snowflake}
26
- */
27
- this.applicationId = data.application_id;
28
-
29
- /**
30
- * The guild this command is part of
31
- * @type {?Guild}
32
- */
33
- this.guild = guild ?? null;
34
-
35
- /**
36
- * The guild's id this command is part of, this may be non-null when `guild` is `null` if the command
37
- * was fetched from the `ApplicationCommandManager`
38
- * @type {?Snowflake}
39
- */
40
- this.guildId = guild?.id ?? guildId ?? null;
41
-
42
- /**
43
- * The manager for permissions of this command on its guild or arbitrary guilds when the command is global
44
- * @type {ApplicationCommandPermissionsManager}
45
- */
46
- this.permissions = new ApplicationCommandPermissionsManager(this);
47
-
48
- /**
49
- * The type of this application command
50
- * @type {ApplicationCommandType}
51
- */
52
- this.type = ApplicationCommandTypes[data.type];
53
-
54
- this._patch(data);
55
- }
56
-
57
- _patch(data) {
58
- if ('name' in data) {
59
- /**
60
- * The name of this command
61
- * @type {string}
62
- */
63
- this.name = data.name;
64
- }
65
-
66
- if ('name_localizations' in data) {
67
- /**
68
- * The name localizations for this command
69
- * @type {?Object<Locale, string>}
70
- */
71
- this.nameLocalizations = data.name_localizations;
72
- } else {
73
- this.nameLocalizations ??= null;
74
- }
75
-
76
- if ('name_localized' in data) {
77
- /**
78
- * The localized name for this command
79
- * @type {?string}
80
- */
81
- this.nameLocalized = data.name_localized;
82
- } else {
83
- this.nameLocalized ??= null;
84
- }
85
-
86
- if ('description' in data) {
87
- /**
88
- * The description of this command
89
- * @type {string}
90
- */
91
- this.description = data.description;
92
- }
93
-
94
- if ('description_localizations' in data) {
95
- /**
96
- * The description localizations for this command
97
- * @type {?Object<Locale, string>}
98
- */
99
- this.descriptionLocalizations = data.description_localizations;
100
- } else {
101
- this.descriptionLocalizations ??= null;
102
- }
103
-
104
- if ('description_localized' in data) {
105
- /**
106
- * The localized description for this command
107
- * @type {?string}
108
- */
109
- this.descriptionLocalized = data.description_localized;
110
- } else {
111
- this.descriptionLocalized ??= null;
112
- }
113
-
114
- if ('options' in data) {
115
- /**
116
- * The options of this command
117
- * @type {ApplicationCommandOption[]}
118
- */
119
- this.options = data.options.map(o => this.constructor.transformOption(o, true));
120
- } else {
121
- this.options ??= [];
122
- }
123
-
124
- /* eslint-disable max-len */
125
- if ('default_permission' in data) {
126
- /**
127
- * Whether the command is enabled by default when the app is added to a guild
128
- * @type {boolean}
129
- * @deprecated Use {@link ApplicationCommand.defaultMemberPermissions} and {@link ApplicationCommand.dmPermission} instead.
130
- */
131
- this.defaultPermission = data.default_permission;
132
- }
133
- /* eslint-disable max-len */
134
-
135
- if ('default_member_permissions' in data) {
136
- /**
137
- * The default bitfield used to determine whether this command be used in a guild
138
- * @type {?Readonly<Permissions>}
139
- */
140
- this.defaultMemberPermissions = data.default_member_permissions
141
- ? new Permissions(BigInt(data.default_member_permissions)).freeze()
142
- : null;
143
- } else {
144
- this.defaultMemberPermissions ??= null;
145
- }
146
-
147
- if ('dm_permission' in data) {
148
- /**
149
- * Whether the command can be used in DMs
150
- * <info>This property is always `null` on guild commands</info>
151
- * @type {?boolean}
152
- */
153
- this.dmPermission = data.dm_permission;
154
- } else {
155
- this.dmPermission ??= null;
156
- }
157
-
158
- if ('version' in data) {
159
- /**
160
- * Autoincrementing version identifier updated during substantial record changes
161
- * @type {Snowflake}
162
- */
163
- this.version = data.version;
164
- }
165
- }
166
-
167
- /**
168
- * The timestamp the command was created at
169
- * @type {number}
170
- * @readonly
171
- */
172
- get createdTimestamp() {
173
- return SnowflakeUtil.timestampFrom(this.id);
174
- }
175
-
176
- /**
177
- * The time the command was created at
178
- * @type {Date}
179
- * @readonly
180
- */
181
- get createdAt() {
182
- return new Date(this.createdTimestamp);
183
- }
184
-
185
- /**
186
- * The manager that this command belongs to
187
- * @type {ApplicationCommandManager}
188
- * @readonly
189
- */
190
- get manager() {
191
- return (this.guild ?? this.client.application).commands;
192
- }
193
-
194
- /**
195
- * Data for creating or editing an application command.
196
- * @typedef {Object} ApplicationCommandData
197
- * @property {string} name The name of the command
198
- * @property {Object<Locale, string>} [nameLocalizations] The localizations for the command name
199
- * @property {string} description The description of the command
200
- * @property {Object<Locale, string>} [descriptionLocalizations] The localizations for the command description
201
- * @property {ApplicationCommandType} [type] The type of the command
202
- * @property {ApplicationCommandOptionData[]} [options] Options for the command
203
- * @property {boolean} [defaultPermission] Whether the command is enabled by default when the app is added to a guild
204
- * @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions
205
- * a member needs in order to run the command
206
- * @property {boolean} [dmPermission] Whether the command is enabled in DMs
207
- */
208
-
209
- /**
210
- * An option for an application command or subcommand.
211
- * <info>In addition to the listed properties, when used as a parameter,
212
- * API style `snake_case` properties can be used for compatibility with generators like `@discordjs/builders`.</info>
213
- * <warn>Note that providing a value for the `camelCase` counterpart for any `snake_case` property
214
- * will discard the provided `snake_case` property.</warn>
215
- * @typedef {Object} ApplicationCommandOptionData
216
- * @property {ApplicationCommandOptionType|number} type The type of the option
217
- * @property {string} name The name of the option
218
- * @property {Object<Locale, string>} [nameLocalizations] The name localizations for the option
219
- * @property {string} description The description of the option
220
- * @property {Object<Locale, string>} [descriptionLocalizations] The description localizations for the option
221
- * @property {boolean} [autocomplete] Whether the option is an autocomplete option
222
- * @property {boolean} [required] Whether the option is required
223
- * @property {ApplicationCommandOptionChoiceData[]} [choices] The choices of the option for the user to pick from
224
- * @property {ApplicationCommandOptionData[]} [options] Additional options if this option is a subcommand (group)
225
- * @property {ChannelType[]|number[]} [channelTypes] When the option type is channel,
226
- * the allowed types of channels that can be selected
227
- * @property {number} [minValue] The minimum value for an `INTEGER` or `NUMBER` option
228
- * @property {number} [maxValue] The maximum value for an `INTEGER` or `NUMBER` option
229
- * @property {number} [minLength] The minimum length for a `STRING` option
230
- * (maximum of `6000`)
231
- * @property {number} [maxLength] The maximum length for a `STRING` option
232
- * (maximum of `6000`)
233
- */
234
-
235
- /**
236
- * @typedef {Object} ApplicationCommandOptionChoiceData
237
- * @property {string} name The name of the choice
238
- * @property {Object<Locale, string>} [nameLocalizations] The localized names for this choice
239
- * @property {string|number} value The value of the choice
240
- */
241
-
242
- /**
243
- * Edits this application command.
244
- * @param {Partial<ApplicationCommandData>} data The data to update the command with
245
- * @returns {Promise<ApplicationCommand>}
246
- * @example
247
- * // Edit the description of this command
248
- * command.edit({
249
- * description: 'New description',
250
- * })
251
- * .then(console.log)
252
- * .catch(console.error);
253
- */
254
- edit(data) {
255
- return this.manager.edit(this, data, this.guildId);
256
- }
257
-
258
- /**
259
- * Edits the name of this ApplicationCommand
260
- * @param {string} name The new name of the command
261
- * @returns {Promise<ApplicationCommand>}
262
- */
263
- setName(name) {
264
- return this.edit({ name });
265
- }
266
-
267
- /**
268
- * Edits the localized names of this ApplicationCommand
269
- * @param {Object<Locale, string>} nameLocalizations The new localized names for the command
270
- * @returns {Promise<ApplicationCommand>}
271
- * @example
272
- * // Edit the name localizations of this command
273
- * command.setLocalizedNames({
274
- * 'en-GB': 'test',
275
- * 'pt-BR': 'teste',
276
- * })
277
- * .then(console.log)
278
- * .catch(console.error)
279
- */
280
- setNameLocalizations(nameLocalizations) {
281
- return this.edit({ nameLocalizations });
282
- }
283
-
284
- /**
285
- * Edits the description of this ApplicationCommand
286
- * @param {string} description The new description of the command
287
- * @returns {Promise<ApplicationCommand>}
288
- */
289
- setDescription(description) {
290
- return this.edit({ description });
291
- }
292
-
293
- /**
294
- * Edits the localized descriptions of this ApplicationCommand
295
- * @param {Object<Locale, string>} descriptionLocalizations The new localized descriptions for the command
296
- * @returns {Promise<ApplicationCommand>}
297
- * @example
298
- * // Edit the description localizations of this command
299
- * command.setLocalizedDescriptions({
300
- * 'en-GB': 'A test command',
301
- * 'pt-BR': 'Um comando de teste',
302
- * })
303
- * .then(console.log)
304
- * .catch(console.error)
305
- */
306
- setDescriptionLocalizations(descriptionLocalizations) {
307
- return this.edit({ descriptionLocalizations });
308
- }
309
-
310
- /* eslint-disable max-len */
311
- /**
312
- * Edits the default permission of this ApplicationCommand
313
- * @param {boolean} [defaultPermission=true] The default permission for this command
314
- * @returns {Promise<ApplicationCommand>}
315
- * @deprecated Use {@link ApplicationCommand#setDefaultMemberPermissions} and {@link ApplicationCommand#setDMPermission} instead.
316
- */
317
- setDefaultPermission(defaultPermission = true) {
318
- return this.edit({ defaultPermission });
319
- }
320
- /* eslint-enable max-len */
321
-
322
- /**
323
- * Edits the default member permissions of this ApplicationCommand
324
- * @param {?PermissionResolvable} defaultMemberPermissions The default member permissions required to run this command
325
- * @returns {Promise<ApplicationCommand>}
326
- */
327
- setDefaultMemberPermissions(defaultMemberPermissions) {
328
- return this.edit({ defaultMemberPermissions });
329
- }
330
-
331
- /**
332
- * Edits the DM permission of this ApplicationCommand
333
- * @param {boolean} [dmPermission=true] Whether the command can be used in DMs
334
- * @returns {Promise<ApplicationCommand>}
335
- */
336
- setDMPermission(dmPermission = true) {
337
- return this.edit({ dmPermission });
338
- }
339
-
340
- /**
341
- * Edits the options of this ApplicationCommand
342
- * @param {ApplicationCommandOptionData[]} options The options to set for this command
343
- * @returns {Promise<ApplicationCommand>}
344
- */
345
- setOptions(options) {
346
- return this.edit({ options });
347
- }
348
-
349
- /**
350
- * Deletes this command.
351
- * @returns {Promise<ApplicationCommand>}
352
- * @example
353
- * // Delete this command
354
- * command.delete()
355
- * .then(console.log)
356
- * .catch(console.error);
357
- */
358
- delete() {
359
- return this.manager.delete(this, this.guildId);
360
- }
361
-
362
- /**
363
- * Whether this command equals another command. It compares all properties, so for most operations
364
- * it is advisable to just compare `command.id === command2.id` as it is much faster and is often
365
- * what most users need.
366
- * @param {ApplicationCommand|ApplicationCommandData|APIApplicationCommand} command The command to compare with
367
- * @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options and choices are in the same
368
- * order in the array <info>The client may not always respect this ordering!</info>
369
- * @returns {boolean}
370
- */
371
- equals(command, enforceOptionOrder = false) {
372
- // If given an id, check if the id matches
373
- if (command.id && this.id !== command.id) return false;
374
-
375
- let defaultMemberPermissions = null;
376
- let dmPermission = command.dmPermission ?? command.dm_permission;
377
-
378
- if ('default_member_permissions' in command) {
379
- defaultMemberPermissions = command.default_member_permissions
380
- ? new Permissions(BigInt(command.default_member_permissions)).bitfield
381
- : null;
382
- }
383
-
384
- if ('defaultMemberPermissions' in command) {
385
- defaultMemberPermissions =
386
- command.defaultMemberPermissions !== null ? new Permissions(command.defaultMemberPermissions).bitfield : null;
387
- }
388
-
389
- // Check top level parameters
390
- const commandType = typeof command.type === 'string' ? command.type : ApplicationCommandTypes[command.type];
391
- if (
392
- command.name !== this.name ||
393
- ('description' in command && command.description !== this.description) ||
394
- ('version' in command && command.version !== this.version) ||
395
- ('autocomplete' in command && command.autocomplete !== this.autocomplete) ||
396
- (commandType && commandType !== this.type) ||
397
- defaultMemberPermissions !== (this.defaultMemberPermissions?.bitfield ?? null) ||
398
- (typeof dmPermission !== 'undefined' && dmPermission !== this.dmPermission) ||
399
- // Future proof for options being nullable
400
- // TODO: remove ?? 0 on each when nullable
401
- (command.options?.length ?? 0) !== (this.options?.length ?? 0) ||
402
- (command.defaultPermission ?? command.default_permission ?? true) !== this.defaultPermission
403
- ) {
404
- return false;
405
- }
406
-
407
- if (command.options) {
408
- return this.constructor.optionsEqual(this.options, command.options, enforceOptionOrder);
409
- }
410
- return true;
411
- }
412
-
413
- /**
414
- * Recursively checks that all options for an {@link ApplicationCommand} are equal to the provided options.
415
- * In most cases it is better to compare using {@link ApplicationCommand#equals}
416
- * @param {ApplicationCommandOptionData[]} existing The options on the existing command,
417
- * should be {@link ApplicationCommand#options}
418
- * @param {ApplicationCommandOptionData[]|APIApplicationCommandOption[]} options The options to compare against
419
- * @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options and choices are in the same
420
- * order in the array <info>The client may not always respect this ordering!</info>
421
- * @returns {boolean}
422
- */
423
- static optionsEqual(existing, options, enforceOptionOrder = false) {
424
- if (existing.length !== options.length) return false;
425
- if (enforceOptionOrder) {
426
- return existing.every((option, index) => this._optionEquals(option, options[index], enforceOptionOrder));
427
- }
428
- const newOptions = new Map(options.map(option => [option.name, option]));
429
- for (const option of existing) {
430
- const foundOption = newOptions.get(option.name);
431
- if (!foundOption || !this._optionEquals(option, foundOption)) return false;
432
- }
433
- return true;
434
- }
435
-
436
- /**
437
- * Checks that an option for an {@link ApplicationCommand} is equal to the provided option
438
- * In most cases it is better to compare using {@link ApplicationCommand#equals}
439
- * @param {ApplicationCommandOptionData} existing The option on the existing command,
440
- * should be from {@link ApplicationCommand#options}
441
- * @param {ApplicationCommandOptionData|APIApplicationCommandOption} option The option to compare against
442
- * @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options or choices are in the same
443
- * order in their array <info>The client may not always respect this ordering!</info>
444
- * @returns {boolean}
445
- * @private
446
- */
447
- static _optionEquals(existing, option, enforceOptionOrder = false) {
448
- const optionType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionTypes[option.type];
449
- if (
450
- option.name !== existing.name ||
451
- optionType !== existing.type ||
452
- option.description !== existing.description ||
453
- option.autocomplete !== existing.autocomplete ||
454
- (option.required ?? (['SUB_COMMAND', 'SUB_COMMAND_GROUP'].includes(optionType) ? undefined : false)) !==
455
- existing.required ||
456
- option.choices?.length !== existing.choices?.length ||
457
- option.options?.length !== existing.options?.length ||
458
- (option.channelTypes ?? option.channel_types)?.length !== existing.channelTypes?.length ||
459
- (option.minValue ?? option.min_value) !== existing.minValue ||
460
- (option.maxValue ?? option.max_value) !== existing.maxValue ||
461
- (option.minLength ?? option.min_length) !== existing.minLength ||
462
- (option.maxLength ?? option.max_length) !== existing.maxLength
463
- ) {
464
- return false;
465
- }
466
-
467
- if (existing.choices) {
468
- if (
469
- enforceOptionOrder &&
470
- !existing.choices.every(
471
- (choice, index) => choice.name === option.choices[index].name && choice.value === option.choices[index].value,
472
- )
473
- ) {
474
- return false;
475
- }
476
- if (!enforceOptionOrder) {
477
- const newChoices = new Map(option.choices.map(choice => [choice.name, choice]));
478
- for (const choice of existing.choices) {
479
- const foundChoice = newChoices.get(choice.name);
480
- if (!foundChoice || foundChoice.value !== choice.value) return false;
481
- }
482
- }
483
- }
484
-
485
- if (existing.channelTypes) {
486
- const newTypes = (option.channelTypes ?? option.channel_types).map(type =>
487
- typeof type === 'number' ? ChannelTypes[type] : type,
488
- );
489
- for (const type of existing.channelTypes) {
490
- if (!newTypes.includes(type)) return false;
491
- }
492
- }
493
-
494
- if (existing.options) {
495
- return this.optionsEqual(existing.options, option.options, enforceOptionOrder);
496
- }
497
- return true;
498
- }
499
-
500
- /**
501
- * An option for an application command or subcommand.
502
- * @typedef {Object} ApplicationCommandOption
503
- * @property {ApplicationCommandOptionType} type The type of the option
504
- * @property {string} name The name of the option
505
- * @property {Object<string, string>} [nameLocalizations] The localizations for the option name
506
- * @property {string} [nameLocalized] The localized name for this option
507
- * @property {string} description The description of the option
508
- * @property {Object<string, string>} [descriptionLocalizations] The localizations for the option description
509
- * @property {string} [descriptionLocalized] The localized description for this option
510
- * @property {boolean} [required] Whether the option is required
511
- * @property {boolean} [autocomplete] Whether the option is an autocomplete option
512
- * @property {ApplicationCommandOptionChoice[]} [choices] The choices of the option for the user to pick from
513
- * @property {ApplicationCommandOption[]} [options] Additional options if this option is a subcommand (group)
514
- * @property {ChannelType[]} [channelTypes] When the option type is channel,
515
- * the allowed types of channels that can be selected
516
- * @property {number} [minValue] The minimum value for an `INTEGER` or `NUMBER` option
517
- * @property {number} [maxValue] The maximum value for an `INTEGER` or `NUMBER` option
518
- * @property {number} [minLength] The minimum length for a `STRING` option
519
- * (maximum of `6000`)
520
- * @property {number} [maxLength] The maximum length for a `STRING` option
521
- * (maximum of `6000`)
522
- */
523
-
524
- /**
525
- * A choice for an application command option.
526
- * @typedef {Object} ApplicationCommandOptionChoice
527
- * @property {string} name The name of the choice
528
- * @property {?string} nameLocalized The localized name of the choice in the provided locale, if any
529
- * @property {?Object<string, string>} [nameLocalizations] The localized names for this choice
530
- * @property {string|number} value The value of the choice
531
- */
532
-
533
- /**
534
- * Transforms an {@link ApplicationCommandOptionData} object into something that can be used with the API.
535
- * @param {ApplicationCommandOptionData|ApplicationCommandOption} option The option to transform
536
- * @param {boolean} [received] Whether this option has been received from Discord
537
- * @returns {APIApplicationCommandOption}
538
- * @private
539
- */
540
- static transformOption(option, received) {
541
- const stringType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionTypes[option.type];
542
- const channelTypesKey = received ? 'channelTypes' : 'channel_types';
543
- const minValueKey = received ? 'minValue' : 'min_value';
544
- const maxValueKey = received ? 'maxValue' : 'max_value';
545
- const minLengthKey = received ? 'minLength' : 'min_length';
546
- const maxLengthKey = received ? 'maxLength' : 'max_length';
547
- const nameLocalizationsKey = received ? 'nameLocalizations' : 'name_localizations';
548
- const nameLocalizedKey = received ? 'nameLocalized' : 'name_localized';
549
- const descriptionLocalizationsKey = received ? 'descriptionLocalizations' : 'description_localizations';
550
- const descriptionLocalizedKey = received ? 'descriptionLocalized' : 'description_localized';
551
- return {
552
- type: typeof option.type === 'number' && !received ? option.type : ApplicationCommandOptionTypes[option.type],
553
- name: option.name,
554
- [nameLocalizationsKey]: option.nameLocalizations ?? option.name_localizations,
555
- [nameLocalizedKey]: option.nameLocalized ?? option.name_localized,
556
- description: option.description,
557
- [descriptionLocalizationsKey]: option.descriptionLocalizations ?? option.description_localizations,
558
- [descriptionLocalizedKey]: option.descriptionLocalized ?? option.description_localized,
559
- required:
560
- option.required ?? (stringType === 'SUB_COMMAND' || stringType === 'SUB_COMMAND_GROUP' ? undefined : false),
561
- autocomplete: option.autocomplete,
562
- choices: option.choices?.map(choice => ({
563
- name: choice.name,
564
- [nameLocalizedKey]: choice.nameLocalized ?? choice.name_localized,
565
- [nameLocalizationsKey]: choice.nameLocalizations ?? choice.name_localizations,
566
- value: choice.value,
567
- })),
568
- options: option.options?.map(o => this.transformOption(o, received)),
569
- [channelTypesKey]: received
570
- ? option.channel_types?.map(type => ChannelTypes[type])
571
- : option.channelTypes?.map(type => (typeof type === 'string' ? ChannelTypes[type] : type)) ??
572
- // When transforming to API data, accept API data
573
- option.channel_types,
574
- [minValueKey]: option.minValue ?? option.min_value,
575
- [maxValueKey]: option.maxValue ?? option.max_value,
576
- [minLengthKey]: option.minLength ?? option.min_length,
577
- [maxLengthKey]: option.maxLength ?? option.max_length,
578
- };
579
- }
580
- }
581
-
582
- module.exports = ApplicationCommand;
583
-
584
- /* eslint-disable max-len */
585
- /**
586
- * @external APIApplicationCommand
587
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure}
588
- */
589
-
590
- /**
591
- * @external APIApplicationCommandOption
592
- * @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure}
593
- */
1
+ 'use strict';
2
+
3
+ const Base = require('./Base');
4
+ const ApplicationCommandPermissionsManager = require('../managers/ApplicationCommandPermissionsManager');
5
+ const { ApplicationCommandOptionTypes, ApplicationCommandTypes, ChannelTypes } = require('../util/Constants');
6
+ const Permissions = require('../util/Permissions');
7
+ const SnowflakeUtil = require('../util/SnowflakeUtil');
8
+
9
+ /**
10
+ * Represents an application command.
11
+ * @extends {Base}
12
+ */
13
+ class ApplicationCommand extends Base {
14
+ constructor(client, data, guild, guildId) {
15
+ super(client);
16
+
17
+ /**
18
+ * The command's id
19
+ * @type {Snowflake}
20
+ */
21
+ this.id = data.id;
22
+
23
+ /**
24
+ * The parent application's id
25
+ * @type {Snowflake}
26
+ */
27
+ this.applicationId = data.application_id;
28
+
29
+ /**
30
+ * The guild this command is part of
31
+ * @type {?Guild}
32
+ */
33
+ this.guild = guild ?? null;
34
+
35
+ /**
36
+ * The guild's id this command is part of, this may be non-null when `guild` is `null` if the command
37
+ * was fetched from the `ApplicationCommandManager`
38
+ * @type {?Snowflake}
39
+ */
40
+ this.guildId = guild?.id ?? guildId ?? null;
41
+
42
+ /**
43
+ * The manager for permissions of this command on its guild or arbitrary guilds when the command is global
44
+ * @type {ApplicationCommandPermissionsManager}
45
+ */
46
+ this.permissions = new ApplicationCommandPermissionsManager(this);
47
+
48
+ /**
49
+ * The type of this application command
50
+ * @type {ApplicationCommandType}
51
+ */
52
+ this.type = ApplicationCommandTypes[data.type];
53
+
54
+ this._patch(data);
55
+ }
56
+
57
+ _patch(data) {
58
+ if ('name' in data) {
59
+ /**
60
+ * The name of this command
61
+ * @type {string}
62
+ */
63
+ this.name = data.name;
64
+ }
65
+
66
+ if ('name_localizations' in data) {
67
+ /**
68
+ * The name localizations for this command
69
+ * @type {?Object<Locale, string>}
70
+ */
71
+ this.nameLocalizations = data.name_localizations;
72
+ } else {
73
+ this.nameLocalizations ??= null;
74
+ }
75
+
76
+ if ('name_localized' in data) {
77
+ /**
78
+ * The localized name for this command
79
+ * @type {?string}
80
+ */
81
+ this.nameLocalized = data.name_localized;
82
+ } else {
83
+ this.nameLocalized ??= null;
84
+ }
85
+
86
+ if ('description' in data) {
87
+ /**
88
+ * The description of this command
89
+ * @type {string}
90
+ */
91
+ this.description = data.description;
92
+ }
93
+
94
+ if ('description_localizations' in data) {
95
+ /**
96
+ * The description localizations for this command
97
+ * @type {?Object<Locale, string>}
98
+ */
99
+ this.descriptionLocalizations = data.description_localizations;
100
+ } else {
101
+ this.descriptionLocalizations ??= null;
102
+ }
103
+
104
+ if ('description_localized' in data) {
105
+ /**
106
+ * The localized description for this command
107
+ * @type {?string}
108
+ */
109
+ this.descriptionLocalized = data.description_localized;
110
+ } else {
111
+ this.descriptionLocalized ??= null;
112
+ }
113
+
114
+ if ('options' in data) {
115
+ /**
116
+ * The options of this command
117
+ * @type {ApplicationCommandOption[]}
118
+ */
119
+ this.options = data.options.map(o => this.constructor.transformOption(o, true));
120
+ } else {
121
+ this.options ??= [];
122
+ }
123
+
124
+ /* eslint-disable max-len */
125
+ if ('default_permission' in data) {
126
+ /**
127
+ * Whether the command is enabled by default when the app is added to a guild
128
+ * @type {boolean}
129
+ * @deprecated Use {@link ApplicationCommand.defaultMemberPermissions} and {@link ApplicationCommand.dmPermission} instead.
130
+ */
131
+ this.defaultPermission = data.default_permission;
132
+ }
133
+ /* eslint-disable max-len */
134
+
135
+ if ('default_member_permissions' in data) {
136
+ /**
137
+ * The default bitfield used to determine whether this command be used in a guild
138
+ * @type {?Readonly<Permissions>}
139
+ */
140
+ this.defaultMemberPermissions = data.default_member_permissions
141
+ ? new Permissions(BigInt(data.default_member_permissions)).freeze()
142
+ : null;
143
+ } else {
144
+ this.defaultMemberPermissions ??= null;
145
+ }
146
+
147
+ if ('dm_permission' in data) {
148
+ /**
149
+ * Whether the command can be used in DMs
150
+ * <info>This property is always `null` on guild commands</info>
151
+ * @type {?boolean}
152
+ */
153
+ this.dmPermission = data.dm_permission;
154
+ } else {
155
+ this.dmPermission ??= null;
156
+ }
157
+
158
+ if ('version' in data) {
159
+ /**
160
+ * Autoincrementing version identifier updated during substantial record changes
161
+ * @type {Snowflake}
162
+ */
163
+ this.version = data.version;
164
+ }
165
+ }
166
+
167
+ /**
168
+ * The timestamp the command was created at
169
+ * @type {number}
170
+ * @readonly
171
+ */
172
+ get createdTimestamp() {
173
+ return SnowflakeUtil.timestampFrom(this.id);
174
+ }
175
+
176
+ /**
177
+ * The time the command was created at
178
+ * @type {Date}
179
+ * @readonly
180
+ */
181
+ get createdAt() {
182
+ return new Date(this.createdTimestamp);
183
+ }
184
+
185
+ /**
186
+ * The manager that this command belongs to
187
+ * @type {ApplicationCommandManager}
188
+ * @readonly
189
+ */
190
+ get manager() {
191
+ return (this.guild ?? this.client.application).commands;
192
+ }
193
+
194
+ /**
195
+ * Data for creating or editing an application command.
196
+ * @typedef {Object} ApplicationCommandData
197
+ * @property {string} name The name of the command
198
+ * @property {Object<Locale, string>} [nameLocalizations] The localizations for the command name
199
+ * @property {string} description The description of the command
200
+ * @property {Object<Locale, string>} [descriptionLocalizations] The localizations for the command description
201
+ * @property {ApplicationCommandType} [type] The type of the command
202
+ * @property {ApplicationCommandOptionData[]} [options] Options for the command
203
+ * @property {boolean} [defaultPermission] Whether the command is enabled by default when the app is added to a guild
204
+ * @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions
205
+ * a member needs in order to run the command
206
+ * @property {boolean} [dmPermission] Whether the command is enabled in DMs
207
+ */
208
+
209
+ /**
210
+ * An option for an application command or subcommand.
211
+ * <info>In addition to the listed properties, when used as a parameter,
212
+ * API style `snake_case` properties can be used for compatibility with generators like `@discordjs/builders`.</info>
213
+ * <warn>Note that providing a value for the `camelCase` counterpart for any `snake_case` property
214
+ * will discard the provided `snake_case` property.</warn>
215
+ * @typedef {Object} ApplicationCommandOptionData
216
+ * @property {ApplicationCommandOptionType|number} type The type of the option
217
+ * @property {string} name The name of the option
218
+ * @property {Object<Locale, string>} [nameLocalizations] The name localizations for the option
219
+ * @property {string} description The description of the option
220
+ * @property {Object<Locale, string>} [descriptionLocalizations] The description localizations for the option
221
+ * @property {boolean} [autocomplete] Whether the option is an autocomplete option
222
+ * @property {boolean} [required] Whether the option is required
223
+ * @property {ApplicationCommandOptionChoiceData[]} [choices] The choices of the option for the user to pick from
224
+ * @property {ApplicationCommandOptionData[]} [options] Additional options if this option is a subcommand (group)
225
+ * @property {ChannelType[]|number[]} [channelTypes] When the option type is channel,
226
+ * the allowed types of channels that can be selected
227
+ * @property {number} [minValue] The minimum value for an `INTEGER` or `NUMBER` option
228
+ * @property {number} [maxValue] The maximum value for an `INTEGER` or `NUMBER` option
229
+ * @property {number} [minLength] The minimum length for a `STRING` option
230
+ * (maximum of `6000`)
231
+ * @property {number} [maxLength] The maximum length for a `STRING` option
232
+ * (maximum of `6000`)
233
+ */
234
+
235
+ /**
236
+ * @typedef {Object} ApplicationCommandOptionChoiceData
237
+ * @property {string} name The name of the choice
238
+ * @property {Object<Locale, string>} [nameLocalizations] The localized names for this choice
239
+ * @property {string|number} value The value of the choice
240
+ */
241
+
242
+ /**
243
+ * Edits this application command.
244
+ * @param {Partial<ApplicationCommandData>} data The data to update the command with
245
+ * @returns {Promise<ApplicationCommand>}
246
+ * @example
247
+ * // Edit the description of this command
248
+ * command.edit({
249
+ * description: 'New description',
250
+ * })
251
+ * .then(console.log)
252
+ * .catch(console.error);
253
+ */
254
+ edit(data) {
255
+ return this.manager.edit(this, data, this.guildId);
256
+ }
257
+
258
+ /**
259
+ * Edits the name of this ApplicationCommand
260
+ * @param {string} name The new name of the command
261
+ * @returns {Promise<ApplicationCommand>}
262
+ */
263
+ setName(name) {
264
+ return this.edit({ name });
265
+ }
266
+
267
+ /**
268
+ * Edits the localized names of this ApplicationCommand
269
+ * @param {Object<Locale, string>} nameLocalizations The new localized names for the command
270
+ * @returns {Promise<ApplicationCommand>}
271
+ * @example
272
+ * // Edit the name localizations of this command
273
+ * command.setLocalizedNames({
274
+ * 'en-GB': 'test',
275
+ * 'pt-BR': 'teste',
276
+ * })
277
+ * .then(console.log)
278
+ * .catch(console.error)
279
+ */
280
+ setNameLocalizations(nameLocalizations) {
281
+ return this.edit({ nameLocalizations });
282
+ }
283
+
284
+ /**
285
+ * Edits the description of this ApplicationCommand
286
+ * @param {string} description The new description of the command
287
+ * @returns {Promise<ApplicationCommand>}
288
+ */
289
+ setDescription(description) {
290
+ return this.edit({ description });
291
+ }
292
+
293
+ /**
294
+ * Edits the localized descriptions of this ApplicationCommand
295
+ * @param {Object<Locale, string>} descriptionLocalizations The new localized descriptions for the command
296
+ * @returns {Promise<ApplicationCommand>}
297
+ * @example
298
+ * // Edit the description localizations of this command
299
+ * command.setLocalizedDescriptions({
300
+ * 'en-GB': 'A test command',
301
+ * 'pt-BR': 'Um comando de teste',
302
+ * })
303
+ * .then(console.log)
304
+ * .catch(console.error)
305
+ */
306
+ setDescriptionLocalizations(descriptionLocalizations) {
307
+ return this.edit({ descriptionLocalizations });
308
+ }
309
+
310
+ /* eslint-disable max-len */
311
+ /**
312
+ * Edits the default permission of this ApplicationCommand
313
+ * @param {boolean} [defaultPermission=true] The default permission for this command
314
+ * @returns {Promise<ApplicationCommand>}
315
+ * @deprecated Use {@link ApplicationCommand#setDefaultMemberPermissions} and {@link ApplicationCommand#setDMPermission} instead.
316
+ */
317
+ setDefaultPermission(defaultPermission = true) {
318
+ return this.edit({ defaultPermission });
319
+ }
320
+ /* eslint-enable max-len */
321
+
322
+ /**
323
+ * Edits the default member permissions of this ApplicationCommand
324
+ * @param {?PermissionResolvable} defaultMemberPermissions The default member permissions required to run this command
325
+ * @returns {Promise<ApplicationCommand>}
326
+ */
327
+ setDefaultMemberPermissions(defaultMemberPermissions) {
328
+ return this.edit({ defaultMemberPermissions });
329
+ }
330
+
331
+ /**
332
+ * Edits the DM permission of this ApplicationCommand
333
+ * @param {boolean} [dmPermission=true] Whether the command can be used in DMs
334
+ * @returns {Promise<ApplicationCommand>}
335
+ */
336
+ setDMPermission(dmPermission = true) {
337
+ return this.edit({ dmPermission });
338
+ }
339
+
340
+ /**
341
+ * Edits the options of this ApplicationCommand
342
+ * @param {ApplicationCommandOptionData[]} options The options to set for this command
343
+ * @returns {Promise<ApplicationCommand>}
344
+ */
345
+ setOptions(options) {
346
+ return this.edit({ options });
347
+ }
348
+
349
+ /**
350
+ * Deletes this command.
351
+ * @returns {Promise<ApplicationCommand>}
352
+ * @example
353
+ * // Delete this command
354
+ * command.delete()
355
+ * .then(console.log)
356
+ * .catch(console.error);
357
+ */
358
+ delete() {
359
+ return this.manager.delete(this, this.guildId);
360
+ }
361
+
362
+ /**
363
+ * Whether this command equals another command. It compares all properties, so for most operations
364
+ * it is advisable to just compare `command.id === command2.id` as it is much faster and is often
365
+ * what most users need.
366
+ * @param {ApplicationCommand|ApplicationCommandData|APIApplicationCommand} command The command to compare with
367
+ * @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options and choices are in the same
368
+ * order in the array <info>The client may not always respect this ordering!</info>
369
+ * @returns {boolean}
370
+ */
371
+ equals(command, enforceOptionOrder = false) {
372
+ // If given an id, check if the id matches
373
+ if (command.id && this.id !== command.id) return false;
374
+
375
+ let defaultMemberPermissions = null;
376
+ let dmPermission = command.dmPermission ?? command.dm_permission;
377
+
378
+ if ('default_member_permissions' in command) {
379
+ defaultMemberPermissions = command.default_member_permissions
380
+ ? new Permissions(BigInt(command.default_member_permissions)).bitfield
381
+ : null;
382
+ }
383
+
384
+ if ('defaultMemberPermissions' in command) {
385
+ defaultMemberPermissions =
386
+ command.defaultMemberPermissions !== null ? new Permissions(command.defaultMemberPermissions).bitfield : null;
387
+ }
388
+
389
+ // Check top level parameters
390
+ const commandType = typeof command.type === 'string' ? command.type : ApplicationCommandTypes[command.type];
391
+ if (
392
+ command.name !== this.name ||
393
+ ('description' in command && command.description !== this.description) ||
394
+ ('version' in command && command.version !== this.version) ||
395
+ ('autocomplete' in command && command.autocomplete !== this.autocomplete) ||
396
+ (commandType && commandType !== this.type) ||
397
+ defaultMemberPermissions !== (this.defaultMemberPermissions?.bitfield ?? null) ||
398
+ (typeof dmPermission !== 'undefined' && dmPermission !== this.dmPermission) ||
399
+ // Future proof for options being nullable
400
+ // TODO: remove ?? 0 on each when nullable
401
+ (command.options?.length ?? 0) !== (this.options?.length ?? 0) ||
402
+ (command.defaultPermission ?? command.default_permission ?? true) !== this.defaultPermission
403
+ ) {
404
+ return false;
405
+ }
406
+
407
+ if (command.options) {
408
+ return this.constructor.optionsEqual(this.options, command.options, enforceOptionOrder);
409
+ }
410
+ return true;
411
+ }
412
+
413
+ /**
414
+ * Recursively checks that all options for an {@link ApplicationCommand} are equal to the provided options.
415
+ * In most cases it is better to compare using {@link ApplicationCommand#equals}
416
+ * @param {ApplicationCommandOptionData[]} existing The options on the existing command,
417
+ * should be {@link ApplicationCommand#options}
418
+ * @param {ApplicationCommandOptionData[]|APIApplicationCommandOption[]} options The options to compare against
419
+ * @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options and choices are in the same
420
+ * order in the array <info>The client may not always respect this ordering!</info>
421
+ * @returns {boolean}
422
+ */
423
+ static optionsEqual(existing, options, enforceOptionOrder = false) {
424
+ if (existing.length !== options.length) return false;
425
+ if (enforceOptionOrder) {
426
+ return existing.every((option, index) => this._optionEquals(option, options[index], enforceOptionOrder));
427
+ }
428
+ const newOptions = new Map(options.map(option => [option.name, option]));
429
+ for (const option of existing) {
430
+ const foundOption = newOptions.get(option.name);
431
+ if (!foundOption || !this._optionEquals(option, foundOption)) return false;
432
+ }
433
+ return true;
434
+ }
435
+
436
+ /**
437
+ * Checks that an option for an {@link ApplicationCommand} is equal to the provided option
438
+ * In most cases it is better to compare using {@link ApplicationCommand#equals}
439
+ * @param {ApplicationCommandOptionData} existing The option on the existing command,
440
+ * should be from {@link ApplicationCommand#options}
441
+ * @param {ApplicationCommandOptionData|APIApplicationCommandOption} option The option to compare against
442
+ * @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options or choices are in the same
443
+ * order in their array <info>The client may not always respect this ordering!</info>
444
+ * @returns {boolean}
445
+ * @private
446
+ */
447
+ static _optionEquals(existing, option, enforceOptionOrder = false) {
448
+ const optionType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionTypes[option.type];
449
+ if (
450
+ option.name !== existing.name ||
451
+ optionType !== existing.type ||
452
+ option.description !== existing.description ||
453
+ option.autocomplete !== existing.autocomplete ||
454
+ (option.required ?? (['SUB_COMMAND', 'SUB_COMMAND_GROUP'].includes(optionType) ? undefined : false)) !==
455
+ existing.required ||
456
+ option.choices?.length !== existing.choices?.length ||
457
+ option.options?.length !== existing.options?.length ||
458
+ (option.channelTypes ?? option.channel_types)?.length !== existing.channelTypes?.length ||
459
+ (option.minValue ?? option.min_value) !== existing.minValue ||
460
+ (option.maxValue ?? option.max_value) !== existing.maxValue ||
461
+ (option.minLength ?? option.min_length) !== existing.minLength ||
462
+ (option.maxLength ?? option.max_length) !== existing.maxLength
463
+ ) {
464
+ return false;
465
+ }
466
+
467
+ if (existing.choices) {
468
+ if (
469
+ enforceOptionOrder &&
470
+ !existing.choices.every(
471
+ (choice, index) => choice.name === option.choices[index].name && choice.value === option.choices[index].value,
472
+ )
473
+ ) {
474
+ return false;
475
+ }
476
+ if (!enforceOptionOrder) {
477
+ const newChoices = new Map(option.choices.map(choice => [choice.name, choice]));
478
+ for (const choice of existing.choices) {
479
+ const foundChoice = newChoices.get(choice.name);
480
+ if (!foundChoice || foundChoice.value !== choice.value) return false;
481
+ }
482
+ }
483
+ }
484
+
485
+ if (existing.channelTypes) {
486
+ const newTypes = (option.channelTypes ?? option.channel_types).map(type =>
487
+ typeof type === 'number' ? ChannelTypes[type] : type,
488
+ );
489
+ for (const type of existing.channelTypes) {
490
+ if (!newTypes.includes(type)) return false;
491
+ }
492
+ }
493
+
494
+ if (existing.options) {
495
+ return this.optionsEqual(existing.options, option.options, enforceOptionOrder);
496
+ }
497
+ return true;
498
+ }
499
+
500
+ /**
501
+ * An option for an application command or subcommand.
502
+ * @typedef {Object} ApplicationCommandOption
503
+ * @property {ApplicationCommandOptionType} type The type of the option
504
+ * @property {string} name The name of the option
505
+ * @property {Object<string, string>} [nameLocalizations] The localizations for the option name
506
+ * @property {string} [nameLocalized] The localized name for this option
507
+ * @property {string} description The description of the option
508
+ * @property {Object<string, string>} [descriptionLocalizations] The localizations for the option description
509
+ * @property {string} [descriptionLocalized] The localized description for this option
510
+ * @property {boolean} [required] Whether the option is required
511
+ * @property {boolean} [autocomplete] Whether the option is an autocomplete option
512
+ * @property {ApplicationCommandOptionChoice[]} [choices] The choices of the option for the user to pick from
513
+ * @property {ApplicationCommandOption[]} [options] Additional options if this option is a subcommand (group)
514
+ * @property {ChannelType[]} [channelTypes] When the option type is channel,
515
+ * the allowed types of channels that can be selected
516
+ * @property {number} [minValue] The minimum value for an `INTEGER` or `NUMBER` option
517
+ * @property {number} [maxValue] The maximum value for an `INTEGER` or `NUMBER` option
518
+ * @property {number} [minLength] The minimum length for a `STRING` option
519
+ * (maximum of `6000`)
520
+ * @property {number} [maxLength] The maximum length for a `STRING` option
521
+ * (maximum of `6000`)
522
+ */
523
+
524
+ /**
525
+ * A choice for an application command option.
526
+ * @typedef {Object} ApplicationCommandOptionChoice
527
+ * @property {string} name The name of the choice
528
+ * @property {?string} nameLocalized The localized name of the choice in the provided locale, if any
529
+ * @property {?Object<string, string>} [nameLocalizations] The localized names for this choice
530
+ * @property {string|number} value The value of the choice
531
+ */
532
+
533
+ /**
534
+ * Transforms an {@link ApplicationCommandOptionData} object into something that can be used with the API.
535
+ * @param {ApplicationCommandOptionData|ApplicationCommandOption} option The option to transform
536
+ * @param {boolean} [received] Whether this option has been received from Discord
537
+ * @returns {APIApplicationCommandOption}
538
+ * @private
539
+ */
540
+ static transformOption(option, received) {
541
+ const stringType = typeof option.type === 'string' ? option.type : ApplicationCommandOptionTypes[option.type];
542
+ const channelTypesKey = received ? 'channelTypes' : 'channel_types';
543
+ const minValueKey = received ? 'minValue' : 'min_value';
544
+ const maxValueKey = received ? 'maxValue' : 'max_value';
545
+ const minLengthKey = received ? 'minLength' : 'min_length';
546
+ const maxLengthKey = received ? 'maxLength' : 'max_length';
547
+ const nameLocalizationsKey = received ? 'nameLocalizations' : 'name_localizations';
548
+ const nameLocalizedKey = received ? 'nameLocalized' : 'name_localized';
549
+ const descriptionLocalizationsKey = received ? 'descriptionLocalizations' : 'description_localizations';
550
+ const descriptionLocalizedKey = received ? 'descriptionLocalized' : 'description_localized';
551
+ return {
552
+ type: typeof option.type === 'number' && !received ? option.type : ApplicationCommandOptionTypes[option.type],
553
+ name: option.name,
554
+ [nameLocalizationsKey]: option.nameLocalizations ?? option.name_localizations,
555
+ [nameLocalizedKey]: option.nameLocalized ?? option.name_localized,
556
+ description: option.description,
557
+ [descriptionLocalizationsKey]: option.descriptionLocalizations ?? option.description_localizations,
558
+ [descriptionLocalizedKey]: option.descriptionLocalized ?? option.description_localized,
559
+ required:
560
+ option.required ?? (stringType === 'SUB_COMMAND' || stringType === 'SUB_COMMAND_GROUP' ? undefined : false),
561
+ autocomplete: option.autocomplete,
562
+ choices: option.choices?.map(choice => ({
563
+ name: choice.name,
564
+ [nameLocalizedKey]: choice.nameLocalized ?? choice.name_localized,
565
+ [nameLocalizationsKey]: choice.nameLocalizations ?? choice.name_localizations,
566
+ value: choice.value,
567
+ })),
568
+ options: option.options?.map(o => this.transformOption(o, received)),
569
+ [channelTypesKey]: received
570
+ ? option.channel_types?.map(type => ChannelTypes[type])
571
+ : option.channelTypes?.map(type => (typeof type === 'string' ? ChannelTypes[type] : type)) ??
572
+ // When transforming to API data, accept API data
573
+ option.channel_types,
574
+ [minValueKey]: option.minValue ?? option.min_value,
575
+ [maxValueKey]: option.maxValue ?? option.max_value,
576
+ [minLengthKey]: option.minLength ?? option.min_length,
577
+ [maxLengthKey]: option.maxLength ?? option.max_length,
578
+ };
579
+ }
580
+ }
581
+
582
+ module.exports = ApplicationCommand;
583
+
584
+ /* eslint-disable max-len */
585
+ /**
586
+ * @external APIApplicationCommand
587
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-structure}
588
+ */
589
+
590
+ /**
591
+ * @external APIApplicationCommandOption
592
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#application-command-object-application-command-option-structure}
593
+ */