seyfert 0.1.0
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 +190 -0
- package/README.md +57 -0
- package/lib/api/CDN.d.ts +220 -0
- package/lib/api/CDN.js +236 -0
- package/lib/api/REST.d.ts +127 -0
- package/lib/api/REST.js +424 -0
- package/lib/api/Router.d.ts +17 -0
- package/lib/api/Router.js +63 -0
- package/lib/api/Routes/applications.d.ts +46 -0
- package/lib/api/Routes/applications.js +2 -0
- package/lib/api/Routes/cdn.d.ts +66 -0
- package/lib/api/Routes/cdn.js +2 -0
- package/lib/api/Routes/channels.d.ts +109 -0
- package/lib/api/Routes/channels.js +2 -0
- package/lib/api/Routes/gateway.d.ts +11 -0
- package/lib/api/Routes/gateway.js +2 -0
- package/lib/api/Routes/guilds.d.ts +171 -0
- package/lib/api/Routes/guilds.js +2 -0
- package/lib/api/Routes/index.d.ts +13 -0
- package/lib/api/Routes/index.js +17 -0
- package/lib/api/Routes/interactions.d.ts +14 -0
- package/lib/api/Routes/interactions.js +2 -0
- package/lib/api/Routes/invites.d.ts +9 -0
- package/lib/api/Routes/invites.js +2 -0
- package/lib/api/Routes/stage-instances.d.ts +13 -0
- package/lib/api/Routes/stage-instances.js +2 -0
- package/lib/api/Routes/stickers.d.ts +11 -0
- package/lib/api/Routes/stickers.js +2 -0
- package/lib/api/Routes/users.d.ts +35 -0
- package/lib/api/Routes/users.js +2 -0
- package/lib/api/Routes/voice.d.ts +10 -0
- package/lib/api/Routes/voice.js +2 -0
- package/lib/api/Routes/webhooks.d.ts +29 -0
- package/lib/api/Routes/webhooks.js +2 -0
- package/lib/api/errors/DiscordAPIError.d.ts +51 -0
- package/lib/api/errors/DiscordAPIError.js +81 -0
- package/lib/api/errors/HTTPError.d.ts +20 -0
- package/lib/api/errors/HTTPError.js +28 -0
- package/lib/api/errors/RateLimitError.d.ts +19 -0
- package/lib/api/errors/RateLimitError.js +37 -0
- package/lib/api/handlers/BurstHandler.d.ts +51 -0
- package/lib/api/handlers/BurstHandler.js +124 -0
- package/lib/api/handlers/SequentialHandler.d.ts +81 -0
- package/lib/api/handlers/SequentialHandler.js +365 -0
- package/lib/api/handlers/Shared.d.ts +14 -0
- package/lib/api/handlers/Shared.js +125 -0
- package/lib/api/index.d.ts +5 -0
- package/lib/api/index.js +21 -0
- package/lib/api/interfaces/Handler.d.ts +21 -0
- package/lib/api/interfaces/Handler.js +2 -0
- package/lib/api/shared.d.ts +7 -0
- package/lib/api/shared.js +27 -0
- package/lib/api/utils/constants.d.ts +39 -0
- package/lib/api/utils/constants.js +50 -0
- package/lib/api/utils/types.d.ts +335 -0
- package/lib/api/utils/types.js +14 -0
- package/lib/api/utils/utils.d.ts +52 -0
- package/lib/api/utils/utils.js +159 -0
- package/lib/builders/ActionRow.d.ts +40 -0
- package/lib/builders/ActionRow.js +58 -0
- package/lib/builders/Attachment.d.ts +106 -0
- package/lib/builders/Attachment.js +196 -0
- package/lib/builders/Base.d.ts +10 -0
- package/lib/builders/Base.js +13 -0
- package/lib/builders/Button.d.ts +59 -0
- package/lib/builders/Button.js +94 -0
- package/lib/builders/MessageEmbed.d.ts +116 -0
- package/lib/builders/MessageEmbed.js +159 -0
- package/lib/builders/Modal.d.ts +111 -0
- package/lib/builders/Modal.js +162 -0
- package/lib/builders/SelectMenu.d.ts +201 -0
- package/lib/builders/SelectMenu.js +293 -0
- package/lib/builders/index.d.ts +12 -0
- package/lib/builders/index.js +54 -0
- package/lib/builders/types.d.ts +21 -0
- package/lib/builders/types.js +2 -0
- package/lib/cache/adapters/default.d.ts +24 -0
- package/lib/cache/adapters/default.js +118 -0
- package/lib/cache/adapters/index.d.ts +4 -0
- package/lib/cache/adapters/index.js +20 -0
- package/lib/cache/adapters/redis.d.ts +35 -0
- package/lib/cache/adapters/redis.js +180 -0
- package/lib/cache/adapters/types.d.ts +25 -0
- package/lib/cache/adapters/types.js +2 -0
- package/lib/cache/adapters/workeradapter.d.ts +24 -0
- package/lib/cache/adapters/workeradapter.js +76 -0
- package/lib/cache/index.d.ts +97 -0
- package/lib/cache/index.js +394 -0
- package/lib/cache/resources/channels.d.ts +7 -0
- package/lib/cache/resources/channels.js +20 -0
- package/lib/cache/resources/default/base.d.ts +25 -0
- package/lib/cache/resources/default/base.js +75 -0
- package/lib/cache/resources/default/guild-based.d.ts +33 -0
- package/lib/cache/resources/default/guild-based.js +91 -0
- package/lib/cache/resources/default/guild-related.d.ts +32 -0
- package/lib/cache/resources/default/guild-related.js +102 -0
- package/lib/cache/resources/emojis.d.ts +7 -0
- package/lib/cache/resources/emojis.js +17 -0
- package/lib/cache/resources/guilds.d.ts +10 -0
- package/lib/cache/resources/guilds.js +117 -0
- package/lib/cache/resources/members.d.ts +10 -0
- package/lib/cache/resources/members.js +41 -0
- package/lib/cache/resources/presence.d.ts +9 -0
- package/lib/cache/resources/presence.js +14 -0
- package/lib/cache/resources/roles.d.ts +7 -0
- package/lib/cache/resources/roles.js +17 -0
- package/lib/cache/resources/stage-instances.d.ts +5 -0
- package/lib/cache/resources/stage-instances.js +8 -0
- package/lib/cache/resources/stickers.d.ts +7 -0
- package/lib/cache/resources/stickers.js +17 -0
- package/lib/cache/resources/threads.d.ts +7 -0
- package/lib/cache/resources/threads.js +17 -0
- package/lib/cache/resources/users.d.ts +7 -0
- package/lib/cache/resources/users.js +17 -0
- package/lib/cache/resources/voice-states.d.ts +9 -0
- package/lib/cache/resources/voice-states.js +13 -0
- package/lib/client/base.d.ts +244 -0
- package/lib/client/base.js +178 -0
- package/lib/client/client.d.ts +32 -0
- package/lib/client/client.js +156 -0
- package/lib/client/httpclient.d.ts +21 -0
- package/lib/client/httpclient.js +143 -0
- package/lib/client/index.d.ts +4 -0
- package/lib/client/index.js +19 -0
- package/lib/client/oninteraction.d.ts +4 -0
- package/lib/client/oninteraction.js +180 -0
- package/lib/client/workerclient.d.ts +28 -0
- package/lib/client/workerclient.js +213 -0
- package/lib/collection.d.ts +233 -0
- package/lib/collection.js +371 -0
- package/lib/commands/applications/chat.d.ts +139 -0
- package/lib/commands/applications/chat.js +173 -0
- package/lib/commands/applications/chatcontext.d.ts +28 -0
- package/lib/commands/applications/chatcontext.js +53 -0
- package/lib/commands/applications/menu.d.ts +39 -0
- package/lib/commands/applications/menu.js +87 -0
- package/lib/commands/applications/menucontext.d.ts +25 -0
- package/lib/commands/applications/menucontext.js +64 -0
- package/lib/commands/applications/options.d.ts +67 -0
- package/lib/commands/applications/options.js +44 -0
- package/lib/commands/applications/shared.d.ts +35 -0
- package/lib/commands/applications/shared.js +2 -0
- package/lib/commands/decorators.d.ts +107 -0
- package/lib/commands/decorators.js +85 -0
- package/lib/commands/handler.d.ts +15 -0
- package/lib/commands/handler.js +140 -0
- package/lib/commands/index.d.ts +8 -0
- package/lib/commands/index.js +24 -0
- package/lib/commands/optionresolver.d.ts +49 -0
- package/lib/commands/optionresolver.js +146 -0
- package/lib/common/bot/watcher.d.ts +53 -0
- package/lib/common/bot/watcher.js +104 -0
- package/lib/common/index.d.ts +13 -0
- package/lib/common/index.js +30 -0
- package/lib/common/it/colors.d.ts +274 -0
- package/lib/common/it/colors.js +453 -0
- package/lib/common/it/constants.d.ts +36 -0
- package/lib/common/it/constants.js +40 -0
- package/lib/common/it/logger.d.ts +114 -0
- package/lib/common/it/logger.js +189 -0
- package/lib/common/it/utils.d.ts +107 -0
- package/lib/common/it/utils.js +275 -0
- package/lib/common/shorters/base.d.ts +5 -0
- package/lib/common/shorters/base.js +10 -0
- package/lib/common/shorters/channels.d.ts +90 -0
- package/lib/common/shorters/channels.js +95 -0
- package/lib/common/shorters/guilds.d.ts +389 -0
- package/lib/common/shorters/guilds.js +350 -0
- package/lib/common/shorters/members.d.ts +115 -0
- package/lib/common/shorters/members.js +179 -0
- package/lib/common/shorters/messages.d.ts +27 -0
- package/lib/common/shorters/messages.js +117 -0
- package/lib/common/shorters/roles.d.ts +12 -0
- package/lib/common/shorters/roles.js +51 -0
- package/lib/common/shorters/templates.d.ts +12 -0
- package/lib/common/shorters/templates.js +29 -0
- package/lib/common/shorters/users.d.ts +11 -0
- package/lib/common/shorters/users.js +42 -0
- package/lib/common/shorters/webhook.d.ts +33 -0
- package/lib/common/shorters/webhook.js +69 -0
- package/lib/common/types/options.d.ts +10 -0
- package/lib/common/types/options.js +2 -0
- package/lib/common/types/resolvables.d.ts +10 -0
- package/lib/common/types/resolvables.js +2 -0
- package/lib/common/types/util.d.ts +90 -0
- package/lib/common/types/util.js +2 -0
- package/lib/common/types/write.d.ts +21 -0
- package/lib/common/types/write.js +2 -0
- package/lib/components/ActionRow.d.ts +10 -0
- package/lib/components/ActionRow.js +13 -0
- package/lib/components/ButtonComponent.d.ts +19 -0
- package/lib/components/ButtonComponent.js +34 -0
- package/lib/components/ChannelSelectMenuComponent.d.ts +6 -0
- package/lib/components/ChannelSelectMenuComponent.js +12 -0
- package/lib/components/MentionableSelectMenuComponent.d.ts +4 -0
- package/lib/components/MentionableSelectMenuComponent.js +7 -0
- package/lib/components/RoleSelectMenuComponent.d.ts +4 -0
- package/lib/components/RoleSelectMenuComponent.js +7 -0
- package/lib/components/StringSelectMenuComponent.d.ts +6 -0
- package/lib/components/StringSelectMenuComponent.js +12 -0
- package/lib/components/TextInputComponent.d.ts +7 -0
- package/lib/components/TextInputComponent.js +14 -0
- package/lib/components/UserSelectMenuComponent.d.ts +4 -0
- package/lib/components/UserSelectMenuComponent.js +7 -0
- package/lib/components/command.d.ts +23 -0
- package/lib/components/command.js +15 -0
- package/lib/components/handler.d.ts +48 -0
- package/lib/components/handler.js +231 -0
- package/lib/components/index.d.ts +20 -0
- package/lib/components/index.js +55 -0
- package/lib/components/listener.d.ts +11 -0
- package/lib/components/listener.js +18 -0
- package/lib/events/event.d.ts +23 -0
- package/lib/events/event.js +2 -0
- package/lib/events/handler.d.ts +19 -0
- package/lib/events/handler.js +112 -0
- package/lib/events/hooks/application_command.d.ts +12 -0
- package/lib/events/hooks/application_command.js +8 -0
- package/lib/events/hooks/auto_moderation.d.ts +22 -0
- package/lib/events/hooks/auto_moderation.js +21 -0
- package/lib/events/hooks/channel.d.ts +11 -0
- package/lib/events/hooks/channel.js +24 -0
- package/lib/events/hooks/custom.d.ts +4 -0
- package/lib/events/hooks/custom.js +11 -0
- package/lib/events/hooks/dispatch.d.ts +5 -0
- package/lib/events/hooks/dispatch.js +12 -0
- package/lib/events/hooks/entitlement.d.ts +35 -0
- package/lib/events/hooks/entitlement.js +16 -0
- package/lib/events/hooks/guild.d.ts +228 -0
- package/lib/events/hooks/guild.js +101 -0
- package/lib/events/hooks/index.d.ts +23 -0
- package/lib/events/hooks/index.js +34 -0
- package/lib/events/hooks/integration.d.ts +94 -0
- package/lib/events/hooks/integration.js +27 -0
- package/lib/events/hooks/interactions.d.ts +4 -0
- package/lib/events/hooks/interactions.js +8 -0
- package/lib/events/hooks/invite.d.ts +21 -0
- package/lib/events/hooks/invite.js +12 -0
- package/lib/events/hooks/message.d.ts +69 -0
- package/lib/events/hooks/message.js +37 -0
- package/lib/events/hooks/presence.d.ts +27 -0
- package/lib/events/hooks/presence.js +8 -0
- package/lib/events/hooks/stage.d.ts +29 -0
- package/lib/events/hooks/stage.js +16 -0
- package/lib/events/hooks/thread.d.ts +198 -0
- package/lib/events/hooks/thread.js +29 -0
- package/lib/events/hooks/typing.d.ts +16 -0
- package/lib/events/hooks/typing.js +14 -0
- package/lib/events/hooks/user.d.ts +4 -0
- package/lib/events/hooks/user.js +8 -0
- package/lib/events/hooks/voice.d.ts +37 -0
- package/lib/events/hooks/voice.js +18 -0
- package/lib/events/hooks/webhook.d.ts +6 -0
- package/lib/events/hooks/webhook.js +8 -0
- package/lib/events/index.d.ts +2 -0
- package/lib/events/index.js +18 -0
- package/lib/index.d.ts +79 -0
- package/lib/index.js +104 -0
- package/lib/langs/handler.d.ts +11 -0
- package/lib/langs/handler.js +34 -0
- package/lib/langs/index.d.ts +2 -0
- package/lib/langs/index.js +18 -0
- package/lib/langs/router.d.ts +18 -0
- package/lib/langs/router.js +42 -0
- package/lib/structures/AnonymousGuild.d.ts +7 -0
- package/lib/structures/AnonymousGuild.js +11 -0
- package/lib/structures/AutoModerationRule.d.ts +22 -0
- package/lib/structures/AutoModerationRule.js +34 -0
- package/lib/structures/ClientUser.d.ts +25 -0
- package/lib/structures/ClientUser.js +52 -0
- package/lib/structures/Guild.d.ts +86 -0
- package/lib/structures/Guild.js +66 -0
- package/lib/structures/GuildEmoji.d.ts +29 -0
- package/lib/structures/GuildEmoji.js +47 -0
- package/lib/structures/GuildMember.d.ts +92 -0
- package/lib/structures/GuildMember.js +137 -0
- package/lib/structures/GuildPreview.d.ts +10 -0
- package/lib/structures/GuildPreview.js +14 -0
- package/lib/structures/GuildRole.d.ts +21 -0
- package/lib/structures/GuildRole.js +32 -0
- package/lib/structures/GuildTemplate.d.ts +23 -0
- package/lib/structures/GuildTemplate.js +36 -0
- package/lib/structures/Interaction.d.ts +152 -0
- package/lib/structures/Interaction.js +409 -0
- package/lib/structures/Message.d.ts +53 -0
- package/lib/structures/Message.js +123 -0
- package/lib/structures/Sticker.d.ts +27 -0
- package/lib/structures/Sticker.js +44 -0
- package/lib/structures/User.d.ts +20 -0
- package/lib/structures/User.js +37 -0
- package/lib/structures/Webhook.d.ts +42 -0
- package/lib/structures/Webhook.js +63 -0
- package/lib/structures/channels.d.ts +232 -0
- package/lib/structures/channels.js +366 -0
- package/lib/structures/extra/Base.d.ts +7 -0
- package/lib/structures/extra/Base.js +39 -0
- package/lib/structures/extra/BaseComponent.d.ts +9 -0
- package/lib/structures/extra/BaseComponent.js +12 -0
- package/lib/structures/extra/BaseGuild.d.ts +40 -0
- package/lib/structures/extra/BaseGuild.js +71 -0
- package/lib/structures/extra/BaseSelectMenuComponent.d.ts +9 -0
- package/lib/structures/extra/BaseSelectMenuComponent.js +13 -0
- package/lib/structures/extra/BitField.d.ts +14 -0
- package/lib/structures/extra/BitField.js +56 -0
- package/lib/structures/extra/DiscordBase.d.ts +18 -0
- package/lib/structures/extra/DiscordBase.js +28 -0
- package/lib/structures/extra/Permissions.d.ts +54 -0
- package/lib/structures/extra/Permissions.js +9 -0
- package/lib/structures/extra/functions.d.ts +11 -0
- package/lib/structures/extra/functions.js +69 -0
- package/lib/structures/index.d.ts +15 -0
- package/lib/structures/index.js +31 -0
- package/lib/websocket/SharedTypes.d.ts +128 -0
- package/lib/websocket/SharedTypes.js +2 -0
- package/lib/websocket/constants/index.d.ts +26 -0
- package/lib/websocket/constants/index.js +31 -0
- package/lib/websocket/discord/basesocket.d.ts +12 -0
- package/lib/websocket/discord/basesocket.js +37 -0
- package/lib/websocket/discord/events/memberUpdate.d.ts +16 -0
- package/lib/websocket/discord/events/memberUpdate.js +47 -0
- package/lib/websocket/discord/events/presenceUpdate.d.ts +24 -0
- package/lib/websocket/discord/events/presenceUpdate.js +46 -0
- package/lib/websocket/discord/handlemessage.d.ts +0 -0
- package/lib/websocket/discord/handlemessage.js +1 -0
- package/lib/websocket/discord/index.d.ts +4 -0
- package/lib/websocket/discord/index.js +20 -0
- package/lib/websocket/discord/memberUpdate.d.ts +16 -0
- package/lib/websocket/discord/memberUpdate.js +47 -0
- package/lib/websocket/discord/shard.d.ts +46 -0
- package/lib/websocket/discord/shard.js +278 -0
- package/lib/websocket/discord/sharder.d.ts +25 -0
- package/lib/websocket/discord/sharder.js +153 -0
- package/lib/websocket/discord/shared.d.ts +99 -0
- package/lib/websocket/discord/shared.js +8 -0
- package/lib/websocket/discord/worker.d.ts +43 -0
- package/lib/websocket/discord/worker.js +2 -0
- package/lib/websocket/discord/workermanager.d.ts +69 -0
- package/lib/websocket/discord/workermanager.js +273 -0
- package/lib/websocket/index.d.ts +3 -0
- package/lib/websocket/index.js +19 -0
- package/lib/websocket/structures/index.d.ts +117 -0
- package/lib/websocket/structures/index.js +261 -0
- package/lib/websocket/structures/timeout.d.ts +20 -0
- package/lib/websocket/structures/timeout.js +75 -0
- package/package.json +70 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { BaseClient } from '../client/base';
|
|
2
|
+
import { OptionResolver, type UsingClient } from '../commands';
|
|
3
|
+
import type { APIApplicationCommandAutocompleteInteraction, APIApplicationCommandInteraction, APIBaseInteraction, APIChatInputApplicationCommandInteraction, APIChatInputApplicationCommandInteractionData, APICommandAutocompleteInteractionResponseCallbackData, APIInteraction, APIInteractionResponse, APIInteractionResponseChannelMessageWithSource, APIInteractionResponseDeferredChannelMessageWithSource, APIInteractionResponseDeferredMessageUpdate, APIInteractionResponsePong, APIInteractionResponseUpdateMessage, APIMessageApplicationCommandInteraction, APIMessageApplicationCommandInteractionData, APIMessageButtonInteractionData, APIMessageComponentInteraction, APIMessageComponentSelectMenuInteraction, APIMessageStringSelectInteractionData, APIModalSubmission, APIModalSubmitInteraction, APIUserApplicationCommandInteraction, APIUserApplicationCommandInteractionData, GatewayInteractionCreateDispatchData, MessageFlags, ObjectToLower, OmitInsert, RESTPostAPIInteractionCallbackJSONBody, ToClass, When } from '../common';
|
|
4
|
+
import { ApplicationCommandType, ComponentType, InteractionResponseType, InteractionType } from '../common';
|
|
5
|
+
import type { ComponentInteractionMessageUpdate, InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, MessageCreateBodyRequest, MessageUpdateBodyRequest, MessageWebhookCreateBodyRequest, ModalCreateBodyRequest } from '../common/types/write';
|
|
6
|
+
import { InteractionGuildMember, type AllChannels } from './';
|
|
7
|
+
import { GuildRole } from './GuildRole';
|
|
8
|
+
import { Message, type WebhookMessage } from './Message';
|
|
9
|
+
import { User } from './User';
|
|
10
|
+
import { DiscordBase } from './extra/DiscordBase';
|
|
11
|
+
import { PermissionsBitField } from './extra/Permissions';
|
|
12
|
+
export type ReplyInteractionBody = {
|
|
13
|
+
type: InteractionResponseType.Modal;
|
|
14
|
+
data: ModalCreateBodyRequest;
|
|
15
|
+
} | {
|
|
16
|
+
type: InteractionResponseType.ChannelMessageWithSource | InteractionResponseType.UpdateMessage;
|
|
17
|
+
data: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest | ComponentInteractionMessageUpdate;
|
|
18
|
+
} | Exclude<RESTPostAPIInteractionCallbackJSONBody, APIInteractionResponsePong>;
|
|
19
|
+
export interface BaseInteraction extends ObjectToLower<Omit<APIBaseInteraction<InteractionType, any>, 'user' | 'member' | 'message' | 'channel' | 'type' | 'app_permissions'>> {
|
|
20
|
+
}
|
|
21
|
+
export declare class BaseInteraction<FromGuild extends boolean = boolean, Type extends APIInteraction = APIInteraction> extends DiscordBase<Type> {
|
|
22
|
+
readonly client: UsingClient;
|
|
23
|
+
protected __reply?: __InternalReplyFunction | undefined;
|
|
24
|
+
user: User;
|
|
25
|
+
member: When<FromGuild, InteractionGuildMember, undefined>;
|
|
26
|
+
channel?: AllChannels;
|
|
27
|
+
message?: Message;
|
|
28
|
+
replied?: Promise<boolean> | boolean;
|
|
29
|
+
appPermissions?: PermissionsBitField;
|
|
30
|
+
constructor(client: UsingClient, interaction: Type, __reply?: __InternalReplyFunction | undefined);
|
|
31
|
+
static transformBodyRequest(body: ReplyInteractionBody): APIInteractionResponse;
|
|
32
|
+
static transformBody<T>(body: InteractionMessageUpdateBodyRequest | MessageUpdateBodyRequest | MessageCreateBodyRequest | MessageWebhookCreateBodyRequest): T;
|
|
33
|
+
private matchReplied;
|
|
34
|
+
reply(body: ReplyInteractionBody): Promise<void>;
|
|
35
|
+
deferReply(flags?: MessageFlags): Promise<void>;
|
|
36
|
+
static from(client: BaseClient, gateway: GatewayInteractionCreateDispatchData, __reply?: __InternalReplyFunction): StringSelectMenuInteraction<string[]> | AutocompleteInteraction<boolean> | BaseInteraction<boolean, import("discord-api-types/payloads/v10/_interactions/ping").APIPingInteraction>;
|
|
37
|
+
}
|
|
38
|
+
export type AllInteractions = AutocompleteInteraction | ChatInputCommandInteraction | UserCommandInteraction | MessageCommandInteraction | ComponentInteraction | SelectMenuInteraction | ModalSubmitInteraction | BaseInteraction;
|
|
39
|
+
export interface AutocompleteInteraction extends ObjectToLower<Omit<APIApplicationCommandAutocompleteInteraction, 'user' | 'member' | 'type' | 'data' | 'message' | 'channel' | 'app_permissions'>> {
|
|
40
|
+
}
|
|
41
|
+
export declare class AutocompleteInteraction<FromGuild extends boolean = boolean> extends BaseInteraction<FromGuild, APIApplicationCommandAutocompleteInteraction> {
|
|
42
|
+
protected __reply?: __InternalReplyFunction | undefined;
|
|
43
|
+
type: InteractionType.ApplicationCommandAutocomplete;
|
|
44
|
+
data: ObjectToLower<APIApplicationCommandAutocompleteInteraction['data']>;
|
|
45
|
+
options: OptionResolver;
|
|
46
|
+
constructor(client: BaseClient, interaction: APIApplicationCommandAutocompleteInteraction, __reply?: __InternalReplyFunction | undefined);
|
|
47
|
+
getInput(): string;
|
|
48
|
+
respond(choices: APICommandAutocompleteInteractionResponseCallbackData['choices']): Promise<void>;
|
|
49
|
+
/** @intenal */
|
|
50
|
+
reply(..._args: unknown[]): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export declare class Interaction<FromGuild extends boolean = boolean, Type extends APIInteraction = APIInteraction> extends BaseInteraction<FromGuild, Type> {
|
|
53
|
+
fetchMessage(messageId: string): Promise<WebhookMessage | undefined>;
|
|
54
|
+
fetchResponse(): Promise<WebhookMessage | undefined>;
|
|
55
|
+
write<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage, void>>;
|
|
56
|
+
modal(body: ModalCreateBodyRequest): Promise<void>;
|
|
57
|
+
editOrReply<FR extends boolean = false>(body: InteractionCreateBodyRequest, fetchReply?: FR): Promise<When<FR, WebhookMessage, void>>;
|
|
58
|
+
editMessage(messageId: string, body: InteractionMessageUpdateBodyRequest): Promise<Message>;
|
|
59
|
+
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
|
|
60
|
+
deleteResponse(): Promise<void>;
|
|
61
|
+
deleteMessage(messageId: string): Promise<void>;
|
|
62
|
+
createResponse({ files, ...body }: MessageWebhookCreateBodyRequest): Promise<Message>;
|
|
63
|
+
}
|
|
64
|
+
export declare class ApplicationCommandInteraction<FromGuild extends boolean = boolean, Type extends APIApplicationCommandInteraction = APIApplicationCommandInteraction> extends Interaction<FromGuild, Type> {
|
|
65
|
+
type: ApplicationCommandType;
|
|
66
|
+
respond(data: APIInteractionResponseChannelMessageWithSource | APIInteractionResponseDeferredChannelMessageWithSource | APIInteractionResponseDeferredMessageUpdate | APIInteractionResponseUpdateMessage): Promise<void>;
|
|
67
|
+
}
|
|
68
|
+
export interface ComponentInteraction extends ObjectToLower<Omit<APIMessageComponentInteraction, 'user' | 'member' | 'type' | 'data' | 'message' | 'channel' | 'app_permissions'>> {
|
|
69
|
+
}
|
|
70
|
+
export declare class ComponentInteraction<FromGuild extends boolean = boolean, Type extends APIMessageComponentInteraction = APIMessageComponentInteraction> extends Interaction<FromGuild, Type> {
|
|
71
|
+
data: ObjectToLower<APIMessageComponentInteraction['data']>;
|
|
72
|
+
channelId: string;
|
|
73
|
+
channel: AllChannels;
|
|
74
|
+
type: InteractionType.MessageComponent;
|
|
75
|
+
update(data: ComponentInteractionMessageUpdate): Promise<void>;
|
|
76
|
+
deferUpdate(): Promise<void>;
|
|
77
|
+
get customId(): string;
|
|
78
|
+
get componentType(): ComponentType.Button | ComponentType.StringSelect | ComponentType.UserSelect | ComponentType.RoleSelect | ComponentType.MentionableSelect | ComponentType.ChannelSelect;
|
|
79
|
+
isButton(): this is ButtonInteraction;
|
|
80
|
+
isChannelSelectMenu(): this is ChannelSelectMenuInteraction;
|
|
81
|
+
isRoleSelectMenu(): this is RoleSelectMenuInteraction;
|
|
82
|
+
isMentionableSelectMenu(): this is MentionableSelectMenuInteraction;
|
|
83
|
+
isUserSelectMenu(): this is UserSelectMenuInteraction;
|
|
84
|
+
isStringSelectMenu(): this is StringSelectMenuInteraction;
|
|
85
|
+
}
|
|
86
|
+
export declare class ButtonInteraction extends ComponentInteraction {
|
|
87
|
+
data: ObjectToLower<APIMessageButtonInteractionData>;
|
|
88
|
+
}
|
|
89
|
+
export declare class SelectMenuInteraction extends ComponentInteraction {
|
|
90
|
+
protected __reply?: __InternalReplyFunction | undefined;
|
|
91
|
+
data: ObjectToLower<APIMessageComponentSelectMenuInteraction['data']>;
|
|
92
|
+
constructor(client: BaseClient, interaction: APIMessageComponentSelectMenuInteraction, __reply?: __InternalReplyFunction | undefined);
|
|
93
|
+
get values(): string[];
|
|
94
|
+
}
|
|
95
|
+
declare const StringSelectMenuInteraction_base: ToClass<Omit<SelectMenuInteraction, "data">, StringSelectMenuInteraction<string[]>>;
|
|
96
|
+
export declare class StringSelectMenuInteraction<T extends any[] = string[]> extends StringSelectMenuInteraction_base {
|
|
97
|
+
data: OmitInsert<ObjectToLower<APIMessageStringSelectInteractionData>, 'values', {
|
|
98
|
+
values: T;
|
|
99
|
+
}>;
|
|
100
|
+
values: T;
|
|
101
|
+
}
|
|
102
|
+
export declare class ChannelSelectMenuInteraction extends SelectMenuInteraction {
|
|
103
|
+
protected __reply?: __InternalReplyFunction | undefined;
|
|
104
|
+
channels: AllChannels[];
|
|
105
|
+
constructor(client: BaseClient, interaction: APIMessageComponentSelectMenuInteraction, __reply?: __InternalReplyFunction | undefined);
|
|
106
|
+
}
|
|
107
|
+
export declare class MentionableSelectMenuInteraction extends SelectMenuInteraction {
|
|
108
|
+
protected __reply?: __InternalReplyFunction | undefined;
|
|
109
|
+
roles: GuildRole[];
|
|
110
|
+
members: InteractionGuildMember[];
|
|
111
|
+
users: User[];
|
|
112
|
+
constructor(client: BaseClient, interaction: APIMessageComponentSelectMenuInteraction, __reply?: __InternalReplyFunction | undefined);
|
|
113
|
+
}
|
|
114
|
+
export declare class RoleSelectMenuInteraction extends SelectMenuInteraction {
|
|
115
|
+
protected __reply?: __InternalReplyFunction | undefined;
|
|
116
|
+
roles: GuildRole[];
|
|
117
|
+
constructor(client: BaseClient, interaction: APIMessageComponentSelectMenuInteraction, __reply?: __InternalReplyFunction | undefined);
|
|
118
|
+
}
|
|
119
|
+
export declare class UserSelectMenuInteraction extends SelectMenuInteraction {
|
|
120
|
+
protected __reply?: __InternalReplyFunction | undefined;
|
|
121
|
+
members: InteractionGuildMember[];
|
|
122
|
+
users: User[];
|
|
123
|
+
constructor(client: BaseClient, interaction: APIMessageComponentSelectMenuInteraction, __reply?: __InternalReplyFunction | undefined);
|
|
124
|
+
}
|
|
125
|
+
export declare class ChatInputCommandInteraction<FromGuild extends boolean = boolean> extends ApplicationCommandInteraction<FromGuild, APIChatInputApplicationCommandInteraction> {
|
|
126
|
+
data: ObjectToLower<APIChatInputApplicationCommandInteractionData>;
|
|
127
|
+
}
|
|
128
|
+
export declare class UserCommandInteraction<FromGuild extends boolean = boolean> extends ApplicationCommandInteraction<FromGuild, APIUserApplicationCommandInteraction> {
|
|
129
|
+
type: ApplicationCommandType.User;
|
|
130
|
+
data: ObjectToLower<APIUserApplicationCommandInteractionData>;
|
|
131
|
+
}
|
|
132
|
+
export declare class MessageCommandInteraction<FromGuild extends boolean = boolean> extends ApplicationCommandInteraction<FromGuild, APIMessageApplicationCommandInteraction> {
|
|
133
|
+
type: ApplicationCommandType.Message;
|
|
134
|
+
data: ObjectToLower<APIMessageApplicationCommandInteractionData>;
|
|
135
|
+
}
|
|
136
|
+
export interface ModalSubmitInteraction<FromGuild extends boolean = boolean> extends Omit<Interaction<FromGuild, APIModalSubmitInteraction>, 'modal'> {
|
|
137
|
+
}
|
|
138
|
+
export declare class ModalSubmitInteraction<FromGuild extends boolean = boolean> extends BaseInteraction<FromGuild> {
|
|
139
|
+
data: ObjectToLower<APIModalSubmission>;
|
|
140
|
+
get customId(): string;
|
|
141
|
+
get components(): {
|
|
142
|
+
components: {
|
|
143
|
+
type: ComponentType;
|
|
144
|
+
customId: string;
|
|
145
|
+
value: string;
|
|
146
|
+
}[];
|
|
147
|
+
type: ComponentType.ActionRow;
|
|
148
|
+
}[];
|
|
149
|
+
getInputValue(customId: string, required: true): string;
|
|
150
|
+
getInputValue(customId: string, required?: false): string | undefined;
|
|
151
|
+
}
|
|
152
|
+
export {};
|
|
@@ -0,0 +1,409 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ModalSubmitInteraction = exports.MessageCommandInteraction = exports.UserCommandInteraction = exports.ChatInputCommandInteraction = exports.UserSelectMenuInteraction = exports.RoleSelectMenuInteraction = exports.MentionableSelectMenuInteraction = exports.ChannelSelectMenuInteraction = exports.StringSelectMenuInteraction = exports.SelectMenuInteraction = exports.ButtonInteraction = exports.ComponentInteraction = exports.ApplicationCommandInteraction = exports.Interaction = exports.AutocompleteInteraction = exports.BaseInteraction = void 0;
|
|
13
|
+
const ts_mixer_1 = require("ts-mixer");
|
|
14
|
+
const builders_1 = require("../builders");
|
|
15
|
+
const commands_1 = require("../commands");
|
|
16
|
+
const common_1 = require("../common");
|
|
17
|
+
const listener_1 = require("../components/listener");
|
|
18
|
+
const _1 = require("./");
|
|
19
|
+
const GuildRole_1 = require("./GuildRole");
|
|
20
|
+
const Message_1 = require("./Message");
|
|
21
|
+
const User_1 = require("./User");
|
|
22
|
+
const channels_1 = __importDefault(require("./channels"));
|
|
23
|
+
const DiscordBase_1 = require("./extra/DiscordBase");
|
|
24
|
+
const Permissions_1 = require("./extra/Permissions");
|
|
25
|
+
class BaseInteraction extends DiscordBase_1.DiscordBase {
|
|
26
|
+
client;
|
|
27
|
+
__reply;
|
|
28
|
+
user;
|
|
29
|
+
member;
|
|
30
|
+
channel;
|
|
31
|
+
message;
|
|
32
|
+
replied;
|
|
33
|
+
appPermissions;
|
|
34
|
+
constructor(client, interaction, __reply) {
|
|
35
|
+
super(client, interaction);
|
|
36
|
+
this.client = client;
|
|
37
|
+
this.__reply = __reply;
|
|
38
|
+
if (interaction.member) {
|
|
39
|
+
this.member = new _1.InteractionGuildMember(client, interaction.member, interaction.member.user, interaction.guild_id);
|
|
40
|
+
}
|
|
41
|
+
if (interaction.message) {
|
|
42
|
+
this.message = new Message_1.Message(client, interaction.message);
|
|
43
|
+
}
|
|
44
|
+
if (interaction.app_permissions) {
|
|
45
|
+
this.appPermissions = new Permissions_1.PermissionsBitField(Number(interaction.app_permissions));
|
|
46
|
+
}
|
|
47
|
+
if (interaction.channel) {
|
|
48
|
+
this.channel = (0, channels_1.default)(interaction.channel, client);
|
|
49
|
+
}
|
|
50
|
+
this.user = this.member?.user ?? new User_1.User(client, interaction.user);
|
|
51
|
+
}
|
|
52
|
+
static transformBodyRequest(body) {
|
|
53
|
+
switch (body.type) {
|
|
54
|
+
case common_1.InteractionResponseType.ApplicationCommandAutocompleteResult:
|
|
55
|
+
case common_1.InteractionResponseType.DeferredMessageUpdate:
|
|
56
|
+
case common_1.InteractionResponseType.DeferredChannelMessageWithSource:
|
|
57
|
+
return body;
|
|
58
|
+
case common_1.InteractionResponseType.ChannelMessageWithSource:
|
|
59
|
+
case common_1.InteractionResponseType.UpdateMessage:
|
|
60
|
+
return {
|
|
61
|
+
type: body.type,
|
|
62
|
+
data: {
|
|
63
|
+
...(body.data ?? {}),
|
|
64
|
+
// @ts-expect-error
|
|
65
|
+
components: (body.data?.components instanceof listener_1.ComponentsListener
|
|
66
|
+
? body.data.components.components
|
|
67
|
+
: body.data.components)?.map(x => (x instanceof builders_1.ActionRow ? x.toJSON() : x)) ?? undefined,
|
|
68
|
+
embeds: body.data?.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)) ?? undefined,
|
|
69
|
+
attachments: body.data?.attachments?.map((x, i) => ({ id: i, ...(0, builders_1.resolveAttachment)(x) })) ?? undefined,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
case common_1.InteractionResponseType.Modal:
|
|
73
|
+
return {
|
|
74
|
+
type: body.type,
|
|
75
|
+
data: body.data instanceof builders_1.Modal
|
|
76
|
+
? body.data.toJSON()
|
|
77
|
+
: {
|
|
78
|
+
...body.data,
|
|
79
|
+
components: body.data?.components
|
|
80
|
+
? body.data.components.map(x => x instanceof builders_1.ActionRow
|
|
81
|
+
? x.toJSON()
|
|
82
|
+
: x)
|
|
83
|
+
: [],
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
default:
|
|
87
|
+
return body;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
static transformBody(body) {
|
|
91
|
+
return {
|
|
92
|
+
...body,
|
|
93
|
+
components: (body?.components instanceof listener_1.ComponentsListener ? body.components.components : body.components)?.map(x => x instanceof builders_1.ActionRow ? x.toJSON() : x) ?? undefined,
|
|
94
|
+
embeds: body?.embeds?.map(x => (x instanceof builders_1.Embed ? x.toJSON() : x)) ?? undefined,
|
|
95
|
+
// attachments: body.attachments?.map((x, i) => ({ id: i, ...resolveAttachment(x) })) ?? undefined,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
matchReplied(data, type, filesParsed) {
|
|
99
|
+
this.replied = (this.__reply ?? this.api.interactions(this.id)(this.token).callback.post)({
|
|
100
|
+
// @ts-expect-error
|
|
101
|
+
body: BaseInteraction.transformBodyRequest({ data, type }),
|
|
102
|
+
files: filesParsed,
|
|
103
|
+
}).then(() => (this.replied = true));
|
|
104
|
+
}
|
|
105
|
+
async reply(body) {
|
|
106
|
+
if (this.replied) {
|
|
107
|
+
throw new Error('Interaction already replied');
|
|
108
|
+
}
|
|
109
|
+
// @ts-expect-error
|
|
110
|
+
if (body.data?.files) {
|
|
111
|
+
// @ts-expect-error
|
|
112
|
+
const { files, ...rest } = body.data;
|
|
113
|
+
this.matchReplied(rest, body.type, await (0, builders_1.resolveFiles)(files));
|
|
114
|
+
// @ts-expect-error
|
|
115
|
+
}
|
|
116
|
+
else
|
|
117
|
+
this.matchReplied(body.data, body.type);
|
|
118
|
+
this.client.components.onRequestInteraction(body.type === common_1.InteractionResponseType.Modal
|
|
119
|
+
? this.user.id
|
|
120
|
+
: body.type === common_1.InteractionResponseType.UpdateMessage
|
|
121
|
+
? this.message.interaction.id
|
|
122
|
+
: this.id, body);
|
|
123
|
+
await this.replied;
|
|
124
|
+
}
|
|
125
|
+
deferReply(flags) {
|
|
126
|
+
return this.reply({
|
|
127
|
+
type: common_1.InteractionResponseType.DeferredChannelMessageWithSource,
|
|
128
|
+
data: {
|
|
129
|
+
flags,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
static from(client, gateway, __reply) {
|
|
134
|
+
switch (gateway.type) {
|
|
135
|
+
case common_1.InteractionType.ApplicationCommandAutocomplete:
|
|
136
|
+
return new AutocompleteInteraction(client, gateway, __reply);
|
|
137
|
+
// biome-ignore lint/suspicious/noFallthroughSwitchClause: bad interaction between biome and ts-server
|
|
138
|
+
case common_1.InteractionType.ApplicationCommand:
|
|
139
|
+
switch (gateway.data.type) {
|
|
140
|
+
case common_1.ApplicationCommandType.ChatInput:
|
|
141
|
+
return new ChatInputCommandInteraction(client, gateway, __reply);
|
|
142
|
+
case common_1.ApplicationCommandType.User:
|
|
143
|
+
return new UserCommandInteraction(client, gateway, __reply);
|
|
144
|
+
case common_1.ApplicationCommandType.Message:
|
|
145
|
+
return new MessageCommandInteraction(client, gateway, __reply);
|
|
146
|
+
}
|
|
147
|
+
// biome-ignore lint/suspicious/noFallthroughSwitchClause: bad interaction between biome and ts-server
|
|
148
|
+
case common_1.InteractionType.MessageComponent:
|
|
149
|
+
switch (gateway.data.component_type) {
|
|
150
|
+
case common_1.ComponentType.Button:
|
|
151
|
+
return new ButtonInteraction(client, gateway, __reply);
|
|
152
|
+
case common_1.ComponentType.ChannelSelect:
|
|
153
|
+
return new ChannelSelectMenuInteraction(client, gateway, __reply);
|
|
154
|
+
case common_1.ComponentType.RoleSelect:
|
|
155
|
+
return new RoleSelectMenuInteraction(client, gateway, __reply);
|
|
156
|
+
case common_1.ComponentType.MentionableSelect:
|
|
157
|
+
return new MentionableSelectMenuInteraction(client, gateway, __reply);
|
|
158
|
+
case common_1.ComponentType.UserSelect:
|
|
159
|
+
return new UserSelectMenuInteraction(client, gateway, __reply);
|
|
160
|
+
case common_1.ComponentType.StringSelect:
|
|
161
|
+
return new StringSelectMenuInteraction(client, gateway, __reply);
|
|
162
|
+
}
|
|
163
|
+
case common_1.InteractionType.ModalSubmit:
|
|
164
|
+
return new ModalSubmitInteraction(client, gateway);
|
|
165
|
+
default:
|
|
166
|
+
return new BaseInteraction(client, gateway);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
exports.BaseInteraction = BaseInteraction;
|
|
171
|
+
class AutocompleteInteraction extends BaseInteraction {
|
|
172
|
+
__reply;
|
|
173
|
+
options;
|
|
174
|
+
constructor(client, interaction, __reply) {
|
|
175
|
+
super(client, interaction);
|
|
176
|
+
this.__reply = __reply;
|
|
177
|
+
this.options = new commands_1.OptionResolver(client, interaction.data.options, undefined, interaction.guild_id, interaction.data.resolved);
|
|
178
|
+
}
|
|
179
|
+
getInput() {
|
|
180
|
+
return this.options.getAutocompleteValue() ?? '';
|
|
181
|
+
}
|
|
182
|
+
respond(choices) {
|
|
183
|
+
return super.reply({ data: { choices }, type: common_1.InteractionResponseType.ApplicationCommandAutocompleteResult });
|
|
184
|
+
}
|
|
185
|
+
/** @intenal */
|
|
186
|
+
async reply(..._args) {
|
|
187
|
+
throw new Error('Cannot use reply in this interaction');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.AutocompleteInteraction = AutocompleteInteraction;
|
|
191
|
+
class Interaction extends BaseInteraction {
|
|
192
|
+
fetchMessage(messageId) {
|
|
193
|
+
return this.client.webhooks.messages.fetch(this.applicationId, this.token, messageId);
|
|
194
|
+
}
|
|
195
|
+
fetchResponse() {
|
|
196
|
+
return this.fetchMessage('@original');
|
|
197
|
+
}
|
|
198
|
+
async write(body, fetchReply) {
|
|
199
|
+
(await this.reply({
|
|
200
|
+
type: common_1.InteractionResponseType.ChannelMessageWithSource,
|
|
201
|
+
data: body,
|
|
202
|
+
}));
|
|
203
|
+
if (fetchReply)
|
|
204
|
+
return this.fetchResponse();
|
|
205
|
+
return undefined;
|
|
206
|
+
}
|
|
207
|
+
modal(body) {
|
|
208
|
+
return this.reply({
|
|
209
|
+
type: common_1.InteractionResponseType.Modal,
|
|
210
|
+
data: body,
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
async editOrReply(body, fetchReply) {
|
|
214
|
+
if (await this.replied) {
|
|
215
|
+
const { content, embeds, allowed_mentions, components, files, attachments } = body;
|
|
216
|
+
return this.editResponse({ content, embeds, allowed_mentions, components, files, attachments });
|
|
217
|
+
}
|
|
218
|
+
return this.write(body, fetchReply);
|
|
219
|
+
}
|
|
220
|
+
async editMessage(messageId, body) {
|
|
221
|
+
const { files, ...data } = body;
|
|
222
|
+
const apiMessage = await this.api
|
|
223
|
+
.webhooks(this.applicationId)(this.token)
|
|
224
|
+
.messages(messageId)
|
|
225
|
+
.patch({
|
|
226
|
+
body: BaseInteraction.transformBody(data),
|
|
227
|
+
files: files ? await (0, builders_1.resolveFiles)(files) : undefined,
|
|
228
|
+
});
|
|
229
|
+
this.client.components.onRequestInteractionUpdate(body, apiMessage);
|
|
230
|
+
return new Message_1.Message(this.client, apiMessage);
|
|
231
|
+
}
|
|
232
|
+
editResponse(body) {
|
|
233
|
+
return this.editMessage('@original', body);
|
|
234
|
+
}
|
|
235
|
+
deleteResponse() {
|
|
236
|
+
return this.deleteMessage('@original');
|
|
237
|
+
}
|
|
238
|
+
deleteMessage(messageId) {
|
|
239
|
+
return this.api
|
|
240
|
+
.webhooks(this.applicationId)(this.token)
|
|
241
|
+
.messages(messageId)
|
|
242
|
+
.delete()
|
|
243
|
+
.then(() => this.client.components.onMessageDelete(messageId === '@original' ? this.id : messageId));
|
|
244
|
+
}
|
|
245
|
+
async createResponse({ files, ...body }) {
|
|
246
|
+
files ??= files ? await (0, builders_1.resolveFiles)(files) : undefined;
|
|
247
|
+
const apiMessage = await this.api
|
|
248
|
+
.webhooks(this.applicationId)(this.token)
|
|
249
|
+
.post({
|
|
250
|
+
body: BaseInteraction.transformBody(body),
|
|
251
|
+
files: files,
|
|
252
|
+
});
|
|
253
|
+
this.client.components.onRequestMessage(body, apiMessage);
|
|
254
|
+
return new Message_1.Message(this.client, apiMessage);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
exports.Interaction = Interaction;
|
|
258
|
+
class ApplicationCommandInteraction extends Interaction {
|
|
259
|
+
type = common_1.ApplicationCommandType.ChatInput;
|
|
260
|
+
respond(data) {
|
|
261
|
+
return this.reply(data);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
exports.ApplicationCommandInteraction = ApplicationCommandInteraction;
|
|
265
|
+
class ComponentInteraction extends Interaction {
|
|
266
|
+
update(data) {
|
|
267
|
+
return this.reply({
|
|
268
|
+
type: common_1.InteractionResponseType.UpdateMessage,
|
|
269
|
+
data,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
deferUpdate() {
|
|
273
|
+
return this.reply({
|
|
274
|
+
type: common_1.InteractionResponseType.DeferredMessageUpdate,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
get customId() {
|
|
278
|
+
return this.data.customId;
|
|
279
|
+
}
|
|
280
|
+
get componentType() {
|
|
281
|
+
return this.data.componentType;
|
|
282
|
+
}
|
|
283
|
+
isButton() {
|
|
284
|
+
return this.data.componentType === common_1.ComponentType.Button;
|
|
285
|
+
}
|
|
286
|
+
isChannelSelectMenu() {
|
|
287
|
+
return this.componentType === common_1.ComponentType.ChannelSelect;
|
|
288
|
+
}
|
|
289
|
+
isRoleSelectMenu() {
|
|
290
|
+
return this.componentType === common_1.ComponentType.RoleSelect;
|
|
291
|
+
}
|
|
292
|
+
isMentionableSelectMenu() {
|
|
293
|
+
return this.componentType === common_1.ComponentType.MentionableSelect;
|
|
294
|
+
}
|
|
295
|
+
isUserSelectMenu() {
|
|
296
|
+
return this.componentType === common_1.ComponentType.UserSelect;
|
|
297
|
+
}
|
|
298
|
+
isStringSelectMenu() {
|
|
299
|
+
return this.componentType === common_1.ComponentType.StringSelect;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
exports.ComponentInteraction = ComponentInteraction;
|
|
303
|
+
class ButtonInteraction extends ComponentInteraction {
|
|
304
|
+
}
|
|
305
|
+
exports.ButtonInteraction = ButtonInteraction;
|
|
306
|
+
class SelectMenuInteraction extends ComponentInteraction {
|
|
307
|
+
__reply;
|
|
308
|
+
constructor(client, interaction, __reply) {
|
|
309
|
+
super(client, interaction);
|
|
310
|
+
this.__reply = __reply;
|
|
311
|
+
}
|
|
312
|
+
get values() {
|
|
313
|
+
return this.data.values;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
exports.SelectMenuInteraction = SelectMenuInteraction;
|
|
317
|
+
class StringSelectMenuInteraction extends SelectMenuInteraction {
|
|
318
|
+
}
|
|
319
|
+
exports.StringSelectMenuInteraction = StringSelectMenuInteraction;
|
|
320
|
+
class ChannelSelectMenuInteraction extends SelectMenuInteraction {
|
|
321
|
+
__reply;
|
|
322
|
+
channels;
|
|
323
|
+
constructor(client, interaction, __reply) {
|
|
324
|
+
super(client, interaction);
|
|
325
|
+
this.__reply = __reply;
|
|
326
|
+
const resolved = interaction.data.resolved;
|
|
327
|
+
this.channels = this.values.map(x => (0, channels_1.default)(resolved.channels[x], this.client));
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
exports.ChannelSelectMenuInteraction = ChannelSelectMenuInteraction;
|
|
331
|
+
class MentionableSelectMenuInteraction extends SelectMenuInteraction {
|
|
332
|
+
__reply;
|
|
333
|
+
roles;
|
|
334
|
+
members;
|
|
335
|
+
users;
|
|
336
|
+
constructor(client, interaction, __reply) {
|
|
337
|
+
super(client, interaction);
|
|
338
|
+
this.__reply = __reply;
|
|
339
|
+
const resolved = interaction.data.resolved;
|
|
340
|
+
this.roles = resolved.roles
|
|
341
|
+
? this.values.map(x => new GuildRole_1.GuildRole(this.client, resolved.roles[x], this.guildId))
|
|
342
|
+
: [];
|
|
343
|
+
this.members = resolved.members
|
|
344
|
+
? this.values.map(x => new _1.InteractionGuildMember(this.client, resolved.members[x], this.users.find(u => u.id === x), this.guildId))
|
|
345
|
+
: [];
|
|
346
|
+
this.users = resolved.users ? this.values.map(x => new User_1.User(this.client, resolved.users[x])) : [];
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
exports.MentionableSelectMenuInteraction = MentionableSelectMenuInteraction;
|
|
350
|
+
class RoleSelectMenuInteraction extends SelectMenuInteraction {
|
|
351
|
+
__reply;
|
|
352
|
+
roles;
|
|
353
|
+
constructor(client, interaction, __reply) {
|
|
354
|
+
super(client, interaction);
|
|
355
|
+
this.__reply = __reply;
|
|
356
|
+
const resolved = interaction.data.resolved;
|
|
357
|
+
this.roles = this.values.map(x => new GuildRole_1.GuildRole(this.client, resolved.roles[x], this.guildId));
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
exports.RoleSelectMenuInteraction = RoleSelectMenuInteraction;
|
|
361
|
+
class UserSelectMenuInteraction extends SelectMenuInteraction {
|
|
362
|
+
__reply;
|
|
363
|
+
members;
|
|
364
|
+
users;
|
|
365
|
+
constructor(client, interaction, __reply) {
|
|
366
|
+
super(client, interaction);
|
|
367
|
+
this.__reply = __reply;
|
|
368
|
+
const resolved = interaction.data.resolved;
|
|
369
|
+
this.users = this.values.map(x => new User_1.User(this.client, resolved.users[x]));
|
|
370
|
+
this.members = resolved.members
|
|
371
|
+
? this.values.map(x => new _1.InteractionGuildMember(this.client, resolved.members[x], this.users.find(u => u.id === x), this.guildId))
|
|
372
|
+
: [];
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
exports.UserSelectMenuInteraction = UserSelectMenuInteraction;
|
|
376
|
+
class ChatInputCommandInteraction extends ApplicationCommandInteraction {
|
|
377
|
+
}
|
|
378
|
+
exports.ChatInputCommandInteraction = ChatInputCommandInteraction;
|
|
379
|
+
class UserCommandInteraction extends ApplicationCommandInteraction {
|
|
380
|
+
}
|
|
381
|
+
exports.UserCommandInteraction = UserCommandInteraction;
|
|
382
|
+
class MessageCommandInteraction extends ApplicationCommandInteraction {
|
|
383
|
+
}
|
|
384
|
+
exports.MessageCommandInteraction = MessageCommandInteraction;
|
|
385
|
+
let ModalSubmitInteraction = class ModalSubmitInteraction extends BaseInteraction {
|
|
386
|
+
get customId() {
|
|
387
|
+
return this.data.customId;
|
|
388
|
+
}
|
|
389
|
+
get components() {
|
|
390
|
+
return this.data.components;
|
|
391
|
+
}
|
|
392
|
+
getInputValue(customId, required) {
|
|
393
|
+
let value;
|
|
394
|
+
for (const { components } of this.components) {
|
|
395
|
+
const get = components.find(x => x.customId === customId);
|
|
396
|
+
if (get) {
|
|
397
|
+
value = get.value;
|
|
398
|
+
break;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
if (!value && required)
|
|
402
|
+
throw new Error(`${customId} component doesn't have a value`);
|
|
403
|
+
return value;
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
exports.ModalSubmitInteraction = ModalSubmitInteraction;
|
|
407
|
+
exports.ModalSubmitInteraction = ModalSubmitInteraction = __decorate([
|
|
408
|
+
(0, ts_mixer_1.mix)(Interaction)
|
|
409
|
+
], ModalSubmitInteraction);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { BaseClient } from '../client/base';
|
|
2
|
+
import type { APIChannelMention, APIMessage, GatewayMessageCreateDispatchData, ObjectToLower } from '../common';
|
|
3
|
+
import type { EmojiResolvable } from '../common/types/resolvables';
|
|
4
|
+
import type { MessageCreateBodyRequest, MessageUpdateBodyRequest } from '../common/types/write';
|
|
5
|
+
import type { ActionRowMessageComponents } from '../components';
|
|
6
|
+
import { MessageActionRowComponent } from '../components/ActionRow';
|
|
7
|
+
import { GuildMember } from './GuildMember';
|
|
8
|
+
import { User } from './User';
|
|
9
|
+
import type { MessageWebhookMethodEditParams, MessageWebhookMethodWriteParams } from './Webhook';
|
|
10
|
+
import { DiscordBase } from './extra/DiscordBase';
|
|
11
|
+
export type MessageData = APIMessage | GatewayMessageCreateDispatchData;
|
|
12
|
+
export interface BaseMessage extends DiscordBase, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components'>> {
|
|
13
|
+
}
|
|
14
|
+
export declare class BaseMessage extends DiscordBase {
|
|
15
|
+
guildId: string | undefined;
|
|
16
|
+
timestamp?: number;
|
|
17
|
+
author: User;
|
|
18
|
+
member?: GuildMember;
|
|
19
|
+
components: MessageActionRowComponent<ActionRowMessageComponents>[];
|
|
20
|
+
mentions: {
|
|
21
|
+
roles: string[];
|
|
22
|
+
channels: APIChannelMention[];
|
|
23
|
+
users: (GuildMember | User)[];
|
|
24
|
+
};
|
|
25
|
+
constructor(client: BaseClient, data: MessageData);
|
|
26
|
+
get url(): string;
|
|
27
|
+
guild(force?: boolean): Promise<import("./Guild").Guild<"cached"> | import("./Guild").Guild<"api"> | undefined>;
|
|
28
|
+
channel(force?: boolean): Promise<import("./channels").AllChannels>;
|
|
29
|
+
react(emoji: EmojiResolvable): Promise<never>;
|
|
30
|
+
private patch;
|
|
31
|
+
}
|
|
32
|
+
export interface Message extends BaseMessage, ObjectToLower<Omit<MessageData, 'timestamp' | 'author' | 'mentions' | 'components'>> {
|
|
33
|
+
}
|
|
34
|
+
export declare class Message extends BaseMessage {
|
|
35
|
+
constructor(client: BaseClient, data: MessageData);
|
|
36
|
+
fetch(): Promise<Message>;
|
|
37
|
+
reply(body: Omit<MessageCreateBodyRequest, 'message_reference'>): Promise<Message>;
|
|
38
|
+
edit(body: MessageUpdateBodyRequest): Promise<Message>;
|
|
39
|
+
write(body: MessageCreateBodyRequest): Promise<Message>;
|
|
40
|
+
delete(reason?: string): Promise<void>;
|
|
41
|
+
crosspost(reason?: string): Promise<Message>;
|
|
42
|
+
}
|
|
43
|
+
export type EditMessageWebhook = Omit<MessageWebhookMethodEditParams, 'messageId'>;
|
|
44
|
+
export type WriteMessageWebhook = MessageWebhookMethodWriteParams;
|
|
45
|
+
export declare class WebhookMessage extends BaseMessage {
|
|
46
|
+
readonly webhookId: string;
|
|
47
|
+
readonly webhookToken: string;
|
|
48
|
+
constructor(client: BaseClient, data: MessageData, webhookId: string, webhookToken: string);
|
|
49
|
+
fetch(): Promise<import("discord-api-types/rest/v10/webhook").RESTGetAPIWebhookWithTokenResult>;
|
|
50
|
+
edit(body: EditMessageWebhook): Promise<WebhookMessage>;
|
|
51
|
+
write(body: WriteMessageWebhook): Promise<WebhookMessage | null>;
|
|
52
|
+
delete(reason?: string): Promise<never>;
|
|
53
|
+
}
|