@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.
- package/LICENSE +191 -0
- package/README.md +148 -0
- package/package.json +73 -0
- package/src/client/Client.ts +967 -0
- package/src/client/actions/Action.ts +141 -0
- package/src/client/actions/ActionsManager.ts +138 -0
- package/src/client/actions/ChannelCreate.ts +21 -0
- package/src/client/actions/ChannelDelete.ts +20 -0
- package/src/client/actions/ChannelUpdate.ts +38 -0
- package/src/client/actions/GuildChannelsPositionUpdate.ts +17 -0
- package/src/client/actions/GuildEmojiCreate.ts +17 -0
- package/src/client/actions/GuildEmojiDelete.ts +16 -0
- package/src/client/actions/GuildEmojiUpdate.ts +17 -0
- package/src/client/actions/GuildEmojisUpdate.ts +30 -0
- package/src/client/actions/GuildMemberRemove.ts +29 -0
- package/src/client/actions/GuildMemberUpdate.ts +41 -0
- package/src/client/actions/GuildRoleCreate.ts +23 -0
- package/src/client/actions/GuildRoleDelete.ts +26 -0
- package/src/client/actions/GuildRolesPositionUpdate.ts +17 -0
- package/src/client/actions/GuildScheduledEventDelete.ts +28 -0
- package/src/client/actions/GuildScheduledEventUserAdd.ts +29 -0
- package/src/client/actions/GuildScheduledEventUserRemove.ts +29 -0
- package/src/client/actions/GuildSoundboardSoundDelete.ts +26 -0
- package/src/client/actions/GuildStickerCreate.ts +17 -0
- package/src/client/actions/GuildStickerDelete.ts +16 -0
- package/src/client/actions/GuildStickerUpdate.ts +17 -0
- package/src/client/actions/GuildStickersUpdate.ts +30 -0
- package/src/client/actions/GuildUpdate.ts +30 -0
- package/src/client/actions/InteractionCreate.ts +104 -0
- package/src/client/actions/MessageCreate.ts +38 -0
- package/src/client/actions/MessageDelete.ts +29 -0
- package/src/client/actions/MessageDeleteBulk.ts +45 -0
- package/src/client/actions/MessagePollVoteAdd.ts +37 -0
- package/src/client/actions/MessagePollVoteRemove.ts +35 -0
- package/src/client/actions/MessageReactionAdd.ts +68 -0
- package/src/client/actions/MessageReactionRemove.ts +47 -0
- package/src/client/actions/MessageReactionRemoveAll.ts +30 -0
- package/src/client/actions/MessageReactionRemoveEmoji.ts +25 -0
- package/src/client/actions/MessageUpdate.ts +22 -0
- package/src/client/actions/StageInstanceCreate.ts +25 -0
- package/src/client/actions/StageInstanceDelete.ts +28 -0
- package/src/client/actions/StageInstanceUpdate.ts +27 -0
- package/src/client/actions/ThreadCreate.ts +22 -0
- package/src/client/actions/ThreadMembersUpdate.ts +45 -0
- package/src/client/actions/TypingStart.ts +26 -0
- package/src/client/actions/UserUpdate.ts +33 -0
- package/src/client/voice/ClientVoiceManager.ts +46 -0
- package/src/client/websocket/handlers/APPLICATION_COMMAND_PERMISSIONS_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_ACTION_EXECUTION.ts +17 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_CREATE.ts +18 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_DELETE.ts +21 -0
- package/src/client/websocket/handlers/AUTO_MODERATION_RULE_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/CHANNEL_CREATE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_DELETE.ts +4 -0
- package/src/client/websocket/handlers/CHANNEL_PINS_UPDATE.ts +22 -0
- package/src/client/websocket/handlers/CHANNEL_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/ENTITLEMENT_CREATE.ts +14 -0
- package/src/client/websocket/handlers/ENTITLEMENT_DELETE.ts +18 -0
- package/src/client/websocket/handlers/ENTITLEMENT_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/GUILD_AUDIT_LOG_ENTRY_CREATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_BAN_ADD.ts +15 -0
- package/src/client/websocket/handlers/GUILD_BAN_REMOVE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_CREATE.ts +34 -0
- package/src/client/websocket/handlers/GUILD_DELETE.ts +36 -0
- package/src/client/websocket/handlers/GUILD_EMOJIS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_INTEGRATIONS_UPDATE.ts +15 -0
- package/src/client/websocket/handlers/GUILD_MEMBERS_CHUNK.ts +40 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_ADD.ts +17 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_MEMBER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_ROLE_UPDATE.ts +21 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_CREATE.ts +17 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_UPDATE.ts +19 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_ADD.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SCHEDULED_EVENT_USER_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUNDS_UPDATE.ts +24 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_CREATE.ts +18 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_DELETE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_SOUNDBOARD_SOUND_UPDATE.ts +20 -0
- package/src/client/websocket/handlers/GUILD_STICKERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/GUILD_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/INTERACTION_CREATE.ts +4 -0
- package/src/client/websocket/handlers/INVITE_CREATE.ts +20 -0
- package/src/client/websocket/handlers/INVITE_DELETE.ts +23 -0
- package/src/client/websocket/handlers/MESSAGE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_DELETE_BULK.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_POLL_VOTE_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_ADD.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_ALL.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_REACTION_REMOVE_EMOJI.ts +4 -0
- package/src/client/websocket/handlers/MESSAGE_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/PRESENCE_UPDATE.ts +42 -0
- package/src/client/websocket/handlers/RATE_LIMITED.ts +23 -0
- package/src/client/websocket/handlers/READY.ts +29 -0
- package/src/client/websocket/handlers/SOUNDBOARD_SOUNDS.ts +24 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_CREATE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_DELETE.ts +4 -0
- package/src/client/websocket/handlers/STAGE_INSTANCE_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_CREATE.ts +14 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_DELETE.ts +16 -0
- package/src/client/websocket/handlers/SUBSCRIPTION_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/THREAD_CREATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_DELETE.ts +17 -0
- package/src/client/websocket/handlers/THREAD_LIST_SYNC.ts +50 -0
- package/src/client/websocket/handlers/THREAD_MEMBERS_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/THREAD_MEMBER_UPDATE.ts +25 -0
- package/src/client/websocket/handlers/THREAD_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/TYPING_START.ts +4 -0
- package/src/client/websocket/handlers/USER_UPDATE.ts +4 -0
- package/src/client/websocket/handlers/VOICE_CHANNEL_EFFECT_SEND.ts +16 -0
- package/src/client/websocket/handlers/VOICE_SERVER_UPDATE.ts +5 -0
- package/src/client/websocket/handlers/VOICE_STATE_UPDATE.ts +37 -0
- package/src/client/websocket/handlers/WEBHOOKS_UPDATE.ts +16 -0
- package/src/client/websocket/handlers/index.ts +74 -0
- package/src/errors/DJSError.ts +50 -0
- package/src/errors/ErrorCodes.ts +277 -0
- package/src/errors/Messages.ts +155 -0
- package/src/errors/index.ts +6 -0
- package/src/index.ts +241 -0
- package/src/managers/ApplicationCommandManager.ts +303 -0
- package/src/managers/ApplicationCommandPermissionsManager.ts +453 -0
- package/src/managers/ApplicationEmojiManager.ts +149 -0
- package/src/managers/AutoModerationRuleManager.ts +307 -0
- package/src/managers/BaseManager.ts +13 -0
- package/src/managers/CachedManager.ts +56 -0
- package/src/managers/CategoryChannelChildManager.ts +81 -0
- package/src/managers/ChannelManager.ts +194 -0
- package/src/managers/DMMessageManager.ts +15 -0
- package/src/managers/DataManager.ts +38 -0
- package/src/managers/EntitlementManager.ts +182 -0
- package/src/managers/GuildApplicationCommandManager.ts +29 -0
- package/src/managers/GuildBanManager.ts +221 -0
- package/src/managers/GuildChannelManager.ts +552 -0
- package/src/managers/GuildEmojiManager.ts +262 -0
- package/src/managers/GuildEmojiRoleManager.ts +134 -0
- package/src/managers/GuildForumThreadManager.ts +84 -0
- package/src/managers/GuildInviteManager.ts +236 -0
- package/src/managers/GuildManager.ts +265 -0
- package/src/managers/GuildMemberManager.ts +619 -0
- package/src/managers/GuildMemberRoleManager.ts +230 -0
- package/src/managers/GuildMessageManager.ts +31 -0
- package/src/managers/GuildScheduledEventManager.ts +330 -0
- package/src/managers/GuildSoundboardSoundManager.ts +157 -0
- package/src/managers/GuildStickerManager.ts +192 -0
- package/src/managers/GuildTextThreadManager.ts +91 -0
- package/src/managers/MessageManager.ts +352 -0
- package/src/managers/PartialGroupDMMessageManager.ts +15 -0
- package/src/managers/PermissionOverwriteManager.ts +174 -0
- package/src/managers/PollAnswerVoterManager.ts +59 -0
- package/src/managers/PresenceManager.ts +60 -0
- package/src/managers/ReactionManager.ts +72 -0
- package/src/managers/ReactionUserManager.ts +82 -0
- package/src/managers/RoleManager.ts +432 -0
- package/src/managers/StageInstanceManager.ts +166 -0
- package/src/managers/SubscriptionManager.ts +83 -0
- package/src/managers/ThreadManager.ts +210 -0
- package/src/managers/ThreadMemberManager.ts +194 -0
- package/src/managers/UserManager.ts +139 -0
- package/src/managers/VoiceStateManager.ts +61 -0
- package/src/sharding/Shard.ts +513 -0
- package/src/sharding/ShardClientUtil.ts +293 -0
- package/src/sharding/ShardingManager.ts +374 -0
- package/src/structures/ActionRow.ts +31 -0
- package/src/structures/AnnouncementChannel.ts +25 -0
- package/src/structures/AnonymousGuild.ts +110 -0
- package/src/structures/ApplicationCommand.ts +675 -0
- package/src/structures/ApplicationEmoji.ts +189 -0
- package/src/structures/ApplicationRoleConnectionMetadata.ts +54 -0
- package/src/structures/Attachment.ts +189 -0
- package/src/structures/AuthorizingIntegrationOwners.ts +63 -0
- package/src/structures/AutoModerationActionExecution.ts +138 -0
- package/src/structures/AutoModerationRule.ts +325 -0
- package/src/structures/AutocompleteInteraction.ts +115 -0
- package/src/structures/Base.ts +37 -0
- package/src/structures/BaseChannel.ts +188 -0
- package/src/structures/BaseGuild.ts +134 -0
- package/src/structures/BaseGuildEmoji.ts +113 -0
- package/src/structures/BaseGuildTextChannel.ts +230 -0
- package/src/structures/BaseGuildVoiceChannel.ts +270 -0
- package/src/structures/BaseInteraction.ts +393 -0
- package/src/structures/BaseInvite.ts +192 -0
- package/src/structures/BaseSelectMenuComponent.ts +58 -0
- package/src/structures/ButtonComponent.ts +68 -0
- package/src/structures/ButtonInteraction.ts +8 -0
- package/src/structures/CategoryChannel.ts +46 -0
- package/src/structures/ChannelSelectMenuComponent.ts +18 -0
- package/src/structures/ChannelSelectMenuInteraction.ts +34 -0
- package/src/structures/ChatInputCommandInteraction.ts +43 -0
- package/src/structures/ClientApplication.ts +470 -0
- package/src/structures/ClientPresence.ts +87 -0
- package/src/structures/ClientUser.ts +219 -0
- package/src/structures/CommandInteraction.ts +193 -0
- package/src/structures/CommandInteractionOptionResolver.ts +336 -0
- package/src/structures/Component.ts +59 -0
- package/src/structures/ContainerComponent.ts +63 -0
- package/src/structures/ContextMenuCommandInteraction.ts +68 -0
- package/src/structures/DMChannel.ts +148 -0
- package/src/structures/DirectoryChannel.ts +40 -0
- package/src/structures/Embed.ts +251 -0
- package/src/structures/Emoji.ts +61 -0
- package/src/structures/Entitlement.ts +206 -0
- package/src/structures/FileComponent.ts +41 -0
- package/src/structures/ForumChannel.ts +31 -0
- package/src/structures/GroupDMInvite.ts +34 -0
- package/src/structures/Guild.ts +1605 -0
- package/src/structures/GuildAuditLogs.ts +99 -0
- package/src/structures/GuildAuditLogsEntry.ts +557 -0
- package/src/structures/GuildBan.ts +65 -0
- package/src/structures/GuildChannel.ts +515 -0
- package/src/structures/GuildEmoji.ts +159 -0
- package/src/structures/GuildInvite.ts +233 -0
- package/src/structures/GuildMember.ts +643 -0
- package/src/structures/GuildOnboarding.ts +73 -0
- package/src/structures/GuildOnboardingPrompt.ts +93 -0
- package/src/structures/GuildOnboardingPromptOption.ts +100 -0
- package/src/structures/GuildPreview.ts +218 -0
- package/src/structures/GuildPreviewEmoji.ts +28 -0
- package/src/structures/GuildScheduledEvent.ts +593 -0
- package/src/structures/GuildTemplate.ts +229 -0
- package/src/structures/Integration.ts +257 -0
- package/src/structures/IntegrationApplication.ts +84 -0
- package/src/structures/InteractionCallback.ts +86 -0
- package/src/structures/InteractionCallbackResource.ts +57 -0
- package/src/structures/InteractionCallbackResponse.ts +35 -0
- package/src/structures/InteractionCollector.ts +260 -0
- package/src/structures/InteractionWebhook.ts +65 -0
- package/src/structures/InviteGuild.ts +22 -0
- package/src/structures/LabelComponent.ts +51 -0
- package/src/structures/MediaChannel.ts +8 -0
- package/src/structures/MediaGalleryComponent.ts +31 -0
- package/src/structures/MediaGalleryItem.ts +54 -0
- package/src/structures/MentionableSelectMenuComponent.ts +8 -0
- package/src/structures/MentionableSelectMenuInteraction.ts +76 -0
- package/src/structures/Message.ts +1202 -0
- package/src/structures/MessageCollector.ts +155 -0
- package/src/structures/MessageComponentInteraction.ts +132 -0
- package/src/structures/MessageContextMenuCommandInteraction.ts +18 -0
- package/src/structures/MessageMentions.ts +327 -0
- package/src/structures/MessagePayload.ts +325 -0
- package/src/structures/MessageReaction.ts +219 -0
- package/src/structures/ModalComponentResolver.ts +237 -0
- package/src/structures/ModalSubmitInteraction.ts +260 -0
- package/src/structures/OAuth2Guild.ts +30 -0
- package/src/structures/PartialGroupDMChannel.ts +151 -0
- package/src/structures/PermissionOverwrites.ts +222 -0
- package/src/structures/Poll.ts +195 -0
- package/src/structures/PollAnswer.ts +100 -0
- package/src/structures/Presence.ts +448 -0
- package/src/structures/PrimaryEntryPointCommandInteraction.ts +8 -0
- package/src/structures/ReactionCollector.ts +245 -0
- package/src/structures/ReactionEmoji.ts +30 -0
- package/src/structures/Role.ts +543 -0
- package/src/structures/RoleSelectMenuComponent.ts +8 -0
- package/src/structures/RoleSelectMenuInteraction.ts +34 -0
- package/src/structures/SKU.ts +62 -0
- package/src/structures/SectionComponent.ts +44 -0
- package/src/structures/SeparatorComponent.ts +29 -0
- package/src/structures/SoundboardSound.ts +176 -0
- package/src/structures/StageChannel.ts +118 -0
- package/src/structures/StageInstance.ts +173 -0
- package/src/structures/Sticker.ts +300 -0
- package/src/structures/StickerPack.ts +111 -0
- package/src/structures/StringSelectMenuComponent.ts +18 -0
- package/src/structures/StringSelectMenuInteraction.ts +21 -0
- package/src/structures/Subscription.ts +138 -0
- package/src/structures/Team.ts +131 -0
- package/src/structures/TeamMember.ts +77 -0
- package/src/structures/TextChannel.ts +33 -0
- package/src/structures/TextDisplayComponent.ts +18 -0
- package/src/structures/TextInputComponent.ts +28 -0
- package/src/structures/ThreadChannel.ts +680 -0
- package/src/structures/ThreadMember.ts +125 -0
- package/src/structures/ThreadOnlyChannel.ts +276 -0
- package/src/structures/ThumbnailComponent.ts +51 -0
- package/src/structures/Typing.ts +81 -0
- package/src/structures/UnfurledMediaItem.ts +33 -0
- package/src/structures/User.ts +511 -0
- package/src/structures/UserContextMenuCommandInteraction.ts +28 -0
- package/src/structures/UserSelectMenuComponent.ts +8 -0
- package/src/structures/UserSelectMenuInteraction.ts +54 -0
- package/src/structures/VoiceChannel.ts +119 -0
- package/src/structures/VoiceChannelEffect.ts +92 -0
- package/src/structures/VoiceRegion.ts +52 -0
- package/src/structures/VoiceState.ts +346 -0
- package/src/structures/Webhook.ts +526 -0
- package/src/structures/WelcomeChannel.ts +67 -0
- package/src/structures/WelcomeScreen.ts +53 -0
- package/src/structures/Widget.ts +110 -0
- package/src/structures/WidgetMember.ts +124 -0
- package/src/structures/interfaces/Application.ts +179 -0
- package/src/structures/interfaces/Collector.ts +372 -0
- package/src/structures/interfaces/InteractionResponses.ts +384 -0
- package/src/structures/interfaces/TextBasedChannel.ts +430 -0
- package/src/util/APITypes.ts +690 -0
- package/src/util/ActivityFlagsBitField.ts +26 -0
- package/src/util/ApplicationFlagsBitField.ts +43 -0
- package/src/util/AttachmentFlagsBitField.ts +26 -0
- package/src/util/BitField.ts +178 -0
- package/src/util/ChannelFlagsBitField.ts +43 -0
- package/src/util/Channels.ts +165 -0
- package/src/util/Colors.ts +72 -0
- package/src/util/Components.ts +285 -0
- package/src/util/Constants.ts +251 -0
- package/src/util/DataResolver.ts +146 -0
- package/src/util/Enums.ts +10 -0
- package/src/util/Events.ts +178 -0
- package/src/util/GuildMemberFlagsBitField.ts +43 -0
- package/src/util/IntentsBitField.ts +35 -0
- package/src/util/InviteFlagsBitField.ts +26 -0
- package/src/util/Invites.ts +27 -0
- package/src/util/LimitedCollection.ts +73 -0
- package/src/util/MessageFlagsBitField.ts +43 -0
- package/src/util/Options.ts +215 -0
- package/src/util/Partials.ts +50 -0
- package/src/util/PermissionsBitField.ts +113 -0
- package/src/util/RoleFlagsBitField.ts +26 -0
- package/src/util/SKUFlagsBitField.ts +26 -0
- package/src/util/ShardEvents.ts +26 -0
- package/src/util/Status.ts +16 -0
- package/src/util/Sweepers.ts +532 -0
- package/src/util/Symbols.ts +1 -0
- package/src/util/SystemChannelFlagsBitField.ts +45 -0
- package/src/util/ThreadMemberFlagsBitField.ts +33 -0
- package/src/util/Transformers.ts +123 -0
- package/src/util/UserFlagsBitField.ts +33 -0
- package/src/util/Util.ts +519 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { __exportStar } from 'tslib';
|
|
2
|
+
|
|
3
|
+
// "Root" classes (starting points)
|
|
4
|
+
export { Client } from './client/Client.js';
|
|
5
|
+
export { Shard } from './sharding/Shard.js';
|
|
6
|
+
export { ShardClientUtil } from './sharding/ShardClientUtil.js';
|
|
7
|
+
export { ShardingManager } from './sharding/ShardingManager.js';
|
|
8
|
+
|
|
9
|
+
// Errors
|
|
10
|
+
export { DiscordjsError } from './errors/DJSError.js';
|
|
11
|
+
export { DiscordjsTypeError } from './errors/DJSError.js';
|
|
12
|
+
export { DiscordjsRangeError } from './errors/DJSError.js';
|
|
13
|
+
exports.DiscordjsErrorCodes = require('./errors/ErrorCodes.js').ErrorCodes;
|
|
14
|
+
|
|
15
|
+
// Utilities
|
|
16
|
+
export { ActivityFlagsBitField } from './util/ActivityFlagsBitField.js';
|
|
17
|
+
export { ApplicationFlagsBitField } from './util/ApplicationFlagsBitField.js';
|
|
18
|
+
export { AttachmentFlagsBitField } from './util/AttachmentFlagsBitField.js';
|
|
19
|
+
export { BaseManager } from './managers/BaseManager.js';
|
|
20
|
+
export { BitField } from './util/BitField.js';
|
|
21
|
+
export { ChannelFlagsBitField } from './util/ChannelFlagsBitField.js';
|
|
22
|
+
export { Collection } from '@ovencord/collection';
|
|
23
|
+
export { Colors } from './util/Colors.js';
|
|
24
|
+
import * as Constants from './util/Constants.js';
|
|
25
|
+
export { Constants };
|
|
26
|
+
export { Events } from './util/Events.js';
|
|
27
|
+
export { GuildMemberFlagsBitField } from './util/GuildMemberFlagsBitField.js';
|
|
28
|
+
export { IntentsBitField } from './util/IntentsBitField.js';
|
|
29
|
+
export { InviteFlagsBitField } from './util/InviteFlagsBitField.js';
|
|
30
|
+
export { LimitedCollection } from './util/LimitedCollection.js';
|
|
31
|
+
export { MessageFlagsBitField } from './util/MessageFlagsBitField.js';
|
|
32
|
+
export { Options } from './util/Options.js';
|
|
33
|
+
export { Partials } from './util/Partials.js';
|
|
34
|
+
export { PermissionsBitField } from './util/PermissionsBitField.js';
|
|
35
|
+
export { RoleFlagsBitField } from './util/RoleFlagsBitField.js';
|
|
36
|
+
export { ShardEvents } from './util/ShardEvents.js';
|
|
37
|
+
export { SKUFlagsBitField } from './util/SKUFlagsBitField.js';
|
|
38
|
+
import { DiscordSnowflake as SnowflakeUtil } from '@sapphire/snowflake';
|
|
39
|
+
export { SnowflakeUtil };
|
|
40
|
+
export { Status } from './util/Status.js';
|
|
41
|
+
export { Sweepers } from './util/Sweepers.js';
|
|
42
|
+
export { SystemChannelFlagsBitField } from './util/SystemChannelFlagsBitField.js';
|
|
43
|
+
export { ThreadMemberFlagsBitField } from './util/ThreadMemberFlagsBitField.js';
|
|
44
|
+
export { UserFlagsBitField } from './util/UserFlagsBitField.js';
|
|
45
|
+
|
|
46
|
+
export * from './util/DataResolver.js';
|
|
47
|
+
|
|
48
|
+
export { cleanCodeBlockContent } from './util/Util.js';
|
|
49
|
+
export { cleanContent } from './util/Util.js';
|
|
50
|
+
export { discordSort } from './util/Util.js';
|
|
51
|
+
export { fetchRecommendedShardCount } from './util/Util.js';
|
|
52
|
+
export { flatten } from './util/Util.js';
|
|
53
|
+
export { parseEmoji } from './util/Util.js';
|
|
54
|
+
export { parseWebhookURL } from './util/Util.js';
|
|
55
|
+
export { resolveColor } from './util/Util.js';
|
|
56
|
+
export { resolveSKUId } from './util/Util.js';
|
|
57
|
+
export { verifyString } from './util/Util.js';
|
|
58
|
+
|
|
59
|
+
export { version } from '../package.json.js';
|
|
60
|
+
|
|
61
|
+
// Managers
|
|
62
|
+
export { ApplicationCommandManager } from './managers/ApplicationCommandManager.js';
|
|
63
|
+
export { ApplicationCommandPermissionsManager } from './managers/ApplicationCommandPermissionsManager.js';
|
|
64
|
+
export { ApplicationEmojiManager } from './managers/ApplicationEmojiManager.js';
|
|
65
|
+
export { AutoModerationRuleManager } from './managers/AutoModerationRuleManager.js';
|
|
66
|
+
export { CachedManager } from './managers/CachedManager.js';
|
|
67
|
+
export { ChannelManager } from './managers/ChannelManager.js';
|
|
68
|
+
export { ClientVoiceManager } from './client/voice/ClientVoiceManager.js';
|
|
69
|
+
export { DataManager } from './managers/DataManager.js';
|
|
70
|
+
export { DMMessageManager } from './managers/DMMessageManager.js';
|
|
71
|
+
export { EntitlementManager } from './managers/EntitlementManager.js';
|
|
72
|
+
export { GuildApplicationCommandManager } from './managers/GuildApplicationCommandManager.js';
|
|
73
|
+
export { GuildBanManager } from './managers/GuildBanManager.js';
|
|
74
|
+
export { GuildChannelManager } from './managers/GuildChannelManager.js';
|
|
75
|
+
export { GuildEmojiManager } from './managers/GuildEmojiManager.js';
|
|
76
|
+
export { GuildEmojiRoleManager } from './managers/GuildEmojiRoleManager.js';
|
|
77
|
+
export { GuildForumThreadManager } from './managers/GuildForumThreadManager.js';
|
|
78
|
+
export { GuildInviteManager } from './managers/GuildInviteManager.js';
|
|
79
|
+
export { GuildManager } from './managers/GuildManager.js';
|
|
80
|
+
export { GuildMemberManager } from './managers/GuildMemberManager.js';
|
|
81
|
+
export { GuildMemberRoleManager } from './managers/GuildMemberRoleManager.js';
|
|
82
|
+
export { GuildMessageManager } from './managers/GuildMessageManager.js';
|
|
83
|
+
export { GuildScheduledEventManager } from './managers/GuildScheduledEventManager.js';
|
|
84
|
+
export { GuildSoundboardSoundManager } from './managers/GuildSoundboardSoundManager.js';
|
|
85
|
+
export { GuildStickerManager } from './managers/GuildStickerManager.js';
|
|
86
|
+
export { GuildTextThreadManager } from './managers/GuildTextThreadManager.js';
|
|
87
|
+
export { MessageManager } from './managers/MessageManager.js';
|
|
88
|
+
export { PermissionOverwriteManager } from './managers/PermissionOverwriteManager.js';
|
|
89
|
+
export { PollAnswerVoterManager } from './managers/PollAnswerVoterManager.js';
|
|
90
|
+
export { PresenceManager } from './managers/PresenceManager.js';
|
|
91
|
+
export { ReactionManager } from './managers/ReactionManager.js';
|
|
92
|
+
export { ReactionUserManager } from './managers/ReactionUserManager.js';
|
|
93
|
+
export { RoleManager } from './managers/RoleManager.js';
|
|
94
|
+
export { StageInstanceManager } from './managers/StageInstanceManager.js';
|
|
95
|
+
export { SubscriptionManager } from './managers/SubscriptionManager.js';
|
|
96
|
+
export { ThreadManager } from './managers/ThreadManager.js';
|
|
97
|
+
export { ThreadMemberManager } from './managers/ThreadMemberManager.js';
|
|
98
|
+
export { UserManager } from './managers/UserManager.js';
|
|
99
|
+
export { VoiceStateManager } from './managers/VoiceStateManager.js';
|
|
100
|
+
|
|
101
|
+
// Structures
|
|
102
|
+
export { ActionRow } from './structures/ActionRow.js';
|
|
103
|
+
export { Activity } from './structures/Presence.js';
|
|
104
|
+
export { AnnouncementChannel } from './structures/AnnouncementChannel.js';
|
|
105
|
+
export { AnonymousGuild } from './structures/AnonymousGuild.js';
|
|
106
|
+
export { AuthorizingIntegrationOwners } from './structures/AuthorizingIntegrationOwners.js';
|
|
107
|
+
export { Application } from './structures/interfaces/Application.js';
|
|
108
|
+
export { ApplicationCommand } from './structures/ApplicationCommand.js';
|
|
109
|
+
export { ApplicationEmoji } from './structures/ApplicationEmoji.js';
|
|
110
|
+
export { ApplicationRoleConnectionMetadata } from './structures/ApplicationRoleConnectionMetadata.js';
|
|
111
|
+
export { Attachment } from './structures/Attachment.js';
|
|
112
|
+
export { AutocompleteInteraction } from './structures/AutocompleteInteraction.js';
|
|
113
|
+
export { AutoModerationActionExecution } from './structures/AutoModerationActionExecution.js';
|
|
114
|
+
export { AutoModerationRule } from './structures/AutoModerationRule.js';
|
|
115
|
+
export { Base } from './structures/Base.js';
|
|
116
|
+
export { BaseChannel } from './structures/BaseChannel.js';
|
|
117
|
+
export { BaseGuild } from './structures/BaseGuild.js';
|
|
118
|
+
export { BaseGuildEmoji } from './structures/BaseGuildEmoji.js';
|
|
119
|
+
export { BaseGuildTextChannel } from './structures/BaseGuildTextChannel.js';
|
|
120
|
+
export { BaseGuildVoiceChannel } from './structures/BaseGuildVoiceChannel.js';
|
|
121
|
+
export { BaseInteraction } from './structures/BaseInteraction.js';
|
|
122
|
+
export { BaseInvite } from './structures/BaseInvite.js';
|
|
123
|
+
export { BaseSelectMenuComponent } from './structures/BaseSelectMenuComponent.js';
|
|
124
|
+
export { ButtonComponent } from './structures/ButtonComponent.js';
|
|
125
|
+
export { ButtonInteraction } from './structures/ButtonInteraction.js';
|
|
126
|
+
export { CategoryChannel } from './structures/CategoryChannel.js';
|
|
127
|
+
export { ChannelSelectMenuComponent } from './structures/ChannelSelectMenuComponent.js';
|
|
128
|
+
export { ChannelSelectMenuInteraction } from './structures/ChannelSelectMenuInteraction.js';
|
|
129
|
+
export { ChatInputCommandInteraction } from './structures/ChatInputCommandInteraction.js';
|
|
130
|
+
export { ClientApplication } from './structures/ClientApplication.js';
|
|
131
|
+
export { ClientPresence } from './structures/ClientPresence.js';
|
|
132
|
+
export { ClientUser } from './structures/ClientUser.js';
|
|
133
|
+
export { Collector } from './structures/interfaces/Collector.js';
|
|
134
|
+
export { CommandInteraction } from './structures/CommandInteraction.js';
|
|
135
|
+
export { CommandInteractionOptionResolver } from './structures/CommandInteractionOptionResolver.js';
|
|
136
|
+
export { Component } from './structures/Component.js';
|
|
137
|
+
export { ContainerComponent } from './structures/ContainerComponent.js';
|
|
138
|
+
export { ContextMenuCommandInteraction } from './structures/ContextMenuCommandInteraction.js';
|
|
139
|
+
export { DirectoryChannel } from './structures/DirectoryChannel.js';
|
|
140
|
+
export { DMChannel } from './structures/DMChannel.js';
|
|
141
|
+
export { Embed } from './structures/Embed.js';
|
|
142
|
+
export { Emoji } from './structures/Emoji.js';
|
|
143
|
+
export { Entitlement } from './structures/Entitlement.js';
|
|
144
|
+
export { FileComponent } from './structures/FileComponent.js';
|
|
145
|
+
export { ForumChannel } from './structures/ForumChannel.js';
|
|
146
|
+
export { GroupDMInvite } from './structures/GroupDMInvite.js';
|
|
147
|
+
export { Guild } from './structures/Guild.js';
|
|
148
|
+
export { GuildAuditLogs } from './structures/GuildAuditLogs.js';
|
|
149
|
+
export { GuildAuditLogsEntry } from './structures/GuildAuditLogsEntry.js';
|
|
150
|
+
export { GuildBan } from './structures/GuildBan.js';
|
|
151
|
+
export { GuildChannel } from './structures/GuildChannel.js';
|
|
152
|
+
export { GuildEmoji } from './structures/GuildEmoji.js';
|
|
153
|
+
export { GuildInvite } from './structures/GuildInvite.js';
|
|
154
|
+
export { GuildMember } from './structures/GuildMember.js';
|
|
155
|
+
export { GuildOnboarding } from './structures/GuildOnboarding.js';
|
|
156
|
+
export { GuildOnboardingPrompt } from './structures/GuildOnboardingPrompt.js';
|
|
157
|
+
export { GuildOnboardingPromptOption } from './structures/GuildOnboardingPromptOption.js';
|
|
158
|
+
export { GuildPreview } from './structures/GuildPreview.js';
|
|
159
|
+
export { GuildPreviewEmoji } from './structures/GuildPreviewEmoji.js';
|
|
160
|
+
export { GuildScheduledEvent } from './structures/GuildScheduledEvent.js';
|
|
161
|
+
export { GuildTemplate } from './structures/GuildTemplate.js';
|
|
162
|
+
export { Integration } from './structures/Integration.js';
|
|
163
|
+
export { IntegrationApplication } from './structures/IntegrationApplication.js';
|
|
164
|
+
export { InteractionCallback } from './structures/InteractionCallback.js';
|
|
165
|
+
export { InteractionCallbackResource } from './structures/InteractionCallbackResource.js';
|
|
166
|
+
export { InteractionCallbackResponse } from './structures/InteractionCallbackResponse.js';
|
|
167
|
+
export { InteractionCollector } from './structures/InteractionCollector.js';
|
|
168
|
+
export { InteractionWebhook } from './structures/InteractionWebhook.js';
|
|
169
|
+
export { InviteGuild } from './structures/InviteGuild.js';
|
|
170
|
+
export { LabelComponent } from './structures/LabelComponent.js';
|
|
171
|
+
export { MediaChannel } from './structures/MediaChannel.js';
|
|
172
|
+
export { MediaGalleryComponent } from './structures/MediaGalleryComponent.js';
|
|
173
|
+
export { MediaGalleryItem } from './structures/MediaGalleryItem.js';
|
|
174
|
+
export { MentionableSelectMenuComponent } from './structures/MentionableSelectMenuComponent.js';
|
|
175
|
+
export { MentionableSelectMenuInteraction } from './structures/MentionableSelectMenuInteraction.js';
|
|
176
|
+
export { MentionableSelectMenuInteraction } from './structures/MentionableSelectMenuInteraction.js';
|
|
177
|
+
export { Message } from './structures/Message.js';
|
|
178
|
+
export { MessageCollector } from './structures/MessageCollector.js';
|
|
179
|
+
export { MessageComponentInteraction } from './structures/MessageComponentInteraction.js';
|
|
180
|
+
export { MessageContextMenuCommandInteraction } from './structures/MessageContextMenuCommandInteraction.js';
|
|
181
|
+
export { MessageMentions } from './structures/MessageMentions.js';
|
|
182
|
+
export { MessagePayload } from './structures/MessagePayload.js';
|
|
183
|
+
export { MessageReaction } from './structures/MessageReaction.js';
|
|
184
|
+
export { ModalComponentResolver } from './structures/ModalComponentResolver.js';
|
|
185
|
+
export { ModalSubmitInteraction } from './structures/ModalSubmitInteraction.js';
|
|
186
|
+
export { OAuth2Guild } from './structures/OAuth2Guild.js';
|
|
187
|
+
export { PartialGroupDMChannel } from './structures/PartialGroupDMChannel.js';
|
|
188
|
+
export { PermissionOverwrites } from './structures/PermissionOverwrites.js';
|
|
189
|
+
export { Poll } from './structures/Poll.js';
|
|
190
|
+
export { PollAnswer } from './structures/PollAnswer.js';
|
|
191
|
+
export { PrimaryEntryPointCommandInteraction } from './structures/PrimaryEntryPointCommandInteraction.js';
|
|
192
|
+
export { Presence } from './structures/Presence.js';
|
|
193
|
+
export { ReactionCollector } from './structures/ReactionCollector.js';
|
|
194
|
+
export { ReactionEmoji } from './structures/ReactionEmoji.js';
|
|
195
|
+
export { RichPresenceAssets } from './structures/Presence.js';
|
|
196
|
+
export { Role } from './structures/Role.js';
|
|
197
|
+
export { RoleSelectMenuComponent } from './structures/RoleSelectMenuComponent.js';
|
|
198
|
+
export { RoleSelectMenuInteraction } from './structures/RoleSelectMenuInteraction.js';
|
|
199
|
+
export { SectionComponent } from './structures/SectionComponent.js';
|
|
200
|
+
export { SeparatorComponent } from './structures/SeparatorComponent.js';
|
|
201
|
+
export { SKU } from './structures/SKU.js';
|
|
202
|
+
export { SoundboardSound } from './structures/SoundboardSound.js';
|
|
203
|
+
export { StageChannel } from './structures/StageChannel.js';
|
|
204
|
+
export { StageInstance } from './structures/StageInstance.js';
|
|
205
|
+
export { Sticker } from './structures/Sticker.js';
|
|
206
|
+
export { StickerPack } from './structures/StickerPack.js';
|
|
207
|
+
export { StringSelectMenuComponent } from './structures/StringSelectMenuComponent.js';
|
|
208
|
+
export { StringSelectMenuInteraction } from './structures/StringSelectMenuInteraction.js';
|
|
209
|
+
export { Subscription } from './structures/Subscription.js';
|
|
210
|
+
export { Team } from './structures/Team.js';
|
|
211
|
+
export { TeamMember } from './structures/TeamMember.js';
|
|
212
|
+
export { TextChannel } from './structures/TextChannel.js';
|
|
213
|
+
export { TextDisplayComponent } from './structures/TextDisplayComponent.js';
|
|
214
|
+
export { TextInputComponent } from './structures/TextInputComponent.js';
|
|
215
|
+
export { ThreadChannel } from './structures/ThreadChannel.js';
|
|
216
|
+
export { ThreadMember } from './structures/ThreadMember.js';
|
|
217
|
+
export { ThreadOnlyChannel } from './structures/ThreadOnlyChannel.js';
|
|
218
|
+
export { ThumbnailComponent } from './structures/ThumbnailComponent.js';
|
|
219
|
+
export { Typing } from './structures/Typing.js';
|
|
220
|
+
export { UnfurledMediaItem } from './structures/UnfurledMediaItem.js';
|
|
221
|
+
export { User } from './structures/User.js';
|
|
222
|
+
export { UserContextMenuCommandInteraction } from './structures/UserContextMenuCommandInteraction.js';
|
|
223
|
+
export { UserSelectMenuComponent } from './structures/UserSelectMenuComponent.js';
|
|
224
|
+
export { UserSelectMenuInteraction } from './structures/UserSelectMenuInteraction.js';
|
|
225
|
+
export { VoiceChannel } from './structures/VoiceChannel.js';
|
|
226
|
+
export { VoiceChannelEffect } from './structures/VoiceChannelEffect.js';
|
|
227
|
+
export { VoiceRegion } from './structures/VoiceRegion.js';
|
|
228
|
+
export { VoiceState } from './structures/VoiceState.js';
|
|
229
|
+
export { Webhook } from './structures/Webhook.js';
|
|
230
|
+
export { WelcomeChannel } from './structures/WelcomeChannel.js';
|
|
231
|
+
export { WelcomeScreen } from './structures/WelcomeScreen.js';
|
|
232
|
+
export { Widget } from './structures/Widget.js';
|
|
233
|
+
export { WidgetMember } from './structures/WidgetMember.js';
|
|
234
|
+
|
|
235
|
+
// External
|
|
236
|
+
export * from 'discord-api-types/v10';
|
|
237
|
+
export * from '@ovencord/builders';
|
|
238
|
+
export * from '@ovencord/formatters';
|
|
239
|
+
export * from '@ovencord/rest';
|
|
240
|
+
export * from '@ovencord/util';
|
|
241
|
+
export * from '@ovencord/ws';
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import { Collection } from '@ovencord/collection';
|
|
2
|
+
import { makeURLSearchParams } from '@ovencord/rest';
|
|
3
|
+
import { isJSONEncodable } from '@ovencord/util';
|
|
4
|
+
import { Routes } from 'discord-api-types/v10';
|
|
5
|
+
import { DiscordjsTypeError, ErrorCodes } from '../errors/index.js';
|
|
6
|
+
import { ApplicationCommand } from '../structures/ApplicationCommand.js';
|
|
7
|
+
import { PermissionsBitField } from '../util/PermissionsBitField.js';
|
|
8
|
+
import { ApplicationCommandPermissionsManager } from './ApplicationCommandPermissionsManager.js';
|
|
9
|
+
import { CachedManager } from './CachedManager.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Manages API methods for application commands and stores their cache.
|
|
13
|
+
*
|
|
14
|
+
* @extends {CachedManager}
|
|
15
|
+
*/
|
|
16
|
+
export class ApplicationCommandManager extends CachedManager {
|
|
17
|
+
public client: any;
|
|
18
|
+
public permissions: any;
|
|
19
|
+
constructor(client, iterable) {
|
|
20
|
+
super(client, ApplicationCommand, iterable);
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The manager for permissions of arbitrary commands on arbitrary guilds
|
|
24
|
+
*
|
|
25
|
+
* @type {ApplicationCommandPermissionsManager}
|
|
26
|
+
*/
|
|
27
|
+
this.permissions = new ApplicationCommandPermissionsManager(this);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The cache of this manager
|
|
32
|
+
*
|
|
33
|
+
* @type {Collection<Snowflake, ApplicationCommand>}
|
|
34
|
+
* @name ApplicationCommandManager#cache
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
_add(data, cache, guildId) {
|
|
38
|
+
return super._add(data, cache, { extras: [this.guild, guildId] });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The APIRouter path to the commands
|
|
43
|
+
*
|
|
44
|
+
* @param {Object} [options] The options
|
|
45
|
+
* @param {Snowflake} [options.id] The application command's id
|
|
46
|
+
* @param {Snowflake} [options.guildId] The guild's id to use in the path,
|
|
47
|
+
* ignored when using a {@link GuildApplicationCommandManager}
|
|
48
|
+
* @returns {string}
|
|
49
|
+
* @private
|
|
50
|
+
*/
|
|
51
|
+
commandPath({ id, guildId } = {}) {
|
|
52
|
+
if (this.guild ?? guildId) {
|
|
53
|
+
if (id) {
|
|
54
|
+
return Routes.applicationGuildCommand(this.client.application.id, this.guild?.id ?? guildId, id);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return Routes.applicationGuildCommands(this.client.application.id, this.guild?.id ?? guildId);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (id) {
|
|
61
|
+
return Routes.applicationCommand(this.client.application.id, id);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return Routes.applicationCommands(this.client.application.id);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Data that resolves to give an ApplicationCommand object. This can be:
|
|
69
|
+
* - An ApplicationCommand object
|
|
70
|
+
* - A Snowflake
|
|
71
|
+
*
|
|
72
|
+
* @typedef {ApplicationCommand|Snowflake} ApplicationCommandResolvable
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Data that resolves to the data of an ApplicationCommand
|
|
77
|
+
*
|
|
78
|
+
* @typedef {ApplicationCommandData|APIApplicationCommand} ApplicationCommandDataResolvable
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Options used to fetch data from Discord
|
|
83
|
+
*
|
|
84
|
+
* @typedef {Object} BaseFetchOptions
|
|
85
|
+
* @property {boolean} [cache=true] Whether to cache the fetched data if it wasn't already
|
|
86
|
+
* @property {boolean} [force=false] Whether to skip the cache check and request the API
|
|
87
|
+
*/
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Options used to fetch Application Commands from Discord
|
|
91
|
+
*
|
|
92
|
+
* @typedef {BaseFetchOptions} FetchApplicationCommandOptions
|
|
93
|
+
* @property {Snowflake} [id] The command's id to fetch
|
|
94
|
+
* @property {Snowflake} [guildId] The guild's id to fetch commands for, for when the guild is not cached
|
|
95
|
+
* @property {Locale} [locale] The locale to use when fetching this command
|
|
96
|
+
* @property {boolean} [withLocalizations] Whether to fetch all localization data
|
|
97
|
+
*/
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Obtains one or multiple application commands from Discord, or the cache if it's already available.
|
|
101
|
+
*
|
|
102
|
+
* @param {Snowflake|FetchApplicationCommandOptions} [options] Options for fetching application command(s)
|
|
103
|
+
* @returns {Promise<ApplicationCommand|Collection<Snowflake, ApplicationCommand>>}
|
|
104
|
+
* @example
|
|
105
|
+
* // Fetch a single command
|
|
106
|
+
* client.application.commands.fetch('123456789012345678')
|
|
107
|
+
* .then(command => console.log(`Fetched command ${command.name}`))
|
|
108
|
+
* .catch(console.error);
|
|
109
|
+
* @example
|
|
110
|
+
* // Fetch all commands
|
|
111
|
+
* client.application.commands.fetch()
|
|
112
|
+
* .then(commands => console.log(`Fetched ${commands.size} commands`))
|
|
113
|
+
* .catch(console.error);
|
|
114
|
+
* @example
|
|
115
|
+
* // Fetch all commands in a guild
|
|
116
|
+
* guild.commands.fetch()
|
|
117
|
+
* .then(commands => console.log(`Fetched ${commands.size} commands`))
|
|
118
|
+
* .catch(console.error);
|
|
119
|
+
* @example
|
|
120
|
+
* // Fetch a single command without checking cache
|
|
121
|
+
* guild.commands.fetch({ id: '123456789012345678', force: true })
|
|
122
|
+
* .then(command => console.log(`Fetched command ${command.name}`))
|
|
123
|
+
* .catch(console.error)
|
|
124
|
+
*/
|
|
125
|
+
async fetch(options) {
|
|
126
|
+
if (!options) return this._fetchMany();
|
|
127
|
+
|
|
128
|
+
if (typeof options === 'string') return this._fetchSingle({ id: options });
|
|
129
|
+
|
|
130
|
+
const { cache, force, guildId, id, locale, withLocalizations } = options;
|
|
131
|
+
|
|
132
|
+
if (id) return this._fetchSingle({ cache, force, guildId, id });
|
|
133
|
+
|
|
134
|
+
return this._fetchMany({ cache, guildId, locale, withLocalizations });
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
async _fetchSingle({ cache, force = false, guildId, id }) {
|
|
138
|
+
if (!force) {
|
|
139
|
+
const existing = this.cache.get(id);
|
|
140
|
+
if (existing) return existing;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const command = await this.client.rest.get(this.commandPath({ id, guildId }));
|
|
144
|
+
return this._add(command, cache);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
async _fetchMany({ cache, guildId, locale, withLocalizations } = {}) {
|
|
148
|
+
const data = await this.client.rest.get(this.commandPath({ guildId }), {
|
|
149
|
+
headers: {
|
|
150
|
+
'X-Discord-Locale': locale,
|
|
151
|
+
},
|
|
152
|
+
query: makeURLSearchParams({ with_localizations: withLocalizations }),
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
return data.reduce((coll, command) => coll.set(command.id, this._add(command, cache, guildId)), new Collection());
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Creates an application command.
|
|
160
|
+
*
|
|
161
|
+
* @param {ApplicationCommandDataResolvable} command The command
|
|
162
|
+
* @param {Snowflake} [guildId] The guild's id to create this command in,
|
|
163
|
+
* ignored when using a {@link GuildApplicationCommandManager}
|
|
164
|
+
* @returns {Promise<ApplicationCommand>}
|
|
165
|
+
* @example
|
|
166
|
+
* // Create a new command
|
|
167
|
+
* client.application.commands.create({
|
|
168
|
+
* name: 'test',
|
|
169
|
+
* description: 'A test command',
|
|
170
|
+
* })
|
|
171
|
+
* .then(console.log)
|
|
172
|
+
* .catch(console.error);
|
|
173
|
+
*/
|
|
174
|
+
async create(command, guildId) {
|
|
175
|
+
const data = await this.client.rest.post(this.commandPath({ guildId }), {
|
|
176
|
+
body: this.constructor.transformCommand(command),
|
|
177
|
+
});
|
|
178
|
+
return this._add(data, true, guildId);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Sets all the commands for this application or guild.
|
|
183
|
+
*
|
|
184
|
+
* @param {ApplicationCommandDataResolvable[]} commands The commands
|
|
185
|
+
* @param {Snowflake} [guildId] The guild's id to create the commands in,
|
|
186
|
+
* ignored when using a {@link GuildApplicationCommandManager}
|
|
187
|
+
* @returns {Promise<Collection<Snowflake, ApplicationCommand>>}
|
|
188
|
+
* @example
|
|
189
|
+
* // Set all commands to just this one
|
|
190
|
+
* client.application.commands.set([
|
|
191
|
+
* {
|
|
192
|
+
* name: 'test',
|
|
193
|
+
* description: 'A test command',
|
|
194
|
+
* },
|
|
195
|
+
* ])
|
|
196
|
+
* .then(console.log)
|
|
197
|
+
* .catch(console.error);
|
|
198
|
+
* @example
|
|
199
|
+
* // Remove all commands
|
|
200
|
+
* guild.commands.set([])
|
|
201
|
+
* .then(console.log)
|
|
202
|
+
* .catch(console.error);
|
|
203
|
+
*/
|
|
204
|
+
async set(commands, guildId) {
|
|
205
|
+
const data = await this.client.rest.put(this.commandPath({ guildId }), {
|
|
206
|
+
body: commands.map(command => this.constructor.transformCommand(command)),
|
|
207
|
+
});
|
|
208
|
+
return data.reduce(
|
|
209
|
+
(collection, command) => collection.set(command.id, this._add(command, true, guildId)),
|
|
210
|
+
new Collection(),
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Edits an application command.
|
|
216
|
+
*
|
|
217
|
+
* @param {ApplicationCommandResolvable} command The command to edit
|
|
218
|
+
* @param {Partial<ApplicationCommandDataResolvable>} data The data to update the command with
|
|
219
|
+
* @param {Snowflake} [guildId] The guild's id where the command registered,
|
|
220
|
+
* ignored when using a {@link GuildApplicationCommandManager}
|
|
221
|
+
* @returns {Promise<ApplicationCommand>}
|
|
222
|
+
* @example
|
|
223
|
+
* // Edit an existing command
|
|
224
|
+
* client.application.commands.edit('123456789012345678', {
|
|
225
|
+
* description: 'New description',
|
|
226
|
+
* })
|
|
227
|
+
* .then(console.log)
|
|
228
|
+
* .catch(console.error);
|
|
229
|
+
*/
|
|
230
|
+
async edit(command, data, guildId) {
|
|
231
|
+
const id = this.resolveId(command);
|
|
232
|
+
if (!id) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'command', 'ApplicationCommandResolvable');
|
|
233
|
+
|
|
234
|
+
const patched = await this.client.rest.patch(this.commandPath({ id, guildId }), {
|
|
235
|
+
body: this.constructor.transformCommand(data),
|
|
236
|
+
});
|
|
237
|
+
return this._add(patched, true, guildId);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* Deletes an application command.
|
|
242
|
+
*
|
|
243
|
+
* @param {ApplicationCommandResolvable} command The command to delete
|
|
244
|
+
* @param {Snowflake} [guildId] The guild's id where the command is registered,
|
|
245
|
+
* ignored when using a {@link GuildApplicationCommandManager}
|
|
246
|
+
* @returns {Promise<?ApplicationCommand>}
|
|
247
|
+
* @example
|
|
248
|
+
* // Delete a command
|
|
249
|
+
* guild.commands.delete('123456789012345678')
|
|
250
|
+
* .then(console.log)
|
|
251
|
+
* .catch(console.error);
|
|
252
|
+
*/
|
|
253
|
+
async delete(command, guildId) {
|
|
254
|
+
const id = this.resolveId(command);
|
|
255
|
+
if (!id) throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'command', 'ApplicationCommandResolvable');
|
|
256
|
+
|
|
257
|
+
await this.client.rest.delete(this.commandPath({ id, guildId }));
|
|
258
|
+
|
|
259
|
+
const cached = this.cache.get(id);
|
|
260
|
+
this.cache.delete(id);
|
|
261
|
+
return cached ?? null;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Transforms an {@link ApplicationCommandData} object into something that can be used with the API.
|
|
266
|
+
*
|
|
267
|
+
* @param {ApplicationCommandDataResolvable} command The command to transform
|
|
268
|
+
* @returns {APIApplicationCommand}
|
|
269
|
+
* @private
|
|
270
|
+
*/
|
|
271
|
+
static transformCommand(command) {
|
|
272
|
+
if (isJSONEncodable(command)) return command.toJSON();
|
|
273
|
+
|
|
274
|
+
let default_member_permissions;
|
|
275
|
+
|
|
276
|
+
if ('default_member_permissions' in command) {
|
|
277
|
+
default_member_permissions = command.default_member_permissions
|
|
278
|
+
? new PermissionsBitField(BigInt(command.default_member_permissions)).bitfield.toString()
|
|
279
|
+
: command.default_member_permissions;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if ('defaultMemberPermissions' in command) {
|
|
283
|
+
default_member_permissions =
|
|
284
|
+
command.defaultMemberPermissions === null
|
|
285
|
+
? command.defaultMemberPermissions
|
|
286
|
+
: new PermissionsBitField(command.defaultMemberPermissions).bitfield.toString();
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
return {
|
|
290
|
+
name: command.name,
|
|
291
|
+
name_localizations: command.nameLocalizations ?? command.name_localizations,
|
|
292
|
+
description: command.description,
|
|
293
|
+
nsfw: command.nsfw,
|
|
294
|
+
description_localizations: command.descriptionLocalizations ?? command.description_localizations,
|
|
295
|
+
type: command.type,
|
|
296
|
+
options: command.options?.map(option => ApplicationCommand.transformOption(option)),
|
|
297
|
+
default_member_permissions,
|
|
298
|
+
integration_types: command.integrationTypes ?? command.integration_types,
|
|
299
|
+
contexts: command.contexts,
|
|
300
|
+
handler: command.handler,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
}
|