@ovencord/discord.js 14.16.3

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 (332) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +148 -0
  3. package/package.json +73 -0
  4. package/src/client/Client.ts +967 -0
  5. package/src/client/actions/Action.ts +141 -0
  6. package/src/client/actions/ActionsManager.ts +138 -0
  7. package/src/client/actions/ChannelCreate.ts +21 -0
  8. package/src/client/actions/ChannelDelete.ts +20 -0
  9. package/src/client/actions/ChannelUpdate.ts +38 -0
  10. package/src/client/actions/GuildChannelsPositionUpdate.ts +17 -0
  11. package/src/client/actions/GuildEmojiCreate.ts +17 -0
  12. package/src/client/actions/GuildEmojiDelete.ts +16 -0
  13. package/src/client/actions/GuildEmojiUpdate.ts +17 -0
  14. package/src/client/actions/GuildEmojisUpdate.ts +30 -0
  15. package/src/client/actions/GuildMemberRemove.ts +29 -0
  16. package/src/client/actions/GuildMemberUpdate.ts +41 -0
  17. package/src/client/actions/GuildRoleCreate.ts +23 -0
  18. package/src/client/actions/GuildRoleDelete.ts +26 -0
  19. package/src/client/actions/GuildRolesPositionUpdate.ts +17 -0
  20. package/src/client/actions/GuildScheduledEventDelete.ts +28 -0
  21. package/src/client/actions/GuildScheduledEventUserAdd.ts +29 -0
  22. package/src/client/actions/GuildScheduledEventUserRemove.ts +29 -0
  23. package/src/client/actions/GuildSoundboardSoundDelete.ts +26 -0
  24. package/src/client/actions/GuildStickerCreate.ts +17 -0
  25. package/src/client/actions/GuildStickerDelete.ts +16 -0
  26. package/src/client/actions/GuildStickerUpdate.ts +17 -0
  27. package/src/client/actions/GuildStickersUpdate.ts +30 -0
  28. package/src/client/actions/GuildUpdate.ts +30 -0
  29. package/src/client/actions/InteractionCreate.ts +104 -0
  30. package/src/client/actions/MessageCreate.ts +38 -0
  31. package/src/client/actions/MessageDelete.ts +29 -0
  32. package/src/client/actions/MessageDeleteBulk.ts +45 -0
  33. package/src/client/actions/MessagePollVoteAdd.ts +37 -0
  34. package/src/client/actions/MessagePollVoteRemove.ts +35 -0
  35. package/src/client/actions/MessageReactionAdd.ts +68 -0
  36. package/src/client/actions/MessageReactionRemove.ts +47 -0
  37. package/src/client/actions/MessageReactionRemoveAll.ts +30 -0
  38. package/src/client/actions/MessageReactionRemoveEmoji.ts +25 -0
  39. package/src/client/actions/MessageUpdate.ts +22 -0
  40. package/src/client/actions/StageInstanceCreate.ts +25 -0
  41. package/src/client/actions/StageInstanceDelete.ts +28 -0
  42. package/src/client/actions/StageInstanceUpdate.ts +27 -0
  43. package/src/client/actions/ThreadCreate.ts +22 -0
  44. package/src/client/actions/ThreadMembersUpdate.ts +45 -0
  45. package/src/client/actions/TypingStart.ts +26 -0
  46. package/src/client/actions/UserUpdate.ts +33 -0
  47. package/src/client/voice/ClientVoiceManager.ts +46 -0
  48. package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.ts +19 -0
  49. package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.ts +17 -0
  50. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.ts +18 -0
  51. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.ts +21 -0
  52. package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.ts +20 -0
  53. package/src/client/websocket/handlers/CHANNEL_CREATE.ts +4 -0
  54. package/src/client/websocket/handlers/CHANNEL_DELETE.ts +4 -0
  55. package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.ts +22 -0
  56. package/src/client/websocket/handlers/CHANNEL_UPDATE.ts +16 -0
  57. package/src/client/websocket/handlers/ENTITLEMENT_CREATE.ts +14 -0
  58. package/src/client/websocket/handlers/ENTITLEMENT_DELETE.ts +18 -0
  59. package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.ts +16 -0
  60. package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.ts +19 -0
  61. package/src/client/websocket/handlers/GUILD_BAN_ADD.ts +15 -0
  62. package/src/client/websocket/handlers/GUILD_BAN_REMOVE.ts +20 -0
  63. package/src/client/websocket/handlers/GUILD_CREATE.ts +34 -0
  64. package/src/client/websocket/handlers/GUILD_DELETE.ts +36 -0
  65. package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.ts +4 -0
  66. package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.ts +15 -0
  67. package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.ts +40 -0
  68. package/src/client/websocket/handlers/GUILD_MEMBER_ADD.ts +17 -0
  69. package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.ts +4 -0
  70. package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.ts +4 -0
  71. package/src/client/websocket/handlers/GUILD_ROLE_CREATE.ts +4 -0
  72. package/src/client/websocket/handlers/GUILD_ROLE_DELETE.ts +4 -0
  73. package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.ts +21 -0
  74. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.ts +17 -0
  75. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.ts +4 -0
  76. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.ts +19 -0
  77. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.ts +4 -0
  78. package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts +4 -0
  79. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.ts +24 -0
  80. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.ts +18 -0
  81. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.ts +4 -0
  82. package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.ts +20 -0
  83. package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.ts +4 -0
  84. package/src/client/websocket/handlers/GUILD_UPDATE.ts +4 -0
  85. package/src/client/websocket/handlers/INTERACTION_CREATE.ts +4 -0
  86. package/src/client/websocket/handlers/INVITE_CREATE.ts +20 -0
  87. package/src/client/websocket/handlers/INVITE_DELETE.ts +23 -0
  88. package/src/client/websocket/handlers/MESSAGE_CREATE.ts +4 -0
  89. package/src/client/websocket/handlers/MESSAGE_DELETE.ts +4 -0
  90. package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.ts +4 -0
  91. package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.ts +4 -0
  92. package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.ts +4 -0
  93. package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.ts +4 -0
  94. package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.ts +4 -0
  95. package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.ts +4 -0
  96. package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.ts +4 -0
  97. package/src/client/websocket/handlers/MESSAGE_UPDATE.ts +16 -0
  98. package/src/client/websocket/handlers/PRESENCE_UPDATE.ts +42 -0
  99. package/src/client/websocket/handlers/RATE_LIMITED.ts +23 -0
  100. package/src/client/websocket/handlers/READY.ts +29 -0
  101. package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.ts +24 -0
  102. package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.ts +4 -0
  103. package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.ts +4 -0
  104. package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.ts +4 -0
  105. package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.ts +14 -0
  106. package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.ts +16 -0
  107. package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.ts +16 -0
  108. package/src/client/websocket/handlers/THREAD_CREATE.ts +4 -0
  109. package/src/client/websocket/handlers/THREAD_DELETE.ts +17 -0
  110. package/src/client/websocket/handlers/THREAD_LIST_SYNC.ts +50 -0
  111. package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.ts +4 -0
  112. package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.ts +25 -0
  113. package/src/client/websocket/handlers/THREAD_UPDATE.ts +16 -0
  114. package/src/client/websocket/handlers/TYPING_START.ts +4 -0
  115. package/src/client/websocket/handlers/USER_UPDATE.ts +4 -0
  116. package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.ts +16 -0
  117. package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.ts +5 -0
  118. package/src/client/websocket/handlers/VOICE_STATE_UPDATE.ts +37 -0
  119. package/src/client/websocket/handlers/WEBHOOKS_UPDATE.ts +16 -0
  120. package/src/client/websocket/handlers/index.ts +74 -0
  121. package/src/errors/DJSError.ts +50 -0
  122. package/src/errors/ErrorCodes.ts +277 -0
  123. package/src/errors/Messages.ts +155 -0
  124. package/src/errors/index.ts +6 -0
  125. package/src/index.ts +241 -0
  126. package/src/managers/ApplicationCommandManager.ts +303 -0
  127. package/src/managers/ApplicationCommandPermissionsManager.ts +453 -0
  128. package/src/managers/ApplicationEmojiManager.ts +149 -0
  129. package/src/managers/AutoModerationRuleManager.ts +307 -0
  130. package/src/managers/BaseManager.ts +13 -0
  131. package/src/managers/CachedManager.ts +56 -0
  132. package/src/managers/CategoryChannelChildManager.ts +81 -0
  133. package/src/managers/ChannelManager.ts +194 -0
  134. package/src/managers/DMMessageManager.ts +15 -0
  135. package/src/managers/DataManager.ts +38 -0
  136. package/src/managers/EntitlementManager.ts +182 -0
  137. package/src/managers/GuildApplicationCommandManager.ts +29 -0
  138. package/src/managers/GuildBanManager.ts +221 -0
  139. package/src/managers/GuildChannelManager.ts +552 -0
  140. package/src/managers/GuildEmojiManager.ts +262 -0
  141. package/src/managers/GuildEmojiRoleManager.ts +134 -0
  142. package/src/managers/GuildForumThreadManager.ts +84 -0
  143. package/src/managers/GuildInviteManager.ts +236 -0
  144. package/src/managers/GuildManager.ts +265 -0
  145. package/src/managers/GuildMemberManager.ts +619 -0
  146. package/src/managers/GuildMemberRoleManager.ts +230 -0
  147. package/src/managers/GuildMessageManager.ts +31 -0
  148. package/src/managers/GuildScheduledEventManager.ts +330 -0
  149. package/src/managers/GuildSoundboardSoundManager.ts +157 -0
  150. package/src/managers/GuildStickerManager.ts +192 -0
  151. package/src/managers/GuildTextThreadManager.ts +91 -0
  152. package/src/managers/MessageManager.ts +352 -0
  153. package/src/managers/PartialGroupDMMessageManager.ts +15 -0
  154. package/src/managers/PermissionOverwriteManager.ts +174 -0
  155. package/src/managers/PollAnswerVoterManager.ts +59 -0
  156. package/src/managers/PresenceManager.ts +60 -0
  157. package/src/managers/ReactionManager.ts +72 -0
  158. package/src/managers/ReactionUserManager.ts +82 -0
  159. package/src/managers/RoleManager.ts +432 -0
  160. package/src/managers/StageInstanceManager.ts +166 -0
  161. package/src/managers/SubscriptionManager.ts +83 -0
  162. package/src/managers/ThreadManager.ts +210 -0
  163. package/src/managers/ThreadMemberManager.ts +194 -0
  164. package/src/managers/UserManager.ts +139 -0
  165. package/src/managers/VoiceStateManager.ts +61 -0
  166. package/src/sharding/Shard.ts +513 -0
  167. package/src/sharding/ShardClientUtil.ts +293 -0
  168. package/src/sharding/ShardingManager.ts +374 -0
  169. package/src/structures/ActionRow.ts +31 -0
  170. package/src/structures/AnnouncementChannel.ts +25 -0
  171. package/src/structures/AnonymousGuild.ts +110 -0
  172. package/src/structures/ApplicationCommand.ts +675 -0
  173. package/src/structures/ApplicationEmoji.ts +189 -0
  174. package/src/structures/ApplicationRoleConnectionMetadata.ts +54 -0
  175. package/src/structures/Attachment.ts +189 -0
  176. package/src/structures/AuthorizingIntegrationOwners.ts +63 -0
  177. package/src/structures/AutoModerationActionExecution.ts +138 -0
  178. package/src/structures/AutoModerationRule.ts +325 -0
  179. package/src/structures/AutocompleteInteraction.ts +115 -0
  180. package/src/structures/Base.ts +37 -0
  181. package/src/structures/BaseChannel.ts +188 -0
  182. package/src/structures/BaseGuild.ts +134 -0
  183. package/src/structures/BaseGuildEmoji.ts +113 -0
  184. package/src/structures/BaseGuildTextChannel.ts +230 -0
  185. package/src/structures/BaseGuildVoiceChannel.ts +270 -0
  186. package/src/structures/BaseInteraction.ts +393 -0
  187. package/src/structures/BaseInvite.ts +192 -0
  188. package/src/structures/BaseSelectMenuComponent.ts +58 -0
  189. package/src/structures/ButtonComponent.ts +68 -0
  190. package/src/structures/ButtonInteraction.ts +8 -0
  191. package/src/structures/CategoryChannel.ts +46 -0
  192. package/src/structures/ChannelSelectMenuComponent.ts +18 -0
  193. package/src/structures/ChannelSelectMenuInteraction.ts +34 -0
  194. package/src/structures/ChatInputCommandInteraction.ts +43 -0
  195. package/src/structures/ClientApplication.ts +470 -0
  196. package/src/structures/ClientPresence.ts +87 -0
  197. package/src/structures/ClientUser.ts +219 -0
  198. package/src/structures/CommandInteraction.ts +193 -0
  199. package/src/structures/CommandInteractionOptionResolver.ts +336 -0
  200. package/src/structures/Component.ts +59 -0
  201. package/src/structures/ContainerComponent.ts +63 -0
  202. package/src/structures/ContextMenuCommandInteraction.ts +68 -0
  203. package/src/structures/DMChannel.ts +148 -0
  204. package/src/structures/DirectoryChannel.ts +40 -0
  205. package/src/structures/Embed.ts +251 -0
  206. package/src/structures/Emoji.ts +61 -0
  207. package/src/structures/Entitlement.ts +206 -0
  208. package/src/structures/FileComponent.ts +41 -0
  209. package/src/structures/ForumChannel.ts +31 -0
  210. package/src/structures/GroupDMInvite.ts +34 -0
  211. package/src/structures/Guild.ts +1605 -0
  212. package/src/structures/GuildAuditLogs.ts +99 -0
  213. package/src/structures/GuildAuditLogsEntry.ts +557 -0
  214. package/src/structures/GuildBan.ts +65 -0
  215. package/src/structures/GuildChannel.ts +515 -0
  216. package/src/structures/GuildEmoji.ts +159 -0
  217. package/src/structures/GuildInvite.ts +233 -0
  218. package/src/structures/GuildMember.ts +643 -0
  219. package/src/structures/GuildOnboarding.ts +73 -0
  220. package/src/structures/GuildOnboardingPrompt.ts +93 -0
  221. package/src/structures/GuildOnboardingPromptOption.ts +100 -0
  222. package/src/structures/GuildPreview.ts +218 -0
  223. package/src/structures/GuildPreviewEmoji.ts +28 -0
  224. package/src/structures/GuildScheduledEvent.ts +593 -0
  225. package/src/structures/GuildTemplate.ts +229 -0
  226. package/src/structures/Integration.ts +257 -0
  227. package/src/structures/IntegrationApplication.ts +84 -0
  228. package/src/structures/InteractionCallback.ts +86 -0
  229. package/src/structures/InteractionCallbackResource.ts +57 -0
  230. package/src/structures/InteractionCallbackResponse.ts +35 -0
  231. package/src/structures/InteractionCollector.ts +260 -0
  232. package/src/structures/InteractionWebhook.ts +65 -0
  233. package/src/structures/InviteGuild.ts +22 -0
  234. package/src/structures/LabelComponent.ts +51 -0
  235. package/src/structures/MediaChannel.ts +8 -0
  236. package/src/structures/MediaGalleryComponent.ts +31 -0
  237. package/src/structures/MediaGalleryItem.ts +54 -0
  238. package/src/structures/MentionableSelectMenuComponent.ts +8 -0
  239. package/src/structures/MentionableSelectMenuInteraction.ts +76 -0
  240. package/src/structures/Message.ts +1202 -0
  241. package/src/structures/MessageCollector.ts +155 -0
  242. package/src/structures/MessageComponentInteraction.ts +132 -0
  243. package/src/structures/MessageContextMenuCommandInteraction.ts +18 -0
  244. package/src/structures/MessageMentions.ts +327 -0
  245. package/src/structures/MessagePayload.ts +325 -0
  246. package/src/structures/MessageReaction.ts +219 -0
  247. package/src/structures/ModalComponentResolver.ts +237 -0
  248. package/src/structures/ModalSubmitInteraction.ts +260 -0
  249. package/src/structures/OAuth2Guild.ts +30 -0
  250. package/src/structures/PartialGroupDMChannel.ts +151 -0
  251. package/src/structures/PermissionOverwrites.ts +222 -0
  252. package/src/structures/Poll.ts +195 -0
  253. package/src/structures/PollAnswer.ts +100 -0
  254. package/src/structures/Presence.ts +448 -0
  255. package/src/structures/PrimaryEntryPointCommandInteraction.ts +8 -0
  256. package/src/structures/ReactionCollector.ts +245 -0
  257. package/src/structures/ReactionEmoji.ts +30 -0
  258. package/src/structures/Role.ts +543 -0
  259. package/src/structures/RoleSelectMenuComponent.ts +8 -0
  260. package/src/structures/RoleSelectMenuInteraction.ts +34 -0
  261. package/src/structures/SKU.ts +62 -0
  262. package/src/structures/SectionComponent.ts +44 -0
  263. package/src/structures/SeparatorComponent.ts +29 -0
  264. package/src/structures/SoundboardSound.ts +176 -0
  265. package/src/structures/StageChannel.ts +118 -0
  266. package/src/structures/StageInstance.ts +173 -0
  267. package/src/structures/Sticker.ts +300 -0
  268. package/src/structures/StickerPack.ts +111 -0
  269. package/src/structures/StringSelectMenuComponent.ts +18 -0
  270. package/src/structures/StringSelectMenuInteraction.ts +21 -0
  271. package/src/structures/Subscription.ts +138 -0
  272. package/src/structures/Team.ts +131 -0
  273. package/src/structures/TeamMember.ts +77 -0
  274. package/src/structures/TextChannel.ts +33 -0
  275. package/src/structures/TextDisplayComponent.ts +18 -0
  276. package/src/structures/TextInputComponent.ts +28 -0
  277. package/src/structures/ThreadChannel.ts +680 -0
  278. package/src/structures/ThreadMember.ts +125 -0
  279. package/src/structures/ThreadOnlyChannel.ts +276 -0
  280. package/src/structures/ThumbnailComponent.ts +51 -0
  281. package/src/structures/Typing.ts +81 -0
  282. package/src/structures/UnfurledMediaItem.ts +33 -0
  283. package/src/structures/User.ts +511 -0
  284. package/src/structures/UserContextMenuCommandInteraction.ts +28 -0
  285. package/src/structures/UserSelectMenuComponent.ts +8 -0
  286. package/src/structures/UserSelectMenuInteraction.ts +54 -0
  287. package/src/structures/VoiceChannel.ts +119 -0
  288. package/src/structures/VoiceChannelEffect.ts +92 -0
  289. package/src/structures/VoiceRegion.ts +52 -0
  290. package/src/structures/VoiceState.ts +346 -0
  291. package/src/structures/Webhook.ts +526 -0
  292. package/src/structures/WelcomeChannel.ts +67 -0
  293. package/src/structures/WelcomeScreen.ts +53 -0
  294. package/src/structures/Widget.ts +110 -0
  295. package/src/structures/WidgetMember.ts +124 -0
  296. package/src/structures/interfaces/Application.ts +179 -0
  297. package/src/structures/interfaces/Collector.ts +372 -0
  298. package/src/structures/interfaces/InteractionResponses.ts +384 -0
  299. package/src/structures/interfaces/TextBasedChannel.ts +430 -0
  300. package/src/util/APITypes.ts +690 -0
  301. package/src/util/ActivityFlagsBitField.ts +26 -0
  302. package/src/util/ApplicationFlagsBitField.ts +43 -0
  303. package/src/util/AttachmentFlagsBitField.ts +26 -0
  304. package/src/util/BitField.ts +178 -0
  305. package/src/util/ChannelFlagsBitField.ts +43 -0
  306. package/src/util/Channels.ts +165 -0
  307. package/src/util/Colors.ts +72 -0
  308. package/src/util/Components.ts +285 -0
  309. package/src/util/Constants.ts +251 -0
  310. package/src/util/DataResolver.ts +146 -0
  311. package/src/util/Enums.ts +10 -0
  312. package/src/util/Events.ts +178 -0
  313. package/src/util/GuildMemberFlagsBitField.ts +43 -0
  314. package/src/util/IntentsBitField.ts +35 -0
  315. package/src/util/InviteFlagsBitField.ts +26 -0
  316. package/src/util/Invites.ts +27 -0
  317. package/src/util/LimitedCollection.ts +73 -0
  318. package/src/util/MessageFlagsBitField.ts +43 -0
  319. package/src/util/Options.ts +215 -0
  320. package/src/util/Partials.ts +50 -0
  321. package/src/util/PermissionsBitField.ts +113 -0
  322. package/src/util/RoleFlagsBitField.ts +26 -0
  323. package/src/util/SKUFlagsBitField.ts +26 -0
  324. package/src/util/ShardEvents.ts +26 -0
  325. package/src/util/Status.ts +16 -0
  326. package/src/util/Sweepers.ts +532 -0
  327. package/src/util/Symbols.ts +1 -0
  328. package/src/util/SystemChannelFlagsBitField.ts +45 -0
  329. package/src/util/ThreadMemberFlagsBitField.ts +33 -0
  330. package/src/util/Transformers.ts +123 -0
  331. package/src/util/UserFlagsBitField.ts +33 -0
  332. package/src/util/Util.ts +519 -0
