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,139 @@
|
|
|
1
|
+
import type { APIApplicationCommandBasicOption, APIApplicationCommandOption, APIAttachment, LocaleString } from '../../common';
|
|
2
|
+
import { ApplicationCommandOptionType, ApplicationCommandType } from '../../common';
|
|
3
|
+
import type { AllChannels, AutocompleteInteraction, GuildRole, InteractionGuildMember, User } from '../../structures';
|
|
4
|
+
import type { Groups, RegisteredMiddlewares } from '../decorators';
|
|
5
|
+
import type { CommandContext } from './chatcontext';
|
|
6
|
+
import type { OKFunction, OnOptionsReturnObject, StopFunction, UsingClient } from './shared';
|
|
7
|
+
export interface ReturnOptionsTypes {
|
|
8
|
+
1: never;
|
|
9
|
+
2: never;
|
|
10
|
+
3: string;
|
|
11
|
+
4: number;
|
|
12
|
+
5: boolean;
|
|
13
|
+
6: InteractionGuildMember | User;
|
|
14
|
+
7: AllChannels;
|
|
15
|
+
8: GuildRole;
|
|
16
|
+
9: GuildRole | AllChannels | User;
|
|
17
|
+
10: number;
|
|
18
|
+
11: APIAttachment;
|
|
19
|
+
}
|
|
20
|
+
type Wrap<N extends ApplicationCommandOptionType> = N extends ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup ? never : {
|
|
21
|
+
required?: boolean;
|
|
22
|
+
value?(data: {
|
|
23
|
+
context: CommandContext;
|
|
24
|
+
value: ReturnOptionsTypes[N];
|
|
25
|
+
}, ok: OKFunction<any>, fail: StopFunction): void;
|
|
26
|
+
} & {
|
|
27
|
+
description: string;
|
|
28
|
+
description_localizations?: APIApplicationCommandBasicOption['description_localizations'];
|
|
29
|
+
name_localizations?: APIApplicationCommandBasicOption['name_localizations'];
|
|
30
|
+
};
|
|
31
|
+
export type __TypeWrapper<T extends ApplicationCommandOptionType> = Wrap<T>;
|
|
32
|
+
export type __TypesWrapper = {
|
|
33
|
+
[P in keyof typeof ApplicationCommandOptionType]: `${(typeof ApplicationCommandOptionType)[P]}` extends `${infer D extends number}` ? Wrap<D> : never;
|
|
34
|
+
};
|
|
35
|
+
export type AutocompleteCallback = (interaction: AutocompleteInteraction) => any;
|
|
36
|
+
export type OnAutocompleteErrorCallback = (interaction: AutocompleteInteraction, error: unknown) => any;
|
|
37
|
+
export type CommandBaseOption = __TypesWrapper[keyof __TypesWrapper];
|
|
38
|
+
export type CommandBaseAutocompleteOption = __TypesWrapper[keyof __TypesWrapper] & {
|
|
39
|
+
autocomplete: AutocompleteCallback;
|
|
40
|
+
onAutocompleteError?: OnAutocompleteErrorCallback;
|
|
41
|
+
};
|
|
42
|
+
export type CommandAutocompleteOption = CommandBaseAutocompleteOption & {
|
|
43
|
+
name: string;
|
|
44
|
+
};
|
|
45
|
+
export type __CommandOption = CommandBaseOption;
|
|
46
|
+
export type CommandOption = __CommandOption & {
|
|
47
|
+
name: string;
|
|
48
|
+
};
|
|
49
|
+
export type OptionsRecord = Record<string, __CommandOption & {
|
|
50
|
+
type: ApplicationCommandOptionType;
|
|
51
|
+
}>;
|
|
52
|
+
type KeysWithoutRequired<T extends OptionsRecord> = {
|
|
53
|
+
[K in keyof T]-?: T[K]['required'] extends true ? never : K;
|
|
54
|
+
}[keyof T];
|
|
55
|
+
type ContextOptionsAux<T extends OptionsRecord> = {
|
|
56
|
+
[K in Exclude<keyof T, KeysWithoutRequired<T>>]: T[K]['value'] extends (...args: any) => any ? T[K]['required'] extends true ? Parameters<Parameters<T[K]['value']>[1]>[0] : never : T[K]['required'] extends true ? ReturnOptionsTypes[T[K]['type']] : never;
|
|
57
|
+
} & {
|
|
58
|
+
[K in KeysWithoutRequired<T>]?: T[K]['value'] extends (...args: any) => any ? T[K]['required'] extends true ? never : Parameters<Parameters<T[K]['value']>[1]>[0] : T[K]['required'] extends true ? never : ReturnOptionsTypes[T[K]['type']];
|
|
59
|
+
};
|
|
60
|
+
export type ContextOptions<T extends OptionsRecord> = ContextOptionsAux<T>;
|
|
61
|
+
declare class BaseCommand {
|
|
62
|
+
middlewares: (keyof RegisteredMiddlewares)[];
|
|
63
|
+
__filePath?: string;
|
|
64
|
+
__t?: {
|
|
65
|
+
name: string;
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
__d?: true;
|
|
69
|
+
__tGroups?: Record<string, {
|
|
70
|
+
name: string;
|
|
71
|
+
description: string;
|
|
72
|
+
defaultDescription: string;
|
|
73
|
+
}>;
|
|
74
|
+
guild_id?: string[];
|
|
75
|
+
name: string;
|
|
76
|
+
type: number;
|
|
77
|
+
nsfw?: boolean;
|
|
78
|
+
description: string;
|
|
79
|
+
default_member_permissions?: string;
|
|
80
|
+
permissions?: bigint;
|
|
81
|
+
dm?: boolean;
|
|
82
|
+
name_localizations?: Partial<Record<LocaleString, string>>;
|
|
83
|
+
description_localizations?: Partial<Record<LocaleString, string>>;
|
|
84
|
+
options?: CommandOption[] | SubCommand[];
|
|
85
|
+
toJSON(): {
|
|
86
|
+
name: string;
|
|
87
|
+
type: number;
|
|
88
|
+
nsfw: boolean;
|
|
89
|
+
description: string;
|
|
90
|
+
name_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
|
|
91
|
+
description_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
|
|
92
|
+
guild_id: string[] | undefined;
|
|
93
|
+
dm_permission: boolean | undefined;
|
|
94
|
+
default_member_permissions: string | undefined;
|
|
95
|
+
};
|
|
96
|
+
reload(): Promise<void>;
|
|
97
|
+
run?(context: CommandContext<any>): any;
|
|
98
|
+
onAfterRun?(context: CommandContext<any>, error: unknown | undefined): any;
|
|
99
|
+
onRunError?(context: CommandContext<any>, error: unknown): any;
|
|
100
|
+
onOptionsError?(context: CommandContext<{}, never>, metadata: OnOptionsReturnObject): any;
|
|
101
|
+
onMiddlewaresError?(context: CommandContext<{}, never>, error: Error): any;
|
|
102
|
+
onInternalError(client: UsingClient, error?: unknown): any;
|
|
103
|
+
}
|
|
104
|
+
export declare class Command extends BaseCommand {
|
|
105
|
+
type: ApplicationCommandType;
|
|
106
|
+
groups?: Parameters<typeof Groups>[0];
|
|
107
|
+
toJSON(): {
|
|
108
|
+
options: APIApplicationCommandOption[];
|
|
109
|
+
name: string;
|
|
110
|
+
type: number;
|
|
111
|
+
nsfw: boolean;
|
|
112
|
+
description: string;
|
|
113
|
+
name_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
|
|
114
|
+
description_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
|
|
115
|
+
guild_id: string[] | undefined;
|
|
116
|
+
dm_permission: boolean | undefined;
|
|
117
|
+
default_member_permissions: string | undefined;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export declare abstract class SubCommand extends BaseCommand {
|
|
121
|
+
type: ApplicationCommandOptionType;
|
|
122
|
+
group?: string;
|
|
123
|
+
options?: CommandOption[];
|
|
124
|
+
toJSON(): {
|
|
125
|
+
options: APIApplicationCommandBasicOption[];
|
|
126
|
+
name: string;
|
|
127
|
+
type: number;
|
|
128
|
+
nsfw: boolean;
|
|
129
|
+
description: string;
|
|
130
|
+
name_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
|
|
131
|
+
description_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
|
|
132
|
+
guild_id: string[] | undefined;
|
|
133
|
+
dm_permission: boolean | undefined;
|
|
134
|
+
default_member_permissions: string | undefined;
|
|
135
|
+
};
|
|
136
|
+
abstract run(context: CommandContext<any>): any;
|
|
137
|
+
onRunError?(context: CommandContext<any>, error: unknown): any;
|
|
138
|
+
}
|
|
139
|
+
export {};
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubCommand = exports.Command = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
class BaseCommand {
|
|
6
|
+
middlewares = [];
|
|
7
|
+
__filePath;
|
|
8
|
+
__t;
|
|
9
|
+
__d;
|
|
10
|
+
__tGroups;
|
|
11
|
+
guild_id;
|
|
12
|
+
name;
|
|
13
|
+
type; // ApplicationCommandType.ChatInput | ApplicationCommandOptionType.Subcommand
|
|
14
|
+
nsfw;
|
|
15
|
+
description;
|
|
16
|
+
default_member_permissions;
|
|
17
|
+
permissions;
|
|
18
|
+
dm;
|
|
19
|
+
name_localizations;
|
|
20
|
+
description_localizations;
|
|
21
|
+
options;
|
|
22
|
+
/** @internal */
|
|
23
|
+
async __runOptions(ctx, resolver) {
|
|
24
|
+
const command = resolver.getCommand();
|
|
25
|
+
if (!resolver.hoistedOptions.length || !command) {
|
|
26
|
+
return [false, {}];
|
|
27
|
+
}
|
|
28
|
+
const data = {};
|
|
29
|
+
let errored = false;
|
|
30
|
+
for (const i of resolver.hoistedOptions) {
|
|
31
|
+
const option = command.options.find(x => x.name === i.name);
|
|
32
|
+
const value = (await new Promise(resolve => option.value?.({ context: ctx, value: resolver.getValue(i.name) }, resolve, resolve) ||
|
|
33
|
+
resolve(resolver.getValue(i.name))));
|
|
34
|
+
if (value instanceof Error) {
|
|
35
|
+
errored = true;
|
|
36
|
+
data[i.name] = {
|
|
37
|
+
failed: true,
|
|
38
|
+
value,
|
|
39
|
+
};
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (value === undefined) {
|
|
43
|
+
if (option.required) {
|
|
44
|
+
errored = true;
|
|
45
|
+
data[i.name] = {
|
|
46
|
+
failed: true,
|
|
47
|
+
value: new Error(`${i.name} is required but returned no value`),
|
|
48
|
+
};
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// @ts-expect-error
|
|
53
|
+
ctx.options[i.name] = value;
|
|
54
|
+
data[i.name] = {
|
|
55
|
+
failed: false,
|
|
56
|
+
value,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return [errored, data];
|
|
60
|
+
}
|
|
61
|
+
/** @internal */
|
|
62
|
+
static __runMiddlewares(context, middlewares, global) {
|
|
63
|
+
if (!middlewares.length) {
|
|
64
|
+
return Promise.resolve(undefined);
|
|
65
|
+
}
|
|
66
|
+
let index = 0;
|
|
67
|
+
return new Promise(res => {
|
|
68
|
+
let running = true;
|
|
69
|
+
const pass = () => {
|
|
70
|
+
if (!running) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
running = false;
|
|
74
|
+
return res('pass');
|
|
75
|
+
};
|
|
76
|
+
const next = obj => {
|
|
77
|
+
if (!running) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
context[global ? 'globalMetadata' : 'metadata'] ??= {};
|
|
81
|
+
// @ts-expect-error
|
|
82
|
+
context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = obj;
|
|
83
|
+
if (++index >= middlewares.length) {
|
|
84
|
+
running = false;
|
|
85
|
+
return res(undefined);
|
|
86
|
+
}
|
|
87
|
+
context.client.middlewares[middlewares[index]]({ context, next, stop, pass });
|
|
88
|
+
};
|
|
89
|
+
const stop = err => {
|
|
90
|
+
if (!running) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
running = false;
|
|
94
|
+
return res(err);
|
|
95
|
+
};
|
|
96
|
+
context.client.middlewares[middlewares[0]]({ context, next, stop, pass });
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
/** @internal */
|
|
100
|
+
__runMiddlewares(context) {
|
|
101
|
+
return BaseCommand.__runMiddlewares(context, this.middlewares, false);
|
|
102
|
+
}
|
|
103
|
+
/** @internal */
|
|
104
|
+
__runGlobalMiddlewares(context) {
|
|
105
|
+
return BaseCommand.__runMiddlewares(context, (context.client.options?.globalMiddlewares ?? []), true);
|
|
106
|
+
}
|
|
107
|
+
toJSON() {
|
|
108
|
+
return {
|
|
109
|
+
name: this.name,
|
|
110
|
+
type: this.type,
|
|
111
|
+
nsfw: this.nsfw || false,
|
|
112
|
+
description: this.description,
|
|
113
|
+
name_localizations: this.name_localizations,
|
|
114
|
+
description_localizations: this.description_localizations,
|
|
115
|
+
guild_id: this.guild_id,
|
|
116
|
+
dm_permission: this.dm,
|
|
117
|
+
default_member_permissions: this.default_member_permissions,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
async reload() {
|
|
121
|
+
delete require.cache[this.__filePath];
|
|
122
|
+
const __tempCommand = await (0, common_1.magicImport)(this.__filePath).then(x => x.default ?? x);
|
|
123
|
+
Object.setPrototypeOf(this, __tempCommand.prototype);
|
|
124
|
+
}
|
|
125
|
+
onInternalError(client, error) {
|
|
126
|
+
client.logger.fatal(error);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
class Command extends BaseCommand {
|
|
130
|
+
type = common_1.ApplicationCommandType.ChatInput;
|
|
131
|
+
groups;
|
|
132
|
+
toJSON() {
|
|
133
|
+
const options = [];
|
|
134
|
+
for (const i of this.options ?? []) {
|
|
135
|
+
if (!(i instanceof SubCommand)) {
|
|
136
|
+
options.push({ ...i, autocomplete: 'autocomplete' in i });
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
if (i.group) {
|
|
140
|
+
if (!options.find(x => x.name === i.group)) {
|
|
141
|
+
options.push({
|
|
142
|
+
type: common_1.ApplicationCommandOptionType.SubcommandGroup,
|
|
143
|
+
name: i.group,
|
|
144
|
+
description: this.groups[i.group].defaultDescription,
|
|
145
|
+
description_localizations: Object.fromEntries(this.groups?.[i.group].description ?? []),
|
|
146
|
+
name_localizations: Object.fromEntries(this.groups?.[i.group].name ?? []),
|
|
147
|
+
options: [],
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
const group = options.find(x => x.name === i.group);
|
|
151
|
+
group.options?.push(i.toJSON());
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
options.push(i.toJSON());
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
...super.toJSON(),
|
|
158
|
+
options,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
exports.Command = Command;
|
|
163
|
+
class SubCommand extends BaseCommand {
|
|
164
|
+
type = common_1.ApplicationCommandOptionType.Subcommand;
|
|
165
|
+
group;
|
|
166
|
+
toJSON() {
|
|
167
|
+
return {
|
|
168
|
+
...super.toJSON(),
|
|
169
|
+
options: (this.options ?? []).map(x => ({ ...x, autocomplete: 'autocomplete' in x })),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
exports.SubCommand = SubCommand;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type UnionToTuple } from '../../common';
|
|
2
|
+
import type { InteractionCreateBodyRequest, InteractionMessageUpdateBodyRequest, ModalCreateBodyRequest } from '../../common/types/write';
|
|
3
|
+
import type { ChatInputCommandInteraction } from '../../structures';
|
|
4
|
+
import type { RegisteredMiddlewares } from '../decorators';
|
|
5
|
+
import type { OptionResolver } from '../optionresolver';
|
|
6
|
+
import type { ContextOptions, OptionsRecord } from './chat';
|
|
7
|
+
import type { CommandMetadata, DefaultLocale, ExtendContext, GlobalMetadata, UsingClient } from './shared';
|
|
8
|
+
export declare class CommandContext<T extends OptionsRecord = {}, M extends keyof RegisteredMiddlewares = never> implements ExtendContext {
|
|
9
|
+
readonly client: UsingClient;
|
|
10
|
+
readonly interaction: ChatInputCommandInteraction;
|
|
11
|
+
resolver: OptionResolver;
|
|
12
|
+
readonly shardId: number;
|
|
13
|
+
constructor(client: UsingClient, interaction: ChatInputCommandInteraction, resolver: OptionResolver, shardId: number);
|
|
14
|
+
options: ContextOptions<T>;
|
|
15
|
+
metadata: CommandMetadata<UnionToTuple<M>>;
|
|
16
|
+
globalMetadata: GlobalMetadata;
|
|
17
|
+
get proxy(): import("../..").APIRoutes;
|
|
18
|
+
get t(): DefaultLocale;
|
|
19
|
+
write(body: InteractionCreateBodyRequest): Promise<void>;
|
|
20
|
+
modal(body: ModalCreateBodyRequest): Promise<void>;
|
|
21
|
+
deferReply(ephemeral?: boolean): Promise<void>;
|
|
22
|
+
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<import("../../structures").Message>;
|
|
23
|
+
deleteResponse(): Promise<void>;
|
|
24
|
+
editOrReply(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest): Promise<void>;
|
|
25
|
+
fetchResponse(): Promise<import("../../structures").WebhookMessage | undefined>;
|
|
26
|
+
get author(): import("../../structures").User;
|
|
27
|
+
get member(): import("../../structures").InteractionGuildMember | undefined;
|
|
28
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CommandContext = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
class CommandContext {
|
|
6
|
+
client;
|
|
7
|
+
interaction;
|
|
8
|
+
resolver;
|
|
9
|
+
shardId;
|
|
10
|
+
constructor(client, interaction, resolver, shardId) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
this.interaction = interaction;
|
|
13
|
+
this.resolver = resolver;
|
|
14
|
+
this.shardId = shardId;
|
|
15
|
+
}
|
|
16
|
+
options = {};
|
|
17
|
+
metadata = {};
|
|
18
|
+
globalMetadata = {};
|
|
19
|
+
get proxy() {
|
|
20
|
+
return this.client.proxy;
|
|
21
|
+
}
|
|
22
|
+
get t() {
|
|
23
|
+
return this.client.langs.get(this.interaction.locale);
|
|
24
|
+
}
|
|
25
|
+
write(body) {
|
|
26
|
+
return this.interaction.write(body);
|
|
27
|
+
}
|
|
28
|
+
modal(body) {
|
|
29
|
+
return this.interaction.modal(body);
|
|
30
|
+
}
|
|
31
|
+
deferReply(ephemeral = false) {
|
|
32
|
+
return this.interaction.deferReply(ephemeral ? common_1.MessageFlags.Ephemeral : undefined);
|
|
33
|
+
}
|
|
34
|
+
editResponse(body) {
|
|
35
|
+
return this.interaction.editResponse(body);
|
|
36
|
+
}
|
|
37
|
+
deleteResponse() {
|
|
38
|
+
return this.interaction.deleteResponse();
|
|
39
|
+
}
|
|
40
|
+
editOrReply(body) {
|
|
41
|
+
return this.interaction.editOrReply(body);
|
|
42
|
+
}
|
|
43
|
+
fetchResponse() {
|
|
44
|
+
return this.interaction.fetchResponse();
|
|
45
|
+
}
|
|
46
|
+
get author() {
|
|
47
|
+
return this.interaction.user;
|
|
48
|
+
}
|
|
49
|
+
get member() {
|
|
50
|
+
return this.interaction.member;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
exports.CommandContext = CommandContext;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { BaseClient } from '../../client/base';
|
|
2
|
+
import { type ApplicationCommandType, type LocaleString } from '../../common';
|
|
3
|
+
import type { RegisteredMiddlewares } from '../decorators';
|
|
4
|
+
import type { MenuCommandContext } from './menucontext';
|
|
5
|
+
export declare abstract class ContextMenuCommand {
|
|
6
|
+
middlewares: (keyof RegisteredMiddlewares)[];
|
|
7
|
+
__filePath?: string;
|
|
8
|
+
__t?: {
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
};
|
|
12
|
+
guild_id?: string[];
|
|
13
|
+
name: string;
|
|
14
|
+
type: ApplicationCommandType.User | ApplicationCommandType.Message;
|
|
15
|
+
nsfw?: boolean;
|
|
16
|
+
description: string;
|
|
17
|
+
default_member_permissions?: string;
|
|
18
|
+
permissions?: bigint;
|
|
19
|
+
dm?: boolean;
|
|
20
|
+
name_localizations?: Partial<Record<LocaleString, string>>;
|
|
21
|
+
description_localizations?: Partial<Record<LocaleString, string>>;
|
|
22
|
+
toJSON(): {
|
|
23
|
+
name: string;
|
|
24
|
+
type: ApplicationCommandType.User | ApplicationCommandType.Message;
|
|
25
|
+
nsfw: boolean | undefined;
|
|
26
|
+
description: string;
|
|
27
|
+
name_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
|
|
28
|
+
description_localizations: Partial<Record<"id" | "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "es-419" | "sv-SE" | "th" | "tr" | "uk" | "vi", string>> | undefined;
|
|
29
|
+
guild_id: string[] | undefined;
|
|
30
|
+
dm_permission: boolean | undefined;
|
|
31
|
+
default_member_permissions: string | undefined;
|
|
32
|
+
};
|
|
33
|
+
reload(): Promise<void>;
|
|
34
|
+
abstract run?(context: MenuCommandContext<any>): any;
|
|
35
|
+
onAfterRun?(context: MenuCommandContext<any>, error: unknown | undefined): any;
|
|
36
|
+
onRunError?(context: MenuCommandContext<any>, error: unknown): any;
|
|
37
|
+
onMiddlewaresError?(context: MenuCommandContext<any, never>, error: Error): any;
|
|
38
|
+
onInternalError(client: BaseClient, error?: unknown): any;
|
|
39
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ContextMenuCommand = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
class ContextMenuCommand {
|
|
6
|
+
middlewares = [];
|
|
7
|
+
__filePath;
|
|
8
|
+
__t;
|
|
9
|
+
guild_id;
|
|
10
|
+
name;
|
|
11
|
+
type;
|
|
12
|
+
nsfw;
|
|
13
|
+
description;
|
|
14
|
+
default_member_permissions;
|
|
15
|
+
permissions;
|
|
16
|
+
dm;
|
|
17
|
+
name_localizations;
|
|
18
|
+
description_localizations;
|
|
19
|
+
/** @internal */
|
|
20
|
+
static __runMiddlewares(context, middlewares, global) {
|
|
21
|
+
if (!middlewares.length) {
|
|
22
|
+
return Promise.resolve(undefined);
|
|
23
|
+
}
|
|
24
|
+
let index = 0;
|
|
25
|
+
return new Promise(res => {
|
|
26
|
+
let running = true;
|
|
27
|
+
const pass = () => {
|
|
28
|
+
if (!running) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
running = false;
|
|
32
|
+
return res('pass');
|
|
33
|
+
};
|
|
34
|
+
const next = obj => {
|
|
35
|
+
if (!running) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
context[global ? 'globalMetadata' : 'metadata'] ??= {};
|
|
39
|
+
// @ts-expect-error
|
|
40
|
+
context[global ? 'globalMetadata' : 'metadata'][middlewares[index]] = obj;
|
|
41
|
+
if (++index >= middlewares.length) {
|
|
42
|
+
running = false;
|
|
43
|
+
return res(undefined);
|
|
44
|
+
}
|
|
45
|
+
context.client.middlewares[middlewares[index]]({ context, next, stop, pass });
|
|
46
|
+
};
|
|
47
|
+
const stop = err => {
|
|
48
|
+
if (!running) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
running = false;
|
|
52
|
+
return res(err);
|
|
53
|
+
};
|
|
54
|
+
context.client.middlewares[middlewares[0]]({ context, next, stop, pass });
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
/** @internal */
|
|
58
|
+
__runMiddlewares(context) {
|
|
59
|
+
return ContextMenuCommand.__runMiddlewares(context, this.middlewares, false);
|
|
60
|
+
}
|
|
61
|
+
/** @internal */
|
|
62
|
+
__runGlobalMiddlewares(context) {
|
|
63
|
+
return ContextMenuCommand.__runMiddlewares(context, (context.client.options?.globalMiddlewares ?? []), true);
|
|
64
|
+
}
|
|
65
|
+
toJSON() {
|
|
66
|
+
return {
|
|
67
|
+
name: this.name,
|
|
68
|
+
type: this.type,
|
|
69
|
+
nsfw: this.nsfw,
|
|
70
|
+
description: this.description,
|
|
71
|
+
name_localizations: this.name_localizations,
|
|
72
|
+
description_localizations: this.description_localizations,
|
|
73
|
+
guild_id: this.guild_id,
|
|
74
|
+
dm_permission: this.dm,
|
|
75
|
+
default_member_permissions: this.default_member_permissions,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
async reload() {
|
|
79
|
+
delete require.cache[this.__filePath];
|
|
80
|
+
const __tempCommand = await (0, common_1.magicImport)(this.__filePath).then(x => x.default ?? x);
|
|
81
|
+
Object.setPrototypeOf(this, __tempCommand.prototype);
|
|
82
|
+
}
|
|
83
|
+
onInternalError(client, error) {
|
|
84
|
+
client.logger.fatal(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.ContextMenuCommand = ContextMenuCommand;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type InteractionCreateBodyRequest, type InteractionMessageUpdateBodyRequest, type ModalCreateBodyRequest, type UnionToTuple } from '../../common';
|
|
2
|
+
import { Message, User, type MessageCommandInteraction, type UserCommandInteraction } from '../../structures';
|
|
3
|
+
import type { RegisteredMiddlewares } from '../decorators';
|
|
4
|
+
import type { CommandMetadata, DefaultLocale, ExtendContext, GlobalMetadata, UsingClient } from './shared';
|
|
5
|
+
export type InteractionTarget<T> = T extends MessageCommandInteraction ? Message : User;
|
|
6
|
+
export declare class MenuCommandContext<T extends MessageCommandInteraction | UserCommandInteraction, M extends keyof RegisteredMiddlewares = never> implements ExtendContext {
|
|
7
|
+
readonly client: UsingClient;
|
|
8
|
+
readonly interaction: T;
|
|
9
|
+
readonly shardId: number;
|
|
10
|
+
constructor(client: UsingClient, interaction: T, shardId: number);
|
|
11
|
+
metadata: CommandMetadata<UnionToTuple<M>>;
|
|
12
|
+
globalMetadata: GlobalMetadata;
|
|
13
|
+
get proxy(): import("../..").APIRoutes;
|
|
14
|
+
get target(): InteractionTarget<T>;
|
|
15
|
+
get t(): DefaultLocale;
|
|
16
|
+
write(body: InteractionCreateBodyRequest): Promise<void>;
|
|
17
|
+
modal(body: ModalCreateBodyRequest): Promise<void>;
|
|
18
|
+
deferReply(ephemeral?: boolean): Promise<void>;
|
|
19
|
+
editResponse(body: InteractionMessageUpdateBodyRequest): Promise<Message>;
|
|
20
|
+
deleteResponse(): Promise<void>;
|
|
21
|
+
editOrReply(body: InteractionCreateBodyRequest | InteractionMessageUpdateBodyRequest): Promise<void>;
|
|
22
|
+
fetchResponse(): Promise<import("../../structures").WebhookMessage | undefined>;
|
|
23
|
+
get author(): User;
|
|
24
|
+
get member(): import("../../structures").InteractionGuildMember | undefined;
|
|
25
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MenuCommandContext = void 0;
|
|
4
|
+
const common_1 = require("../../common");
|
|
5
|
+
const structures_1 = require("../../structures");
|
|
6
|
+
class MenuCommandContext {
|
|
7
|
+
client;
|
|
8
|
+
interaction;
|
|
9
|
+
shardId;
|
|
10
|
+
constructor(client, interaction, shardId) {
|
|
11
|
+
this.client = client;
|
|
12
|
+
this.interaction = interaction;
|
|
13
|
+
this.shardId = shardId;
|
|
14
|
+
}
|
|
15
|
+
metadata = {};
|
|
16
|
+
globalMetadata = {};
|
|
17
|
+
get proxy() {
|
|
18
|
+
return this.client.proxy;
|
|
19
|
+
}
|
|
20
|
+
// biome-ignore lint/suspicious/useGetterReturn: bugged
|
|
21
|
+
get target() {
|
|
22
|
+
switch (this.interaction.data.type) {
|
|
23
|
+
case common_1.ApplicationCommandType.Message: {
|
|
24
|
+
const data = this.interaction.data.resolved.messages[this.interaction.data.targetId];
|
|
25
|
+
return new structures_1.Message(this.client, (0, common_1.toSnakeCase)(data));
|
|
26
|
+
}
|
|
27
|
+
case common_1.ApplicationCommandType.User: {
|
|
28
|
+
const data = this.interaction.data.resolved.users[this.interaction.data.targetId];
|
|
29
|
+
return new structures_1.User(this.client, (0, common_1.toSnakeCase)(data));
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
get t() {
|
|
34
|
+
return this.client.langs.get(this.interaction.locale);
|
|
35
|
+
}
|
|
36
|
+
write(body) {
|
|
37
|
+
return this.interaction.write(body);
|
|
38
|
+
}
|
|
39
|
+
modal(body) {
|
|
40
|
+
return this.interaction.modal(body);
|
|
41
|
+
}
|
|
42
|
+
deferReply(ephemeral = false) {
|
|
43
|
+
return this.interaction.deferReply(ephemeral ? common_1.MessageFlags.Ephemeral : undefined);
|
|
44
|
+
}
|
|
45
|
+
editResponse(body) {
|
|
46
|
+
return this.interaction.editResponse(body);
|
|
47
|
+
}
|
|
48
|
+
deleteResponse() {
|
|
49
|
+
return this.interaction.deleteResponse();
|
|
50
|
+
}
|
|
51
|
+
editOrReply(body) {
|
|
52
|
+
return this.interaction.editOrReply(body);
|
|
53
|
+
}
|
|
54
|
+
fetchResponse() {
|
|
55
|
+
return this.interaction.fetchResponse();
|
|
56
|
+
}
|
|
57
|
+
get author() {
|
|
58
|
+
return this.interaction.user;
|
|
59
|
+
}
|
|
60
|
+
get member() {
|
|
61
|
+
return this.interaction.member;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
exports.MenuCommandContext = MenuCommandContext;
|