@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
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { makeURLSearchParams } from '@ovencord/rest';
|
|
2
|
+
import { isJSONEncodable } from '@ovencord/util';
|
|
3
|
+
import { InteractionResponseType, MessageFlags, Routes, InteractionType } from 'discord-api-types/v10';
|
|
4
|
+
import { DiscordjsError, ErrorCodes } from '../../errors/index.js';
|
|
5
|
+
import { MessageFlagsBitField } from '../../util/MessageFlagsBitField.js';
|
|
6
|
+
import { InteractionCallbackResponse } from '../InteractionCallbackResponse.js';
|
|
7
|
+
import { InteractionCollector } from '../InteractionCollector.js';
|
|
8
|
+
import { MessagePayload } from '../MessagePayload.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Interface for classes that support shared interaction response types.
|
|
12
|
+
*
|
|
13
|
+
* @interface
|
|
14
|
+
*/
|
|
15
|
+
export class InteractionResponses {
|
|
16
|
+
public deferred: any;
|
|
17
|
+
public ephemeral: any;
|
|
18
|
+
public replied: any;
|
|
19
|
+
/**
|
|
20
|
+
* Options for deferring the reply to an {@link BaseInteraction}.
|
|
21
|
+
*
|
|
22
|
+
* @typedef {Object} InteractionDeferReplyOptions
|
|
23
|
+
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
|
24
|
+
* @property {MessageFlagsResolvable} [flags] Flags for the reply.
|
|
25
|
+
* <info>Only `MessageFlags.Ephemeral` can be set.</info>
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Options for deferring and updating the reply to a {@link MessageComponentInteraction}.
|
|
30
|
+
*
|
|
31
|
+
* @typedef {Object} InteractionDeferUpdateOptions
|
|
32
|
+
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Options for a reply to a {@link BaseInteraction}.
|
|
37
|
+
*
|
|
38
|
+
* @typedef {BaseMessageOptionsWithPoll} InteractionReplyOptions
|
|
39
|
+
* @property {boolean} [tts=false] Whether the message should be spoken aloud
|
|
40
|
+
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
|
41
|
+
* @property {MessageFlagsResolvable} [flags] Which flags to set for the message.
|
|
42
|
+
* <info>Only {@link MessageFlags.Ephemeral}, {@link MessageFlags.SuppressEmbeds},
|
|
43
|
+
* {@link MessageFlags.SuppressNotifications}, and {@link MessageFlags.IsVoiceMessage} can be set.</info>
|
|
44
|
+
*/
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Options for updating the message received from a {@link MessageComponentInteraction}.
|
|
48
|
+
*
|
|
49
|
+
* @typedef {MessageEditOptions} InteractionUpdateOptions
|
|
50
|
+
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Options for launching activity in response to a {@link BaseInteraction}
|
|
55
|
+
*
|
|
56
|
+
* @typedef {Object} LaunchActivityOptions
|
|
57
|
+
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Options for showing a modal in response to a {@link BaseInteraction}
|
|
62
|
+
*
|
|
63
|
+
* @typedef {Object} ShowModalOptions
|
|
64
|
+
* @property {boolean} [withResponse] Whether to return an {@link InteractionCallbackResponse} as the response
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Defers the reply to this interaction.
|
|
69
|
+
*
|
|
70
|
+
* @param {InteractionDeferReplyOptions} [options] Options for deferring the reply to this interaction
|
|
71
|
+
* @returns {Promise<InteractionCallbackResponse|undefined>}
|
|
72
|
+
* @example
|
|
73
|
+
* // Defer the reply to this interaction
|
|
74
|
+
* interaction.deferReply()
|
|
75
|
+
* .then(console.log)
|
|
76
|
+
* .catch(console.error)
|
|
77
|
+
* @example
|
|
78
|
+
* // Defer to send an ephemeral reply later
|
|
79
|
+
* interaction.deferReply({ flags: MessageFlags.Ephemeral })
|
|
80
|
+
* .then(console.log)
|
|
81
|
+
* .catch(console.error);
|
|
82
|
+
*/
|
|
83
|
+
async deferReply(options = {}) {
|
|
84
|
+
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
85
|
+
|
|
86
|
+
const resolvedFlags = new MessageFlagsBitField(options.flags);
|
|
87
|
+
|
|
88
|
+
const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
|
89
|
+
body: {
|
|
90
|
+
type: InteractionResponseType.DeferredChannelMessageWithSource,
|
|
91
|
+
data: {
|
|
92
|
+
flags: resolvedFlags.bitfield,
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
auth: false,
|
|
96
|
+
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
this.deferred = true;
|
|
100
|
+
this.ephemeral = resolvedFlags.has(MessageFlags.Ephemeral);
|
|
101
|
+
|
|
102
|
+
return options.withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Creates a reply to this interaction.
|
|
107
|
+
* <info>Use the `withResponse` option to get the interaction callback response.</info>
|
|
108
|
+
*
|
|
109
|
+
* @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
|
|
110
|
+
* @returns {Promise<InteractionCallbackResponse|undefined>}
|
|
111
|
+
* @example
|
|
112
|
+
* // Reply to the interaction and fetch the response
|
|
113
|
+
* interaction.reply({ content: 'Pong!', withResponse: true })
|
|
114
|
+
* .then((response) => console.log(`Reply sent with content ${response.resource.message.content}`))
|
|
115
|
+
* .catch(console.error);
|
|
116
|
+
* @example
|
|
117
|
+
* // Create an ephemeral reply with an embed
|
|
118
|
+
* const embed = new EmbedBuilder().setDescription('Pong!');
|
|
119
|
+
*
|
|
120
|
+
* interaction.reply({ embeds: [embed], flags: MessageFlags.Ephemeral })
|
|
121
|
+
* .then(() => console.log('Reply sent.'))
|
|
122
|
+
* .catch(console.error);
|
|
123
|
+
*/
|
|
124
|
+
async reply(options) {
|
|
125
|
+
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
126
|
+
|
|
127
|
+
let messagePayload;
|
|
128
|
+
if (options instanceof MessagePayload) messagePayload = options;
|
|
129
|
+
else messagePayload = MessagePayload.create(this, options);
|
|
130
|
+
|
|
131
|
+
const { body: data, files } = await messagePayload.resolveBody().resolveFiles();
|
|
132
|
+
|
|
133
|
+
const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
|
134
|
+
body: {
|
|
135
|
+
type: InteractionResponseType.ChannelMessageWithSource,
|
|
136
|
+
data,
|
|
137
|
+
},
|
|
138
|
+
files,
|
|
139
|
+
auth: false,
|
|
140
|
+
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
this.ephemeral = Boolean(data.flags & MessageFlags.Ephemeral);
|
|
144
|
+
this.replied = true;
|
|
145
|
+
|
|
146
|
+
return options.withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Fetches a reply to this interaction.
|
|
151
|
+
*
|
|
152
|
+
* @see Webhook#fetchMessage
|
|
153
|
+
* @param {Snowflake|'@original'} [message='@original'] The response to fetch
|
|
154
|
+
* @returns {Promise<Message>}
|
|
155
|
+
* @example
|
|
156
|
+
* // Fetch the initial reply to this interaction
|
|
157
|
+
* interaction.fetchReply()
|
|
158
|
+
* .then(reply => console.log(`Replied with ${reply.content}`))
|
|
159
|
+
* .catch(console.error);
|
|
160
|
+
*/
|
|
161
|
+
async fetchReply(message = '@original') {
|
|
162
|
+
return this.webhook.fetchMessage(message);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Options that can be passed into {@link InteractionResponses#editReply}.
|
|
167
|
+
*
|
|
168
|
+
* @typedef {WebhookMessageEditOptions} InteractionEditReplyOptions
|
|
169
|
+
* @property {MessageResolvable|'@original'} [message='@original'] The response to edit
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Edits a reply to this interaction.
|
|
174
|
+
*
|
|
175
|
+
* @see Webhook#editMessage
|
|
176
|
+
* @param {string|MessagePayload|InteractionEditReplyOptions} options The new options for the message
|
|
177
|
+
* @returns {Promise<Message>}
|
|
178
|
+
* @example
|
|
179
|
+
* // Edit the initial reply to this interaction
|
|
180
|
+
* interaction.editReply('New content')
|
|
181
|
+
* .then(console.log)
|
|
182
|
+
* .catch(console.error);
|
|
183
|
+
*/
|
|
184
|
+
async editReply(options) {
|
|
185
|
+
if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied);
|
|
186
|
+
const msg = await this.webhook.editMessage(options.message ?? '@original', options);
|
|
187
|
+
this.replied = true;
|
|
188
|
+
return msg;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Deletes a reply to this interaction.
|
|
193
|
+
*
|
|
194
|
+
* @see Webhook#deleteMessage
|
|
195
|
+
* @param {MessageResolvable|'@original'} [message='@original'] The response to delete
|
|
196
|
+
* @returns {Promise<void>}
|
|
197
|
+
* @example
|
|
198
|
+
* // Delete the initial reply to this interaction
|
|
199
|
+
* interaction.deleteReply()
|
|
200
|
+
* .then(console.log)
|
|
201
|
+
* .catch(console.error);
|
|
202
|
+
*/
|
|
203
|
+
async deleteReply(message = '@original') {
|
|
204
|
+
if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied);
|
|
205
|
+
|
|
206
|
+
await this.webhook.deleteMessage(message);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Send a follow-up message to this interaction.
|
|
211
|
+
*
|
|
212
|
+
* @param {string|MessagePayload|InteractionReplyOptions} options The options for the reply
|
|
213
|
+
* @returns {Promise<Message>}
|
|
214
|
+
*/
|
|
215
|
+
async followUp(options) {
|
|
216
|
+
if (!this.deferred && !this.replied) throw new DiscordjsError(ErrorCodes.InteractionNotReplied);
|
|
217
|
+
const msg = await this.webhook.send(options);
|
|
218
|
+
this.replied = true;
|
|
219
|
+
return msg;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Defers an update to the message to which the component was attached.
|
|
224
|
+
*
|
|
225
|
+
* @param {InteractionDeferUpdateOptions} [options] Options for deferring the update to this interaction
|
|
226
|
+
* @returns {Promise<InteractionCallbackResponse|undefined>}
|
|
227
|
+
* @example
|
|
228
|
+
* // Defer updating and reset the component's loading state
|
|
229
|
+
* interaction.deferUpdate()
|
|
230
|
+
* .then(console.log)
|
|
231
|
+
* .catch(console.error);
|
|
232
|
+
*/
|
|
233
|
+
async deferUpdate(options = {}) {
|
|
234
|
+
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
235
|
+
const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
|
236
|
+
body: {
|
|
237
|
+
type: InteractionResponseType.DeferredMessageUpdate,
|
|
238
|
+
},
|
|
239
|
+
auth: false,
|
|
240
|
+
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
|
241
|
+
});
|
|
242
|
+
this.deferred = true;
|
|
243
|
+
|
|
244
|
+
return options.withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Updates the original message of the component on which the interaction was received on.
|
|
249
|
+
*
|
|
250
|
+
* @param {string|MessagePayload|InteractionUpdateOptions} [options] The options for the updated message
|
|
251
|
+
* @returns {Promise<InteractionCallbackResponse|undefined>}
|
|
252
|
+
* @example
|
|
253
|
+
* // Remove the components from the message
|
|
254
|
+
* interaction.update({
|
|
255
|
+
* content: "A component interaction was received",
|
|
256
|
+
* components: []
|
|
257
|
+
* })
|
|
258
|
+
* .then(console.log)
|
|
259
|
+
* .catch(console.error);
|
|
260
|
+
*/
|
|
261
|
+
async update(options = {}) {
|
|
262
|
+
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
263
|
+
|
|
264
|
+
let messagePayload;
|
|
265
|
+
if (options instanceof MessagePayload) messagePayload = options;
|
|
266
|
+
else messagePayload = MessagePayload.create(this, options);
|
|
267
|
+
|
|
268
|
+
const { body: data, files } = await messagePayload.resolveBody().resolveFiles();
|
|
269
|
+
|
|
270
|
+
const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
|
271
|
+
body: {
|
|
272
|
+
type: InteractionResponseType.UpdateMessage,
|
|
273
|
+
data,
|
|
274
|
+
},
|
|
275
|
+
files,
|
|
276
|
+
auth: false,
|
|
277
|
+
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
|
278
|
+
});
|
|
279
|
+
this.replied = true;
|
|
280
|
+
|
|
281
|
+
return options.withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Launches this application's activity, if enabled
|
|
286
|
+
*
|
|
287
|
+
* @param {LaunchActivityOptions} [options={}] Options for launching the activity
|
|
288
|
+
* @returns {Promise<InteractionCallbackResponse|undefined>}
|
|
289
|
+
*/
|
|
290
|
+
async launchActivity({ withResponse } = {}) {
|
|
291
|
+
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
292
|
+
const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
|
293
|
+
query: makeURLSearchParams({ with_response: withResponse ?? false }),
|
|
294
|
+
body: {
|
|
295
|
+
type: InteractionResponseType.LaunchActivity,
|
|
296
|
+
},
|
|
297
|
+
auth: false,
|
|
298
|
+
});
|
|
299
|
+
this.replied = true;
|
|
300
|
+
|
|
301
|
+
return withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Shows a modal component
|
|
306
|
+
*
|
|
307
|
+
* @param {ModalBuilder|ModalComponentData|APIModalInteractionResponseCallbackData} modal The modal to show
|
|
308
|
+
* @param {ShowModalOptions} [options={}] The options for sending this interaction response
|
|
309
|
+
* @returns {Promise<InteractionCallbackResponse|undefined>}
|
|
310
|
+
*/
|
|
311
|
+
async showModal(modal, options = {}) {
|
|
312
|
+
if (this.deferred || this.replied) throw new DiscordjsError(ErrorCodes.InteractionAlreadyReplied);
|
|
313
|
+
const response = await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
|
|
314
|
+
body: {
|
|
315
|
+
type: InteractionResponseType.Modal,
|
|
316
|
+
data: isJSONEncodable(modal) ? modal.toJSON() : this.client.options.jsonTransformer(modal),
|
|
317
|
+
},
|
|
318
|
+
auth: false,
|
|
319
|
+
query: makeURLSearchParams({ with_response: options.withResponse ?? false }),
|
|
320
|
+
});
|
|
321
|
+
this.replied = true;
|
|
322
|
+
|
|
323
|
+
return options.withResponse ? new InteractionCallbackResponse(this.client, response) : undefined;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* An object containing the same properties as {@link CollectorOptions}, but a few less:
|
|
328
|
+
*
|
|
329
|
+
* @typedef {Object} AwaitModalSubmitOptions
|
|
330
|
+
* @property {CollectorFilter} [filter] The filter applied to this collector
|
|
331
|
+
* @property {number} time Time in milliseconds to wait for an interaction before rejecting
|
|
332
|
+
*/
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* Collects a single modal submit interaction that passes the filter.
|
|
336
|
+
* The Promise will reject if the time expires.
|
|
337
|
+
*
|
|
338
|
+
* @param {AwaitModalSubmitOptions} options Options to pass to the internal collector
|
|
339
|
+
* @returns {Promise<ModalSubmitInteraction>}
|
|
340
|
+
* @example
|
|
341
|
+
* // Collect a modal submit interaction
|
|
342
|
+
* const filter = (interaction) => interaction.customId === 'modal';
|
|
343
|
+
* interaction.awaitModalSubmit({ filter, time: 15_000 })
|
|
344
|
+
* .then(interaction => console.log(`${interaction.customId} was submitted!`))
|
|
345
|
+
* .catch(console.error);
|
|
346
|
+
*/
|
|
347
|
+
async awaitModalSubmit(options) {
|
|
348
|
+
if (typeof options.time !== 'number') throw new DiscordjsError(ErrorCodes.InvalidType, 'time', 'number');
|
|
349
|
+
const _options = { ...options, max: 1, interactionType: InteractionType.ModalSubmit };
|
|
350
|
+
return new Promise((resolve, reject) => {
|
|
351
|
+
const collector = new InteractionCollector(this.client, _options);
|
|
352
|
+
collector.once('end', (interactions, reason) => {
|
|
353
|
+
const interaction = interactions.first();
|
|
354
|
+
if (interaction) resolve(interaction);
|
|
355
|
+
else reject(new DiscordjsError(ErrorCodes.InteractionCollectorError, reason));
|
|
356
|
+
});
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
static applyToClass(structure, ignore = []) {
|
|
361
|
+
const props = [
|
|
362
|
+
'deferReply',
|
|
363
|
+
'reply',
|
|
364
|
+
'fetchReply',
|
|
365
|
+
'editReply',
|
|
366
|
+
'deleteReply',
|
|
367
|
+
'followUp',
|
|
368
|
+
'deferUpdate',
|
|
369
|
+
'update',
|
|
370
|
+
'launchActivity',
|
|
371
|
+
'showModal',
|
|
372
|
+
'awaitModalSubmit',
|
|
373
|
+
];
|
|
374
|
+
|
|
375
|
+
for (const prop of props) {
|
|
376
|
+
if (ignore.includes(prop)) continue;
|
|
377
|
+
Object.defineProperty(
|
|
378
|
+
structure.prototype,
|
|
379
|
+
prop,
|
|
380
|
+
Object.getOwnPropertyDescriptor(InteractionResponses.prototype, prop),
|
|
381
|
+
);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|