@@ -0,0 +1,675 @@
1
+ import { DiscordSnowflake } from '@sapphire/snowflake';
2
+ import { ApplicationCommandOptionType } from 'discord-api-types/v10';
3
+ import isEqual from 'fast-deep-equal';
4
+ import { ApplicationCommandPermissionsManager } from '../managers/ApplicationCommandPermissionsManager.js';
5
+ import { PermissionsBitField } from '../util/PermissionsBitField.js';
6
+ import { Base } from './Base.js';
7
+
8
+ /**
9
+ * Represents an application command.
10
+ *
11
+ * @extends {Base}
12
+ */
13
+ export class ApplicationCommand extends Base {
14
+ public client: any;
15
+ public id: any;
16
+ public applicationId: any;
17
+ public guild: any;
18
+ public guildId: any;
19
+ public permissions: any;
20
+ public type: any;
21
+ public nsfw: any;
22
+ public name: any;
23
+ public nameLocalizations: any;
24
+ public nameLocalized: any;
25
+ public description: any;
26
+ public descriptionLocalizations: any;
27
+ public descriptionLocalized: any;
28
+ public options: any;
29
+ public defaultMemberPermissions: any;
30
+ public integrationTypes: any;
31
+ public contexts: any;
32
+ public handler: any;
33
+ public version: any;
34
+ constructor(client, data, guild, guildId) {
35
+ super(client);
36
+
37
+ /**
38
+ * The command's id
39
+ *
40
+ * @type {Snowflake}
41
+ */
42
+ this.id = data.id;
43
+
44
+ /**
45
+ * The parent application's id
46
+ *
47
+ * @type {Snowflake}
48
+ */
49
+ this.applicationId = data.application_id;
50
+
51
+ /**
52
+ * The guild this command is part of
53
+ *
54
+ * @type {?Guild}
55
+ */
56
+ this.guild = guild ?? null;
57
+
58
+ /**
59
+ * The guild's id this command is part of, this may be non-null when `guild` is `null` if the command
60
+ * was fetched from the `ApplicationCommandManager`
61
+ *
62
+ * @type {?Snowflake}
63
+ */
64
+ this.guildId = guild?.id ?? guildId ?? null;
65
+
66
+ /**
67
+ * The manager for permissions of this command on its guild or arbitrary guilds when the command is global
68
+ *
69
+ * @type {ApplicationCommandPermissionsManager}
70
+ */
71
+ this.permissions = new ApplicationCommandPermissionsManager(this);
72
+
73
+ /**
74
+ * The type of this application command
75
+ *
76
+ * @type {ApplicationCommandType}
77
+ */
78
+ this.type = data.type;
79
+
80
+ /**
81
+ * Whether this command is age-restricted (18+)
82
+ *
83
+ * @type {boolean}
84
+ */
85
+ this.nsfw = data.nsfw ?? false;
86
+
87
+ this._patch(data);
88
+ }
89
+
90
+ _patch(data) {
91
+ if ('name' in data) {
92
+ /**
93
+ * The name of this command
94
+ *
95
+ * @type {string}
96
+ */
97
+ this.name = data.name;
98
+ }
99
+
100
+ if ('name_localizations' in data) {
101
+ /**
102
+ * The name localizations for this command
103
+ *
104
+ * @type {?LocalizationMap}
105
+ */
106
+ this.nameLocalizations = data.name_localizations;
107
+ } else {
108
+ this.nameLocalizations ??= null;
109
+ }
110
+
111
+ if ('name_localized' in data) {
112
+ /**
113
+ * The localized name for this command
114
+ *
115
+ * @type {?string}
116
+ */
117
+ this.nameLocalized = data.name_localized;
118
+ } else {
119
+ this.nameLocalized ??= null;
120
+ }
121
+
122
+ if ('description' in data) {
123
+ /**
124
+ * The description of this command
125
+ *
126
+ * @type {string}
127
+ */
128
+ this.description = data.description;
129
+ }
130
+
131
+ if ('description_localizations' in data) {
132
+ /**
133
+ * The description localizations for this command
134
+ *
135
+ * @type {?LocalizationMap}
136
+ */
137
+ this.descriptionLocalizations = data.description_localizations;
138
+ } else {
139
+ this.descriptionLocalizations ??= null;
140
+ }
141
+
142
+ if ('description_localized' in data) {
143
+ /**
144
+ * The localized description for this command
145
+ *
146
+ * @type {?string}
147
+ */
148
+ this.descriptionLocalized = data.description_localized;
149
+ } else {
150
+ this.descriptionLocalized ??= null;
151
+ }
152
+
153
+ if ('options' in data) {
154
+ /**
155
+ * The options of this command
156
+ *
157
+ * @type {?ApplicationCommandOption[]}
158
+ */
159
+ this.options = data.options.map(option => this.constructor.transformOption(option, true));
160
+ } else {
161
+ this.options ??= null;
162
+ }
163
+
164
+ if ('default_member_permissions' in data) {
165
+ /**
166
+ * The default bitfield used to determine whether this command be used in a guild
167
+ *
168
+ * @type {?Readonly<PermissionsBitField>}
169
+ */
170
+ this.defaultMemberPermissions = data.default_member_permissions
171
+ ? new PermissionsBitField(BigInt(data.default_member_permissions)).freeze()
172
+ : null;
173
+ } else {
174
+ this.defaultMemberPermissions ??= null;
175
+ }
176
+
177
+ if ('integration_types' in data) {
178
+ /**
179
+ * Installation context(s) where the command is available
180
+ * <info>Only for globally-scoped commands</info>
181
+ *
182
+ * @type {?ApplicationIntegrationType[]}
183
+ */
184
+ this.integrationTypes = data.integration_types;
185
+ } else {
186
+ this.integrationTypes ??= null;
187
+ }
188
+
189
+ if ('contexts' in data) {
190
+ /**
191
+ * Interaction context(s) where the command can be used
192
+ * <info>Only for globally-scoped commands</info>
193
+ *
194
+ * @type {?InteractionContextType[]}
195
+ */
196
+ this.contexts = data.contexts;
197
+ } else {
198
+ this.contexts ??= null;
199
+ }
200
+
201
+ if ('handler' in data) {
202
+ /**
203
+ * Determines whether the interaction is handled by the app's interactions handler or by Discord.
204
+ * <info>Only available for {@link ApplicationCommandType.PrimaryEntryPoint} commands on
205
+ * applications with the {@link ApplicationFlags.Embedded} flag (i.e, those that have an Activity)</info>
206
+ *
207
+ * @type {?EntryPointCommandHandlerType}
208
+ */
209
+ this.handler = data.handler;
210
+ } else {
211
+ this.handler ??= null;
212
+ }
213
+
214
+ if ('version' in data) {
215
+ /**
216
+ * Autoincrementing version identifier updated during substantial record changes
217
+ *
218
+ * @type {Snowflake}
219
+ */
220
+ this.version = data.version;
221
+ }
222
+ }
223
+
224
+ /**
225
+ * The timestamp the command was created at
226
+ *
227
+ * @type {number}
228
+ * @readonly
229
+ */
230
+ get createdTimestamp() {
231
+ return DiscordSnowflake.timestampFrom(this.id);
232
+ }
233
+
234
+ /**
235
+ * The time the command was created at
236
+ *
237
+ * @type {Date}
238
+ * @readonly
239
+ */
240
+ get createdAt() {
241
+ return new Date(this.createdTimestamp);
242
+ }
243
+
244
+ /**
245
+ * The manager that this command belongs to
246
+ *
247
+ * @type {ApplicationCommandManager}
248
+ * @readonly
249
+ */
250
+ get manager() {
251
+ return (this.guild ?? this.client.application).commands;
252
+ }
253
+
254
+ /**
255
+ * Data for creating or editing an application command.
256
+ *
257
+ * @typedef {Object} ApplicationCommandData
258
+ * @property {string} name The name of the command, must be in all lowercase if type is
259
+ * {@link ApplicationCommandType.ChatInput}
260
+ * @property {LocalizationMap} [nameLocalizations] The localizations for the command name
261
+ * @property {string} description The description of the command,
262
+ * if type is {@link ApplicationCommandType.ChatInput} or {@link ApplicationCommandType.PrimaryEntryPoint}
263
+ * @property {boolean} [nsfw] Whether the command is age-restricted
264
+ * @property {LocalizationMap} [descriptionLocalizations] The localizations for the command description,
265
+ * if type is {@link ApplicationCommandType.ChatInput} or {@link ApplicationCommandType.PrimaryEntryPoint}
266
+ * @property {ApplicationCommandType} [type=ApplicationCommandType.ChatInput] The type of the command
267
+ * @property {ApplicationCommandOptionData[]} [options] Options for the command
268
+ * @property {?PermissionResolvable} [defaultMemberPermissions] The bitfield used to determine the default permissions
269
+ * a member needs in order to run the command
270
+ * @property {ApplicationIntegrationType[]} [integrationTypes] Installation contexts where the command is available
271
+ * @property {InteractionContextType[]} [contexts] Interaction contexts where the command can be used
272
+ * @property {EntryPointCommandHandlerType} [handler] Whether the interaction is handled by the app's
273
+ * interactions handler or by Discord.
274
+ */
275
+
276
+ /**
277
+ * An option for an application command or subcommand.
278
+ * <info>In addition to the listed properties, when used as a parameter,
279
+ * API style `snake_case` properties can be used for compatibility with generators like `@ovencord/builders`.</info>
280
+ * <warn>Note that providing a value for the `camelCase` counterpart for any `snake_case` property
281
+ * will discard the provided `snake_case` property.</warn>
282
+ *
283
+ * @typedef {Object} ApplicationCommandOptionData
284
+ * @property {ApplicationCommandOptionType} type The type of the option
285
+ * @property {string} name The name of the option
286
+ * @property {LocalizationMap} [nameLocalizations] The name localizations for the option
287
+ * @property {string} description The description of the option
288
+ * @property {LocalizationMap} [descriptionLocalizations] The description localizations for the option
289
+ * @property {boolean} [autocomplete] Whether the autocomplete interaction is enabled for a
290
+ * {@link ApplicationCommandOptionType.String}, {@link ApplicationCommandOptionType.Integer} or
291
+ * {@link ApplicationCommandOptionType.Number} option
292
+ * @property {boolean} [required] Whether the option is required
293
+ * @property {ApplicationCommandOptionChoiceData[]} [choices] The choices of the option for the user to pick from
294
+ * @property {ApplicationCommandOptionData[]} [options] Additional options if this option is a subcommand (group)
295
+ * @property {ChannelType[]} [channelTypes] When the option type is channel,
296
+ * the allowed types of channels that can be selected
297
+ * @property {number} [minValue] The minimum value for an {@link ApplicationCommandOptionType.Integer} or
298
+ * {@link ApplicationCommandOptionType.Number} option
299
+ * @property {number} [maxValue] The maximum value for an {@link ApplicationCommandOptionType.Integer} or
300
+ * {@link ApplicationCommandOptionType.Number} option
301
+ * @property {number} [minLength] The minimum length for an {@link ApplicationCommandOptionType.String} option
302
+ * (maximum of `6000`)
303
+ * @property {number} [maxLength] The maximum length for an {@link ApplicationCommandOptionType.String} option
304
+ * (maximum of `6000`)
305
+ */
306
+
307
+ /**
308
+ * @typedef {Object} ApplicationCommandOptionChoiceData
309
+ * @property {string} name The name of the choice
310
+ * @property {LocalizationMap} [nameLocalizations] The localized names for this choice
311
+ * @property {string|number} value The value of the choice
312
+ */
313
+
314
+ /**
315
+ * Edits this application command.
316
+ *
317
+ * @param {Partial<ApplicationCommandData>} data The data to update the command with
318
+ * @returns {Promise<ApplicationCommand>}
319
+ * @example
320
+ * // Edit the description of this command
321
+ * command.edit({
322
+ * description: 'New description',
323
+ * })
324
+ * .then(console.log)
325
+ * .catch(console.error);
326
+ */
327
+ async edit(data) {
328
+ return this.manager.edit(this, data, this.guildId);
329
+ }
330
+
331
+ /**
332
+ * Edits the name of this ApplicationCommand
333
+ *
334
+ * @param {string} name The new name of the command
335
+ * @returns {Promise<ApplicationCommand>}
336
+ */
337
+ async setName(name) {
338
+ return this.edit({ name });
339
+ }
340
+
341
+ /**
342
+ * Edits the localized names of this ApplicationCommand
343
+ *
344
+ * @param {LocalizationMap} nameLocalizations The new localized names for the command
345
+ * @returns {Promise<ApplicationCommand>}
346
+ * @example
347
+ * // Edit the name localizations of this command
348
+ * command.setNameLocalizations({
349
+ * 'en-GB': 'test',
350
+ * 'pt-BR': 'teste',
351
+ * })
352
+ * .then(console.log)
353
+ * .catch(console.error)
354
+ */
355
+ async setNameLocalizations(nameLocalizations) {
356
+ return this.edit({ nameLocalizations });
357
+ }
358
+
359
+ /**
360
+ * Edits the description of this ApplicationCommand
361
+ *
362
+ * @param {string} description The new description of the command
363
+ * @returns {Promise<ApplicationCommand>}
364
+ */
365
+ async setDescription(description) {
366
+ return this.edit({ description });
367
+ }
368
+
369
+ /**
370
+ * Edits the localized descriptions of this ApplicationCommand
371
+ *
372
+ * @param {LocalizationMap} descriptionLocalizations The new localized descriptions for the command
373
+ * @returns {Promise<ApplicationCommand>}
374
+ * @example
375
+ * // Edit the description localizations of this command
376
+ * command.setDescriptionLocalizations({
377
+ * 'en-GB': 'A test command',
378
+ * 'pt-BR': 'Um comando de teste',
379
+ * })
380
+ * .then(console.log)
381
+ * .catch(console.error)
382
+ */
383
+ async setDescriptionLocalizations(descriptionLocalizations) {
384
+ return this.edit({ descriptionLocalizations });
385
+ }
386
+
387
+ /**
388
+ * Edits the default member permissions of this ApplicationCommand
389
+ *
390
+ * @param {?PermissionResolvable} defaultMemberPermissions The default member permissions required to run this command
391
+ * @returns {Promise<ApplicationCommand>}
392
+ */
393
+ async setDefaultMemberPermissions(defaultMemberPermissions) {
394
+ return this.edit({ defaultMemberPermissions });
395
+ }
396
+
397
+ /**
398
+ * Edits the options of this ApplicationCommand
399
+ *
400
+ * @param {ApplicationCommandOptionData[]} options The options to set for this command
401
+ * @returns {Promise<ApplicationCommand>}
402
+ */
403
+ async setOptions(options) {
404
+ return this.edit({ options });
405
+ }
406
+
407
+ /**
408
+ * Deletes this command.
409
+ *
410
+ * @returns {Promise<ApplicationCommand>}
411
+ * @example
412
+ * // Delete this command
413
+ * command.delete()
414
+ * .then(console.log)
415
+ * .catch(console.error);
416
+ */
417
+ async delete() {
418
+ return this.manager.delete(this, this.guildId);
419
+ }
420
+
421
+ /**
422
+ * Whether this command equals another command. It compares all properties, so for most operations
423
+ * it is advisable to just compare `command.id === command2.id` as it is much faster and is often
424
+ * what most users need.
425
+ *
426
+ * @param {ApplicationCommand|ApplicationCommandData|APIApplicationCommand} command The command to compare with
427
+ * @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options and choices are in the same
428
+ * order in the array <info>The client may not always respect this ordering!</info>
429
+ * @returns {boolean}
430
+ */
431
+ equals(command, enforceOptionOrder = false) {
432
+ // If given an id, check if the id matches
433
+ if (command.id && this.id !== command.id) return false;
434
+
435
+ let defaultMemberPermissions = null;
436
+
437
+ if ('default_member_permissions' in command) {
438
+ defaultMemberPermissions = command.default_member_permissions
439
+ ? new PermissionsBitField(BigInt(command.default_member_permissions)).bitfield
440
+ : null;
441
+ }
442
+
443
+ if ('defaultMemberPermissions' in command) {
444
+ defaultMemberPermissions =
445
+ command.defaultMemberPermissions === null
446
+ ? null
447
+ : new PermissionsBitField(command.defaultMemberPermissions).bitfield;
448
+ }
449
+
450
+ // Check top level parameters
451
+ if (
452
+ command.name !== this.name ||
453
+ ('description' in command && command.description !== this.description) ||
454
+ ('version' in command && command.version !== this.version) ||
455
+ (command.type && command.type !== this.type) ||
456
+ ('nsfw' in command && command.nsfw !== this.nsfw) ||
457
+ command.options?.length !== this.options?.length ||
458
+ defaultMemberPermissions !== (this.defaultMemberPermissions?.bitfield ?? null) ||
459
+ !isEqual(command.nameLocalizations ?? command.name_localizations ?? {}, this.nameLocalizations ?? {}) ||
460
+ !isEqual(
461
+ command.descriptionLocalizations ?? command.description_localizations ?? {},
462
+ this.descriptionLocalizations ?? {},
463
+ ) ||
464
+ !isEqual(command.integrationTypes ?? command.integration_types ?? [], this.integrationTypes ?? []) ||
465
+ !isEqual(command.contexts ?? [], this.contexts ?? []) ||
466
+ ('handler' in command && command.handler !== this.handler)
467
+ ) {
468
+ return false;
469
+ }
470
+
471
+ // Don't need to check both because we already checked the lengths above
472
+ if (command.options) {
473
+ return this.constructor.optionsEqual(this.options, command.options, enforceOptionOrder);
474
+ }
475
+
476
+ return true;
477
+ }
478
+
479
+ /**
480
+ * Recursively checks that all options for an {@link ApplicationCommand} are equal to the provided options.
481
+ * In most cases it is better to compare using {@link ApplicationCommand#equals}
482
+ *
483
+ * @param {ApplicationCommandOptionData[]} existing The options on the existing command,
484
+ * should be {@link ApplicationCommand#options}
485
+ * @param {ApplicationCommandOptionData[]|APIApplicationCommandOption[]} options The options to compare against
486
+ * @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options and choices are in the same
487
+ * order in the array <info>The client may not always respect this ordering!</info>
488
+ * @returns {boolean}
489
+ */
490
+ static optionsEqual(existing, options, enforceOptionOrder = false) {
491
+ if (existing.length !== options.length) return false;
492
+ if (enforceOptionOrder) {
493
+ return existing.every((option, index) => this._optionEquals(option, options[index], enforceOptionOrder));
494
+ }
495
+
496
+ const newOptions = new Map(options.map(option => [option.name, option]));
497
+ for (const option of existing) {
498
+ const foundOption = newOptions.get(option.name);
499
+ if (!foundOption || !this._optionEquals(option, foundOption)) return false;
500
+ }
501
+
502
+ return true;
503
+ }
504
+
505
+ /**
506
+ * Checks that an option for an {@link ApplicationCommand} is equal to the provided option
507
+ * In most cases it is better to compare using {@link ApplicationCommand#equals}
508
+ *
509
+ * @param {ApplicationCommandOptionData} existing The option on the existing command,
510
+ * should be from {@link ApplicationCommand#options}
511
+ * @param {ApplicationCommandOptionData|APIApplicationCommandOption} option The option to compare against
512
+ * @param {boolean} [enforceOptionOrder=false] Whether to strictly check that options or choices are in the same
513
+ * order in their array <info>The client may not always respect this ordering!</info>
514
+ * @returns {boolean}
515
+ * @private
516
+ */
517
+ static _optionEquals(existing, option, enforceOptionOrder = false) {
518
+ if (
519
+ option.name !== existing.name ||
520
+ option.type !== existing.type ||
521
+ option.description !== existing.description ||
522
+ option.autocomplete !== existing.autocomplete ||
523
+ (option.required ??
524
+ ([ApplicationCommandOptionType.Subcommand, ApplicationCommandOptionType.SubcommandGroup].includes(option.type)
525
+ ? undefined
526
+ : false)) !== existing.required ||
527
+ option.choices?.length !== existing.choices?.length ||
528
+ option.options?.length !== existing.options?.length ||
529
+ (option.channelTypes ?? option.channel_types)?.length !== existing.channelTypes?.length ||
530
+ (option.minValue ?? option.min_value) !== existing.minValue ||
531
+ (option.maxValue ?? option.max_value) !== existing.maxValue ||
532
+ (option.minLength ?? option.min_length) !== existing.minLength ||
533
+ (option.maxLength ?? option.max_length) !== existing.maxLength ||
534
+ !isEqual(option.nameLocalizations ?? option.name_localizations ?? {}, existing.nameLocalizations ?? {}) ||
535
+ !isEqual(
536
+ option.descriptionLocalizations ?? option.description_localizations ?? {},
537
+ existing.descriptionLocalizations ?? {},
538
+ )
539
+ ) {
540
+ return false;
541
+ }
542
+
543
+ if (existing.choices) {
544
+ if (
545
+ enforceOptionOrder &&
546
+ !existing.choices.every(
547
+ (choice, index) =>
548
+ choice.name === option.choices[index].name &&
549
+ choice.value === option.choices[index].value &&
550
+ isEqual(
551
+ choice.nameLocalizations ?? {},
552
+ option.choices[index].nameLocalizations ?? option.choices[index].name_localizations ?? {},
553
+ ),
554
+ )
555
+ ) {
556
+ return false;
557
+ }
558
+
559
+ if (!enforceOptionOrder) {
560
+ const newChoices = new Map(option.choices.map(choice => [choice.name, choice]));
561
+ for (const choice of existing.choices) {
562
+ const foundChoice = newChoices.get(choice.name);
563
+ if (!foundChoice || foundChoice.value !== choice.value) return false;
564
+ }
565
+ }
566
+ }
567
+
568
+ if (existing.channelTypes) {
569
+ const newTypes = option.channelTypes ?? option.channel_types;
570
+ for (const type of existing.channelTypes) {
571
+ if (!newTypes.includes(type)) return false;
572
+ }
573
+ }
574
+
575
+ if (existing.options) {
576
+ return this.optionsEqual(existing.options, option.options, enforceOptionOrder);
577
+ }
578
+
579
+ return true;
580
+ }
581
+
582
+ /**
583
+ * An option for an application command or subcommand.
584
+ *
585
+ * @typedef {Object} ApplicationCommandOption
586
+ * @property {ApplicationCommandOptionType} type The type of the option
587
+ * @property {string} name The name of the option
588
+ * @property {LocalizationMap} [nameLocalizations] The localizations for the option name
589
+ * @property {string} [nameLocalized] The localized name for this option
590
+ * @property {string} description The description of the option
591
+ * @property {LocalizationMap} [descriptionLocalizations] The localizations for the option description
592
+ * @property {string} [descriptionLocalized] The localized description for this option
593
+ * @property {boolean} [required] Whether the option is required
594
+ * @property {boolean} [autocomplete] Whether the autocomplete interaction is enabled for a
595
+ * {@link ApplicationCommandOptionType.String}, {@link ApplicationCommandOptionType.Integer} or
596
+ * {@link ApplicationCommandOptionType.Number} option
597
+ * @property {ApplicationCommandOptionChoice[]} [choices] The choices of the option for the user to pick from
598
+ * @property {ApplicationCommandOption[]} [options] Additional options if this option is a subcommand (group)
599
+ * @property {ApplicationCommandOptionAllowedChannelType[]} [channelTypes] When the option type is channel,
600
+ * the allowed types of channels that can be selected
601
+ * @property {number} [minValue] The minimum value for an {@link ApplicationCommandOptionType.Integer} or
602
+ * {@link ApplicationCommandOptionType.Number} option
603
+ * @property {number} [maxValue] The maximum value for an {@link ApplicationCommandOptionType.Integer} or
604
+ * {@link ApplicationCommandOptionType.Number} option
605
+ * @property {number} [minLength] The minimum length for an {@link ApplicationCommandOptionType.String} option
606
+ * (maximum of `6000`)
607
+ * @property {number} [maxLength] The maximum length for an {@link ApplicationCommandOptionType.String} option
608
+ * (maximum of `6000`)
609
+ */
610
+
611
+ /**
612
+ * A choice for an application command option.
613
+ *
614
+ * @typedef {Object} ApplicationCommandOptionChoice
615
+ * @property {string} name The name of the choice
616
+ * @property {?string} nameLocalized The localized name of the choice in the provided locale, if any
617
+ * @property {?LocalizationMap} [nameLocalizations] The localized names for this choice
618
+ * @property {string|number} value The value of the choice
619
+ */
620
+
621
+ /**
622
+ * Transforms an {@link ApplicationCommandOptionData} object into something that can be used with the API.
623
+ *
624
+ * @param {ApplicationCommandOptionData|ApplicationCommandOption} option The option to transform
625
+ * @param {boolean} [received] Whether this option has been received from Discord
626
+ * @returns {APIApplicationCommandOption}
627
+ * @private
628
+ */
629
+ static transformOption(option, received) {
630
+ const channelTypesKey = received ? 'channelTypes' : 'channel_types';
631
+ const minValueKey = received ? 'minValue' : 'min_value';
632
+ const maxValueKey = received ? 'maxValue' : 'max_value';
633
+ const minLengthKey = received ? 'minLength' : 'min_length';
634
+ const maxLengthKey = received ? 'maxLength' : 'max_length';
635
+ const nameLocalizationsKey = received ? 'nameLocalizations' : 'name_localizations';
636
+ const nameLocalizedKey = received ? 'nameLocalized' : 'name_localized';
637
+ const descriptionLocalizationsKey = received ? 'descriptionLocalizations' : 'description_localizations';
638
+ const descriptionLocalizedKey = received ? 'descriptionLocalized' : 'description_localized';
639
+ return {
640
+ type: option.type,
641
+ name: option.name,
642
+ [nameLocalizationsKey]: option.nameLocalizations ?? option.name_localizations,
643
+ [nameLocalizedKey]: option.nameLocalized ?? option.name_localized,
644
+ description: option.description,
645
+ [descriptionLocalizationsKey]: option.descriptionLocalizations ?? option.description_localizations,
646
+ [descriptionLocalizedKey]: option.descriptionLocalized ?? option.description_localized,
647
+ required:
648
+ option.required ??
649
+ (option.type === ApplicationCommandOptionType.Subcommand ||
650
+ option.type === ApplicationCommandOptionType.SubcommandGroup
651
+ ? undefined
652
+ : false),
653
+ autocomplete: option.autocomplete,
654
+ choices: option.choices?.map(choice => ({
655
+ name: choice.name,
656
+ [nameLocalizedKey]: choice.nameLocalized ?? choice.name_localized,
657
+ [nameLocalizationsKey]: choice.nameLocalizations ?? choice.name_localizations,
658
+ value: choice.value,
659
+ })),
660
+ options: option.options?.map(opt => this.transformOption(opt, received)),
661
+ [channelTypesKey]: option.channelTypes ?? option.channel_types,
662
+ [minValueKey]: option.minValue ?? option.min_value,
663
+ [maxValueKey]: option.maxValue ?? option.max_value,
664
+ [minLengthKey]: option.minLength ?? option.min_length,
665
+ [maxLengthKey]: option.maxLength ?? option.max_length,
666
+ };
667
+ }
668
+ }
669
+
670
+
671
+
672
+ /**
673
+ * @external ApplicationCommandOptionAllowedChannelType
674
+ * @see {@link https://discord.js.org/docs/packages/builders/stable/ApplicationCommandOptionAllowedChannelType:TypeAlias}
675
+ */