mini-interactions 0.0.0-stage → 0.15.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 +21 -0
- package/MIGRATION.md +126 -0
- package/README.md +253 -2
- package/dist/bot.d.ts +58 -0
- package/dist/bot.js +217 -0
- package/dist/builders/ActionRowBuilder.d.ts +22 -0
- package/dist/builders/ActionRowBuilder.js +33 -0
- package/dist/builders/AutomodRuleBuilder.d.ts +45 -0
- package/dist/builders/AutomodRuleBuilder.js +151 -0
- package/dist/builders/ButtonBuilder.d.ts +53 -0
- package/dist/builders/ButtonBuilder.js +124 -0
- package/dist/builders/ChannelSelectMenuBuilder.d.ts +53 -0
- package/dist/builders/ChannelSelectMenuBuilder.js +105 -0
- package/dist/builders/CheckboxBuilder.d.ts +20 -0
- package/dist/builders/CheckboxBuilder.js +20 -0
- package/dist/builders/CheckboxGroupBuilder.d.ts +25 -0
- package/dist/builders/CheckboxGroupBuilder.js +48 -0
- package/dist/builders/EmbedBuilder.d.ts +33 -0
- package/dist/builders/EmbedBuilder.js +103 -0
- package/dist/builders/FileUploadBuilder.d.ts +17 -0
- package/dist/builders/FileUploadBuilder.js +22 -0
- package/dist/builders/LabelBuilder.d.ts +16 -0
- package/dist/builders/LabelBuilder.js +21 -0
- package/dist/builders/MiniContainerBuilder.d.ts +131 -0
- package/dist/builders/MiniContainerBuilder.js +347 -0
- package/dist/builders/ModalBuilder.d.ts +16 -0
- package/dist/builders/ModalBuilder.js +36 -0
- package/dist/builders/ModalChannelSelectMenuBuilder.d.ts +29 -0
- package/dist/builders/ModalChannelSelectMenuBuilder.js +25 -0
- package/dist/builders/ModalMentionableSelectMenuBuilder.d.ts +53 -0
- package/dist/builders/ModalMentionableSelectMenuBuilder.js +87 -0
- package/dist/builders/ModalRoleSelectMenuBuilder.d.ts +27 -0
- package/dist/builders/ModalRoleSelectMenuBuilder.js +24 -0
- package/dist/builders/ModalStringSelectMenuBuilder.d.ts +62 -0
- package/dist/builders/ModalStringSelectMenuBuilder.js +120 -0
- package/dist/builders/ModalUserSelectMenuBuilder.d.ts +53 -0
- package/dist/builders/ModalUserSelectMenuBuilder.js +96 -0
- package/dist/builders/RadioBuilder.d.ts +22 -0
- package/dist/builders/RadioBuilder.js +36 -0
- package/dist/builders/RoleSelectMenuBuilder.d.ts +47 -0
- package/dist/builders/RoleSelectMenuBuilder.js +92 -0
- package/dist/builders/StringSelectMenuBuilder.d.ts +52 -0
- package/dist/builders/StringSelectMenuBuilder.js +104 -0
- package/dist/builders/StringSelectMenuOptionBuilder.d.ts +46 -0
- package/dist/builders/StringSelectMenuOptionBuilder.js +106 -0
- package/dist/builders/TextInputBuilder.d.ts +23 -0
- package/dist/builders/TextInputBuilder.js +26 -0
- package/dist/builders/index.d.ts +44 -0
- package/dist/builders/index.js +22 -0
- package/dist/builders/shared.d.ts +8 -0
- package/dist/builders/shared.js +11 -0
- package/dist/commands/CommandBuilder.d.ts +278 -0
- package/dist/commands/CommandBuilder.js +687 -0
- package/dist/commands/ContextMenuCommandBuilder.d.ts +94 -0
- package/dist/commands/ContextMenuCommandBuilder.js +145 -0
- package/dist/core/http/DiscordRestClient.d.ts +400 -0
- package/dist/core/http/DiscordRestClient.js +988 -0
- package/dist/core/interactions/InteractionContext.d.ts +33 -0
- package/dist/core/interactions/InteractionContext.js +61 -0
- package/dist/core/interactions/InteractionVerifier.d.ts +8 -0
- package/dist/core/interactions/InteractionVerifier.js +9 -0
- package/dist/core/messages/DiscordSentMessage.d.ts +32 -0
- package/dist/core/messages/DiscordSentMessage.js +64 -0
- package/dist/core/messages/message-payloads.d.ts +94 -0
- package/dist/core/messages/message-payloads.js +99 -0
- package/dist/core/webhooks/DiscordWebhook.d.ts +14 -0
- package/dist/core/webhooks/DiscordWebhook.js +69 -0
- package/dist/database/MiniDataBuilder.d.ts +61 -0
- package/dist/database/MiniDataBuilder.js +98 -0
- package/dist/database/MiniDatabase.d.ts +67 -0
- package/dist/database/MiniDatabase.js +222 -0
- package/dist/database/MiniDatabaseBuilder.d.ts +58 -0
- package/dist/database/MiniDatabaseBuilder.js +84 -0
- package/dist/database/index.d.ts +5 -0
- package/dist/database/index.js +3 -0
- package/dist/identity/ApplicationIdentityProfile.d.ts +188 -0
- package/dist/identity/ApplicationIdentityProfile.js +207 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +34 -0
- package/dist/lobby/Lobby.d.ts +150 -0
- package/dist/lobby/Lobby.js +90 -0
- package/dist/node/MiniInteraction.d.ts +199 -0
- package/dist/node/MiniInteraction.js +861 -0
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +1 -0
- package/dist/oauth2/DiscordOAuth.d.ts +49 -0
- package/dist/oauth2/DiscordOAuth.js +113 -0
- package/dist/oauth2/OAuth2Builder.d.ts +296 -0
- package/dist/oauth2/OAuth2Builder.js +435 -0
- package/dist/oauth2/OAuth2Scopes.d.ts +285 -0
- package/dist/oauth2/OAuth2Scopes.js +438 -0
- package/dist/oauth2/OAuthTokenStorage.d.ts +37 -0
- package/dist/oauth2/OAuthTokenStorage.js +109 -0
- package/dist/oauth2/index.d.ts +8 -0
- package/dist/oauth2/index.js +4 -0
- package/dist/router/AutocompleteContext.d.ts +36 -0
- package/dist/router/AutocompleteContext.js +82 -0
- package/dist/router/InteractionRouter.d.ts +82 -0
- package/dist/router/InteractionRouter.js +225 -0
- package/dist/types/ButtonStyle.d.ts +16 -0
- package/dist/types/ButtonStyle.js +17 -0
- package/dist/types/ChannelType.d.ts +2 -0
- package/dist/types/ChannelType.js +2 -0
- package/dist/types/Commands.d.ts +35 -0
- package/dist/types/Commands.js +1 -0
- package/dist/types/ComponentTypes.d.ts +19 -0
- package/dist/types/ComponentTypes.js +1 -0
- package/dist/types/InteractionFlags.d.ts +5 -0
- package/dist/types/InteractionFlags.js +6 -0
- package/dist/types/PermissionFlags.d.ts +56 -0
- package/dist/types/PermissionFlags.js +5 -0
- package/dist/types/RoleConnectionMetadata.d.ts +14 -0
- package/dist/types/RoleConnectionMetadata.js +1 -0
- package/dist/types/RoleConnectionMetadataTypes.d.ts +11 -0
- package/dist/types/RoleConnectionMetadataTypes.js +12 -0
- package/dist/types/SeparatorSpacingSize.d.ts +2 -0
- package/dist/types/SeparatorSpacingSize.js +2 -0
- package/dist/types/checkbox.d.ts +16 -0
- package/dist/types/checkbox.js +12 -0
- package/dist/types/discord.d.ts +2 -0
- package/dist/types/discord.js +1 -0
- package/dist/types/radio.d.ts +12 -0
- package/dist/types/radio.js +10 -0
- package/dist/types/validation.d.ts +14 -0
- package/dist/types/validation.js +40 -0
- package/dist/utils/CommandInteractionOptions.d.ts +66 -0
- package/dist/utils/CommandInteractionOptions.js +364 -0
- package/dist/utils/ContextMenuInteraction.d.ts +76 -0
- package/dist/utils/ContextMenuInteraction.js +152 -0
- package/dist/utils/MessageComponentInteraction.d.ts +148 -0
- package/dist/utils/MessageComponentInteraction.js +259 -0
- package/dist/utils/ModalSubmitInteraction.d.ts +86 -0
- package/dist/utils/ModalSubmitInteraction.js +267 -0
- package/dist/utils/cdn.d.ts +30 -0
- package/dist/utils/cdn.js +60 -0
- package/dist/utils/formatting.d.ts +76 -0
- package/dist/utils/formatting.js +132 -0
- package/dist/utils/interactionMessageHelpers.d.ts +40 -0
- package/dist/utils/interactionMessageHelpers.js +118 -0
- package/dist/utils/localization.d.ts +25 -0
- package/dist/utils/localization.js +38 -0
- package/dist/utils/snowflake.d.ts +19 -0
- package/dist/utils/snowflake.js +32 -0
- package/dist/webhooks/WebhookEvent.d.ts +229 -0
- package/dist/webhooks/WebhookEvent.js +59 -0
- package/dist/webhooks/WebhookEventRouter.d.ts +123 -0
- package/dist/webhooks/WebhookEventRouter.js +160 -0
- package/dist/webhooks/WebhookEventVerifier.d.ts +33 -0
- package/dist/webhooks/WebhookEventVerifier.js +37 -0
- package/dist/webhooks/index.d.ts +6 -0
- package/dist/webhooks/index.js +3 -0
- package/package.json +90 -4
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { InteractionResponseType, } from "discord-api-types/v10";
|
|
2
|
+
/**
|
|
3
|
+
* Context for autocomplete interactions (`InteractionType.ApplicationCommandAutocomplete`).
|
|
4
|
+
* Collects up to 25 choice suggestions and produces the `type: 8` response.
|
|
5
|
+
*/
|
|
6
|
+
export class AutocompleteContext {
|
|
7
|
+
interaction;
|
|
8
|
+
responded = false;
|
|
9
|
+
autocompleteResponse;
|
|
10
|
+
constructor(interaction) {
|
|
11
|
+
this.interaction = interaction;
|
|
12
|
+
}
|
|
13
|
+
/** Name of the command being autocompleted. */
|
|
14
|
+
get commandName() {
|
|
15
|
+
return this.interaction.data.name;
|
|
16
|
+
}
|
|
17
|
+
get hasResponded() {
|
|
18
|
+
return this.responded;
|
|
19
|
+
}
|
|
20
|
+
/** The raw response produced by {@link respond}, if any. */
|
|
21
|
+
get result() {
|
|
22
|
+
return this.autocompleteResponse;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Finds the option the user is currently typing in.
|
|
26
|
+
*
|
|
27
|
+
* @param required - Throw when no focused option exists instead of returning null.
|
|
28
|
+
*/
|
|
29
|
+
getFocusedOption(required = true) {
|
|
30
|
+
const found = this.search(this.interaction.data.options ?? []);
|
|
31
|
+
if (!found) {
|
|
32
|
+
if (required) {
|
|
33
|
+
throw new Error("[MiniInteraction] No focused option on this autocomplete interaction.");
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return found;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Answers the autocomplete request with up to 25 choices.
|
|
41
|
+
* Plain strings are accepted as shorthand for `{ name, value }` pairs.
|
|
42
|
+
*/
|
|
43
|
+
respond(choices) {
|
|
44
|
+
if (!Array.isArray(choices)) {
|
|
45
|
+
throw new Error("[MiniInteraction] Autocomplete choices must be an array.");
|
|
46
|
+
}
|
|
47
|
+
this.responded = true;
|
|
48
|
+
this.autocompleteResponse = {
|
|
49
|
+
type: InteractionResponseType.ApplicationCommandAutocompleteResult,
|
|
50
|
+
data: {
|
|
51
|
+
choices: choices
|
|
52
|
+
.slice(0, 25)
|
|
53
|
+
.map((choice) => typeof choice === "string"
|
|
54
|
+
? { name: choice, value: choice }
|
|
55
|
+
: { ...choice }),
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
return this.autocompleteResponse;
|
|
59
|
+
}
|
|
60
|
+
search(options, path = {}) {
|
|
61
|
+
for (const option of options) {
|
|
62
|
+
if ("focused" in option && option.focused) {
|
|
63
|
+
return {
|
|
64
|
+
name: option.name,
|
|
65
|
+
value: option.value,
|
|
66
|
+
type: option.type,
|
|
67
|
+
subcommandGroup: path.subcommandGroup,
|
|
68
|
+
subcommand: path.subcommand,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
if ("options" in option && Array.isArray(option.options)) {
|
|
72
|
+
const nested = this.search(option.options, {
|
|
73
|
+
subcommandGroup: option.type === 2 /* SubcommandGroup */ ? option.name : path.subcommandGroup,
|
|
74
|
+
subcommand: option.type === 1 /* Subcommand */ ? option.name : path.subcommand,
|
|
75
|
+
});
|
|
76
|
+
if (nested)
|
|
77
|
+
return nested;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { type APIInteraction, type APIInteractionResponse } from "discord-api-types/v10";
|
|
2
|
+
import { DiscordRestClient } from "../core/http/DiscordRestClient.js";
|
|
3
|
+
import { InteractionContext } from "../core/interactions/InteractionContext.js";
|
|
4
|
+
import { CommandInteraction } from "../utils/CommandInteractionOptions.js";
|
|
5
|
+
import { AppCommandInteraction, MessageContextMenuInteraction, UserContextMenuInteraction } from "../utils/ContextMenuInteraction.js";
|
|
6
|
+
import { MessageComponentInteraction } from "../utils/MessageComponentInteraction.js";
|
|
7
|
+
import { ModalSubmitInteraction } from "../utils/ModalSubmitInteraction.js";
|
|
8
|
+
import { AutocompleteContext } from "./AutocompleteContext.js";
|
|
9
|
+
/** Handler for chat-input (slash) commands. */
|
|
10
|
+
export type ChatInputHandler = (interaction: CommandInteraction, ctx: InteractionContext) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
11
|
+
/** Handler for User context menu commands. */
|
|
12
|
+
export type UserMenuHandler = (interaction: UserContextMenuInteraction, ctx: InteractionContext) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
13
|
+
/** Handler for Message context menu commands. */
|
|
14
|
+
export type MessageMenuHandler = (interaction: MessageContextMenuInteraction, ctx: InteractionContext) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
15
|
+
/** Handler for Primary Entry Point commands. */
|
|
16
|
+
export type EntryPointHandler = (interaction: AppCommandInteraction, ctx: InteractionContext) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
17
|
+
/** Handler for message components (buttons, selects, ...). */
|
|
18
|
+
export type ComponentHandler = (interaction: MessageComponentInteraction, ctx: InteractionContext) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
19
|
+
/** Handler for modal submissions. */
|
|
20
|
+
export type ModalHandler = (interaction: ModalSubmitInteraction, ctx: InteractionContext) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
21
|
+
/** Handler for autocomplete requests. */
|
|
22
|
+
export type AutocompleteHandler = (interaction: AutocompleteContext, ctx: InteractionContext) => Promise<void> | void;
|
|
23
|
+
/** Middleware executed before dispatch; call `next()` to continue the chain. */
|
|
24
|
+
export type RouterMiddleware = (interaction: APIInteraction, ctx: InteractionContext, next: () => Promise<APIInteractionResponse | void>) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
25
|
+
/** Error hook; return a response to answer the interaction gracefully. */
|
|
26
|
+
export type RouterErrorHandler = (error: unknown, interaction: APIInteraction, ctx: InteractionContext) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
27
|
+
/** Fallback invoked when no handler matches an interaction. */
|
|
28
|
+
export type RouterFallback = (interaction: APIInteraction, ctx: InteractionContext) => APIInteractionResponse | void;
|
|
29
|
+
export type InteractionRouterOptions = {
|
|
30
|
+
/** Optional REST client (or lazy resolver) used to commit deferred edits/follow-ups automatically. */
|
|
31
|
+
rest?: DiscordRestClient | (() => DiscordRestClient | undefined);
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Dispatches interactions to registered handlers with support for chat-input
|
|
35
|
+
* commands, context menus, primary entry points, components, modals and
|
|
36
|
+
* autocomplete — including middleware, error hooks and pattern-based custom ids.
|
|
37
|
+
*/
|
|
38
|
+
export declare class InteractionRouter {
|
|
39
|
+
private readonly options;
|
|
40
|
+
private readonly commandHandlers;
|
|
41
|
+
private readonly exactComponentHandlers;
|
|
42
|
+
private readonly globComponentEntries;
|
|
43
|
+
private readonly regexComponentEntries;
|
|
44
|
+
private readonly modalHandlers;
|
|
45
|
+
private readonly autocompleteHandlers;
|
|
46
|
+
private readonly middleware;
|
|
47
|
+
private errorHandler?;
|
|
48
|
+
private fallbackHandler?;
|
|
49
|
+
constructor(options?: InteractionRouterOptions);
|
|
50
|
+
onCommand(name: string, handler: ChatInputHandler): this;
|
|
51
|
+
/** Registers a User context menu command handler. */
|
|
52
|
+
onUserCommand(name: string, handler: UserMenuHandler): this;
|
|
53
|
+
/** Registers a Message context menu command handler. */
|
|
54
|
+
onMessageCommand(name: string, handler: MessageMenuHandler): this;
|
|
55
|
+
/** Registers a Primary Entry Point command handler. */
|
|
56
|
+
onEntryPointCommand(name: string, handler: EntryPointHandler): this;
|
|
57
|
+
/**
|
|
58
|
+
* Registers a component handler. Exact custom ids take priority over
|
|
59
|
+
* patterns; glob patterns (`config:*`) match by longest prefix, regexes
|
|
60
|
+
* are tested in registration order.
|
|
61
|
+
*/
|
|
62
|
+
onComponent(customIdOrPattern: string | RegExp, handler: ComponentHandler): this;
|
|
63
|
+
onModal(customId: string, handler: ModalHandler): this;
|
|
64
|
+
/** Registers an autocomplete handler for a chat-input command name. */
|
|
65
|
+
onAutocomplete(commandName: string, handler: AutocompleteHandler): this;
|
|
66
|
+
/** Adds middleware that runs before dispatch. Call `next()` to continue. */
|
|
67
|
+
use(middleware: RouterMiddleware): this;
|
|
68
|
+
/** Sets the error hook used when a handler or middleware throws. */
|
|
69
|
+
onError(handler: RouterErrorHandler): this;
|
|
70
|
+
/** Sets the fallback used when no handler matches (e.g. a default defer). */
|
|
71
|
+
onFallback(handler: RouterFallback): this;
|
|
72
|
+
dispatch(interaction: APIInteraction, ctx: InteractionContext): Promise<APIInteractionResponse | void>;
|
|
73
|
+
private handle;
|
|
74
|
+
/**
|
|
75
|
+
* Resolves a component handler: exact id first, then glob prefix patterns
|
|
76
|
+
* (longest prefix wins), then regex patterns in registration order.
|
|
77
|
+
*/
|
|
78
|
+
private matchComponent;
|
|
79
|
+
private commandKey;
|
|
80
|
+
private resolveRest;
|
|
81
|
+
private buildHelpers;
|
|
82
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { ApplicationCommandType, InteractionType, } from "discord-api-types/v10";
|
|
2
|
+
import { createCommandInteraction, } from "../utils/CommandInteractionOptions.js";
|
|
3
|
+
import { createAppCommandInteraction, createMessageContextMenuInteraction, createUserContextMenuInteraction, } from "../utils/ContextMenuInteraction.js";
|
|
4
|
+
import { createMessageComponentInteraction, } from "../utils/MessageComponentInteraction.js";
|
|
5
|
+
import { createModalSubmitInteraction, } from "../utils/ModalSubmitInteraction.js";
|
|
6
|
+
import { AutocompleteContext } from "./AutocompleteContext.js";
|
|
7
|
+
/**
|
|
8
|
+
* Dispatches interactions to registered handlers with support for chat-input
|
|
9
|
+
* commands, context menus, primary entry points, components, modals and
|
|
10
|
+
* autocomplete — including middleware, error hooks and pattern-based custom ids.
|
|
11
|
+
*/
|
|
12
|
+
export class InteractionRouter {
|
|
13
|
+
options;
|
|
14
|
+
commandHandlers = new Map();
|
|
15
|
+
exactComponentHandlers = new Map();
|
|
16
|
+
globComponentEntries = [];
|
|
17
|
+
regexComponentEntries = [];
|
|
18
|
+
modalHandlers = new Map();
|
|
19
|
+
autocompleteHandlers = new Map();
|
|
20
|
+
middleware = [];
|
|
21
|
+
errorHandler;
|
|
22
|
+
fallbackHandler;
|
|
23
|
+
constructor(options = {}) {
|
|
24
|
+
this.options = options;
|
|
25
|
+
}
|
|
26
|
+
onCommand(name, handler) {
|
|
27
|
+
this.commandHandlers.set(this.commandKey(ApplicationCommandType.ChatInput, name), { type: ApplicationCommandType.ChatInput, handler });
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
/** Registers a User context menu command handler. */
|
|
31
|
+
onUserCommand(name, handler) {
|
|
32
|
+
this.commandHandlers.set(this.commandKey(ApplicationCommandType.User, name), { type: ApplicationCommandType.User, handler });
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
/** Registers a Message context menu command handler. */
|
|
36
|
+
onMessageCommand(name, handler) {
|
|
37
|
+
this.commandHandlers.set(this.commandKey(ApplicationCommandType.Message, name), { type: ApplicationCommandType.Message, handler });
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
/** Registers a Primary Entry Point command handler. */
|
|
41
|
+
onEntryPointCommand(name, handler) {
|
|
42
|
+
this.commandHandlers.set(this.commandKey(ApplicationCommandType.PrimaryEntryPoint, name), { type: ApplicationCommandType.PrimaryEntryPoint, handler });
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Registers a component handler. Exact custom ids take priority over
|
|
47
|
+
* patterns; glob patterns (`config:*`) match by longest prefix, regexes
|
|
48
|
+
* are tested in registration order.
|
|
49
|
+
*/
|
|
50
|
+
onComponent(customIdOrPattern, handler) {
|
|
51
|
+
if (typeof customIdOrPattern === "string") {
|
|
52
|
+
if (customIdOrPattern.endsWith("*")) {
|
|
53
|
+
const entry = { prefix: customIdOrPattern.slice(0, -1), handler };
|
|
54
|
+
const insertAt = this.globComponentEntries.findIndex((candidate) => candidate.prefix.length < entry.prefix.length);
|
|
55
|
+
if (insertAt === -1) {
|
|
56
|
+
this.globComponentEntries.push(entry);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
this.globComponentEntries.splice(insertAt, 0, entry);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.exactComponentHandlers.set(customIdOrPattern, handler);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.regexComponentEntries.push({ matcher: new RegExp(customIdOrPattern.source, customIdOrPattern.flags), handler });
|
|
68
|
+
}
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
onModal(customId, handler) {
|
|
72
|
+
this.modalHandlers.set(customId, handler);
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/** Registers an autocomplete handler for a chat-input command name. */
|
|
76
|
+
onAutocomplete(commandName, handler) {
|
|
77
|
+
this.autocompleteHandlers.set(commandName, handler);
|
|
78
|
+
return this;
|
|
79
|
+
}
|
|
80
|
+
/** Adds middleware that runs before dispatch. Call `next()` to continue. */
|
|
81
|
+
use(middleware) {
|
|
82
|
+
this.middleware.push(middleware);
|
|
83
|
+
return this;
|
|
84
|
+
}
|
|
85
|
+
/** Sets the error hook used when a handler or middleware throws. */
|
|
86
|
+
onError(handler) {
|
|
87
|
+
this.errorHandler = handler;
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
/** Sets the fallback used when no handler matches (e.g. a default defer). */
|
|
91
|
+
onFallback(handler) {
|
|
92
|
+
this.fallbackHandler = handler;
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
async dispatch(interaction, ctx) {
|
|
96
|
+
try {
|
|
97
|
+
if (this.middleware.length === 0) {
|
|
98
|
+
return await this.handle(interaction, ctx);
|
|
99
|
+
}
|
|
100
|
+
let index = -1;
|
|
101
|
+
const run = async () => {
|
|
102
|
+
index += 1;
|
|
103
|
+
if (index < this.middleware.length) {
|
|
104
|
+
return this.middleware[index](interaction, ctx, run);
|
|
105
|
+
}
|
|
106
|
+
return this.handle(interaction, ctx);
|
|
107
|
+
};
|
|
108
|
+
return await run();
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
if (!this.errorHandler)
|
|
112
|
+
throw error;
|
|
113
|
+
return this.errorHandler(error, interaction, ctx);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
async handle(interaction, ctx) {
|
|
117
|
+
if (interaction.type === InteractionType.ApplicationCommand) {
|
|
118
|
+
const entry = interaction.data.name !== undefined
|
|
119
|
+
? this.commandHandlers.get(this.commandKey(interaction.data.type, interaction.data.name))
|
|
120
|
+
: undefined;
|
|
121
|
+
if (!entry || entry.type !== interaction.data.type) {
|
|
122
|
+
return this.fallbackHandler?.(interaction, ctx);
|
|
123
|
+
}
|
|
124
|
+
const captured = [];
|
|
125
|
+
const helpers = this.buildHelpers(captured);
|
|
126
|
+
let result;
|
|
127
|
+
switch (interaction.data.type) {
|
|
128
|
+
case ApplicationCommandType.ChatInput:
|
|
129
|
+
result = await entry.handler(createCommandInteraction(interaction, helpers), ctx);
|
|
130
|
+
break;
|
|
131
|
+
case ApplicationCommandType.User:
|
|
132
|
+
result = await entry.handler(createUserContextMenuInteraction(interaction, helpers), ctx);
|
|
133
|
+
break;
|
|
134
|
+
case ApplicationCommandType.Message:
|
|
135
|
+
result = await entry.handler(createMessageContextMenuInteraction(interaction, helpers), ctx);
|
|
136
|
+
break;
|
|
137
|
+
case ApplicationCommandType.PrimaryEntryPoint:
|
|
138
|
+
result = await entry.handler(createAppCommandInteraction(interaction, helpers), ctx);
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
return this.fallbackHandler?.(interaction, ctx);
|
|
142
|
+
}
|
|
143
|
+
return result ?? captured[0];
|
|
144
|
+
}
|
|
145
|
+
if (interaction.type === InteractionType.MessageComponent) {
|
|
146
|
+
const handler = this.matchComponent(interaction.data.custom_id);
|
|
147
|
+
if (!handler)
|
|
148
|
+
return this.fallbackHandler?.(interaction, ctx);
|
|
149
|
+
const captured = [];
|
|
150
|
+
const wrapped = createMessageComponentInteraction(interaction, this.buildHelpers(captured));
|
|
151
|
+
const result = await handler(wrapped, ctx);
|
|
152
|
+
return result ?? captured[0];
|
|
153
|
+
}
|
|
154
|
+
if (interaction.type === InteractionType.ModalSubmit) {
|
|
155
|
+
const handler = this.modalHandlers.get(interaction.data.custom_id);
|
|
156
|
+
if (!handler)
|
|
157
|
+
return this.fallbackHandler?.(interaction, ctx);
|
|
158
|
+
const captured = [];
|
|
159
|
+
const wrapped = createModalSubmitInteraction(interaction, this.buildHelpers(captured));
|
|
160
|
+
const result = await handler(wrapped, ctx);
|
|
161
|
+
return result ?? captured[0];
|
|
162
|
+
}
|
|
163
|
+
if (interaction.type === InteractionType.ApplicationCommandAutocomplete) {
|
|
164
|
+
const handler = this.autocompleteHandlers.get(interaction.data.name);
|
|
165
|
+
if (!handler)
|
|
166
|
+
return this.fallbackHandler?.(interaction, ctx);
|
|
167
|
+
const autocomplete = new AutocompleteContext(interaction);
|
|
168
|
+
await handler(autocomplete, ctx);
|
|
169
|
+
return autocomplete.result;
|
|
170
|
+
}
|
|
171
|
+
return this.fallbackHandler?.(interaction, ctx);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Resolves a component handler: exact id first, then glob prefix patterns
|
|
175
|
+
* (longest prefix wins), then regex patterns in registration order.
|
|
176
|
+
*/
|
|
177
|
+
matchComponent(customId) {
|
|
178
|
+
const exact = this.exactComponentHandlers.get(customId);
|
|
179
|
+
if (exact)
|
|
180
|
+
return exact;
|
|
181
|
+
for (const entry of this.globComponentEntries) {
|
|
182
|
+
if (customId.startsWith(entry.prefix)) {
|
|
183
|
+
return entry.handler;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
for (const entry of this.regexComponentEntries) {
|
|
187
|
+
entry.matcher.lastIndex = 0;
|
|
188
|
+
const matches = entry.matcher.test(customId);
|
|
189
|
+
entry.matcher.lastIndex = 0;
|
|
190
|
+
if (matches) {
|
|
191
|
+
return entry.handler;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return undefined;
|
|
195
|
+
}
|
|
196
|
+
commandKey(type, name) {
|
|
197
|
+
return `${type}:${name}`;
|
|
198
|
+
}
|
|
199
|
+
resolveRest() {
|
|
200
|
+
const rest = this.options.rest;
|
|
201
|
+
return typeof rest === "function" ? rest() : rest;
|
|
202
|
+
}
|
|
203
|
+
buildHelpers(captured) {
|
|
204
|
+
return {
|
|
205
|
+
canRespond: (_interactionId) => true,
|
|
206
|
+
trackResponse: () => { },
|
|
207
|
+
onAck: (response) => {
|
|
208
|
+
if (!captured.includes(response))
|
|
209
|
+
captured.push(response);
|
|
210
|
+
},
|
|
211
|
+
sendFollowUp: this.resolveRest()
|
|
212
|
+
? async (token, response, messageId) => {
|
|
213
|
+
const rest = this.resolveRest();
|
|
214
|
+
const data = "data" in response ? response.data ?? {} : {};
|
|
215
|
+
if (messageId === "@original") {
|
|
216
|
+
await rest.editOriginal(token, data);
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
await rest.createFollowup(token, data);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
: undefined,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Visual styles for Discord buttons matching the public API values. */
|
|
2
|
+
export declare enum ButtonStyle {
|
|
3
|
+
/** The most prominent option in a set of actions. */
|
|
4
|
+
Primary = 1,
|
|
5
|
+
/** A neutral action that complements the primary action. */
|
|
6
|
+
Secondary = 2,
|
|
7
|
+
/** Indicates a successful or positive action. */
|
|
8
|
+
Success = 3,
|
|
9
|
+
/** Highlights a potentially destructive action. */
|
|
10
|
+
Danger = 4,
|
|
11
|
+
/** Navigates the user to an external URL. */
|
|
12
|
+
Link = 5,
|
|
13
|
+
/** Initiates a premium purchase flow. */
|
|
14
|
+
Premium = 6
|
|
15
|
+
}
|
|
16
|
+
export default ButtonStyle;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Visual styles for Discord buttons matching the public API values. */
|
|
2
|
+
export var ButtonStyle;
|
|
3
|
+
(function (ButtonStyle) {
|
|
4
|
+
/** The most prominent option in a set of actions. */
|
|
5
|
+
ButtonStyle[ButtonStyle["Primary"] = 1] = "Primary";
|
|
6
|
+
/** A neutral action that complements the primary action. */
|
|
7
|
+
ButtonStyle[ButtonStyle["Secondary"] = 2] = "Secondary";
|
|
8
|
+
/** Indicates a successful or positive action. */
|
|
9
|
+
ButtonStyle[ButtonStyle["Success"] = 3] = "Success";
|
|
10
|
+
/** Highlights a potentially destructive action. */
|
|
11
|
+
ButtonStyle[ButtonStyle["Danger"] = 4] = "Danger";
|
|
12
|
+
/** Navigates the user to an external URL. */
|
|
13
|
+
ButtonStyle[ButtonStyle["Link"] = 5] = "Link";
|
|
14
|
+
/** Initiates a premium purchase flow. */
|
|
15
|
+
ButtonStyle[ButtonStyle["Premium"] = 6] = "Premium";
|
|
16
|
+
})(ButtonStyle || (ButtonStyle = {}));
|
|
17
|
+
export default ButtonStyle;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { APIInteractionResponse, RESTPostAPIChatInputApplicationCommandsJSONBody, RESTPostAPIContextMenuApplicationCommandsJSONBody, RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody } from "discord-api-types/v10";
|
|
2
|
+
import type { CommandInteraction } from "../utils/CommandInteractionOptions.js";
|
|
3
|
+
import type { UserContextMenuInteraction, MessageContextMenuInteraction, AppCommandInteraction } from "../utils/ContextMenuInteraction.js";
|
|
4
|
+
import type { ButtonInteraction, StringSelectInteraction, RoleSelectInteraction, UserSelectInteraction, ChannelSelectInteraction, MentionableSelectInteraction, RadioInteraction, CheckboxInteraction } from "../utils/MessageComponentInteraction.js";
|
|
5
|
+
import type { ModalSubmitInteraction } from "../utils/ModalSubmitInteraction.js";
|
|
6
|
+
import type { JSONEncodable } from "../builders/shared.js";
|
|
7
|
+
import type { CommandBuilder } from "../commands/CommandBuilder.js";
|
|
8
|
+
import type { MessageCommandBuilder, UserCommandBuilder, AppCommandBuilder } from "../commands/ContextMenuCommandBuilder.js";
|
|
9
|
+
/** Handler signature for slash command executions within MiniInteraction. */
|
|
10
|
+
export type SlashCommandHandler = (interaction: CommandInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
11
|
+
/** Handler signature for user context menu command executions within MiniInteraction. */
|
|
12
|
+
export type UserCommandHandler = (interaction: UserContextMenuInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
13
|
+
/** Handler signature for message context menu command executions within MiniInteraction. */
|
|
14
|
+
export type MessageCommandHandler = (interaction: MessageContextMenuInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
15
|
+
/** Handler signature for primary entry point command executions within MiniInteraction. */
|
|
16
|
+
export type AppCommandHandler = (interaction: AppCommandInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
17
|
+
/** Union of all command handler types. */
|
|
18
|
+
export type CommandHandler = SlashCommandHandler | UserCommandHandler | MessageCommandHandler | AppCommandHandler;
|
|
19
|
+
/** Structure representing a slash command definition and its runtime handler. */
|
|
20
|
+
export type InteractionCommand = {
|
|
21
|
+
data: RESTPostAPIChatInputApplicationCommandsJSONBody | RESTPostAPIContextMenuApplicationCommandsJSONBody | RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody | CommandBuilder | UserCommandBuilder | MessageCommandBuilder | AppCommandBuilder | JSONEncodable<RESTPostAPIChatInputApplicationCommandsJSONBody | RESTPostAPIContextMenuApplicationCommandsJSONBody | RESTPostAPIPrimaryEntryPointApplicationCommandJSONBody>;
|
|
22
|
+
handler: CommandHandler;
|
|
23
|
+
};
|
|
24
|
+
/** Handler for any message component interaction */
|
|
25
|
+
export type ComponentInteraction = ButtonInteraction | StringSelectInteraction | RoleSelectInteraction | UserSelectInteraction | ChannelSelectInteraction | MentionableSelectInteraction | RadioInteraction | CheckboxInteraction;
|
|
26
|
+
/** Structure for a standalone component handler */
|
|
27
|
+
export type InteractionComponent = {
|
|
28
|
+
customId: string;
|
|
29
|
+
handler: (interaction: ComponentInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
30
|
+
};
|
|
31
|
+
/** Structure for a standalone modal handler */
|
|
32
|
+
export type InteractionModal = {
|
|
33
|
+
customId: string;
|
|
34
|
+
handler: (interaction: ModalSubmitInteraction) => Promise<APIInteractionResponse | void> | APIInteractionResponse | void;
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { APIComponentInActionRow, APIComponentInMessageActionRow, APIModalInteractionResponseCallbackComponent } from "discord-api-types/v10";
|
|
2
|
+
import type { APIRadioComponent } from "./radio.js";
|
|
3
|
+
import type { APICheckboxComponent } from "./checkbox.js";
|
|
4
|
+
/** Defines a component structure for use in ActionRow builders. */
|
|
5
|
+
export type ActionRowComponent = APIComponentInActionRow | APIRadioComponent | APICheckboxComponent;
|
|
6
|
+
/** Defines a message component structure for use in message builders. */
|
|
7
|
+
export type MessageActionRowComponent = APIComponentInMessageActionRow;
|
|
8
|
+
/** Structure for an action row containing mini-interaction components. */
|
|
9
|
+
export interface MiniActionRow<T extends ActionRowComponent = ActionRowComponent> {
|
|
10
|
+
type: 1;
|
|
11
|
+
components: T[];
|
|
12
|
+
}
|
|
13
|
+
/** Structure for a message action row containing mini-interaction components. */
|
|
14
|
+
export interface MessageMiniActionRow<T extends MessageActionRowComponent = MessageActionRowComponent> {
|
|
15
|
+
type: 1;
|
|
16
|
+
components: T[];
|
|
17
|
+
}
|
|
18
|
+
/** Generic type for any supported interaction component data. */
|
|
19
|
+
export type InteractionComponentData = MessageActionRowComponent | APIModalInteractionResponseCallbackComponent;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export var InteractionFlags;
|
|
2
|
+
(function (InteractionFlags) {
|
|
3
|
+
InteractionFlags[InteractionFlags["Ephemeral"] = 64] = "Ephemeral";
|
|
4
|
+
InteractionFlags[InteractionFlags["IsComponentsV2"] = 32768] = "IsComponentsV2";
|
|
5
|
+
InteractionFlags[InteractionFlags["SuppressEmbeds"] = 4] = "SuppressEmbeds";
|
|
6
|
+
})(InteractionFlags || (InteractionFlags = {}));
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/** Convenience mapping of Discord permission bit flags for MiniInteraction usage. */
|
|
2
|
+
export declare const MiniPermFlags: {
|
|
3
|
+
readonly CreateInstantInvite: bigint;
|
|
4
|
+
readonly KickMembers: bigint;
|
|
5
|
+
readonly BanMembers: bigint;
|
|
6
|
+
readonly Administrator: bigint;
|
|
7
|
+
readonly ManageChannels: bigint;
|
|
8
|
+
readonly ManageGuild: bigint;
|
|
9
|
+
readonly AddReactions: bigint;
|
|
10
|
+
readonly ViewAuditLog: bigint;
|
|
11
|
+
readonly PrioritySpeaker: bigint;
|
|
12
|
+
readonly Stream: bigint;
|
|
13
|
+
readonly ViewChannel: bigint;
|
|
14
|
+
readonly SendMessages: bigint;
|
|
15
|
+
readonly SendTTSMessages: bigint;
|
|
16
|
+
readonly ManageMessages: bigint;
|
|
17
|
+
readonly EmbedLinks: bigint;
|
|
18
|
+
readonly AttachFiles: bigint;
|
|
19
|
+
readonly ReadMessageHistory: bigint;
|
|
20
|
+
readonly MentionEveryone: bigint;
|
|
21
|
+
readonly UseExternalEmojis: bigint;
|
|
22
|
+
readonly ViewGuildInsights: bigint;
|
|
23
|
+
readonly Connect: bigint;
|
|
24
|
+
readonly Speak: bigint;
|
|
25
|
+
readonly MuteMembers: bigint;
|
|
26
|
+
readonly DeafenMembers: bigint;
|
|
27
|
+
readonly MoveMembers: bigint;
|
|
28
|
+
readonly UseVAD: bigint;
|
|
29
|
+
readonly ChangeNickname: bigint;
|
|
30
|
+
readonly ManageNicknames: bigint;
|
|
31
|
+
readonly ManageRoles: bigint;
|
|
32
|
+
readonly ManageWebhooks: bigint;
|
|
33
|
+
readonly ManageEmojisAndStickers: bigint;
|
|
34
|
+
readonly ManageGuildExpressions: bigint;
|
|
35
|
+
readonly UseApplicationCommands: bigint;
|
|
36
|
+
readonly RequestToSpeak: bigint;
|
|
37
|
+
readonly ManageEvents: bigint;
|
|
38
|
+
readonly ManageThreads: bigint;
|
|
39
|
+
readonly CreatePublicThreads: bigint;
|
|
40
|
+
readonly CreatePrivateThreads: bigint;
|
|
41
|
+
readonly UseExternalStickers: bigint;
|
|
42
|
+
readonly SendMessagesInThreads: bigint;
|
|
43
|
+
readonly UseEmbeddedActivities: bigint;
|
|
44
|
+
readonly ModerateMembers: bigint;
|
|
45
|
+
readonly ViewCreatorMonetizationAnalytics: bigint;
|
|
46
|
+
readonly UseSoundboard: bigint;
|
|
47
|
+
readonly CreateGuildExpressions: bigint;
|
|
48
|
+
readonly CreateEvents: bigint;
|
|
49
|
+
readonly UseExternalSounds: bigint;
|
|
50
|
+
readonly SendVoiceMessages: bigint;
|
|
51
|
+
readonly SetVoiceChannelStatus: bigint;
|
|
52
|
+
readonly SendPolls: bigint;
|
|
53
|
+
readonly UseExternalApps: bigint;
|
|
54
|
+
readonly PinMessages: bigint;
|
|
55
|
+
readonly BypassSlowmode: bigint;
|
|
56
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { APIApplicationRoleConnectionMetadata, Locale, RESTPutAPIApplicationRoleConnectionMetadataResult } from "discord-api-types/v10";
|
|
2
|
+
import type { RoleConnectionMetadataTypes } from "./RoleConnectionMetadataTypes.js";
|
|
3
|
+
export type DiscordLocale = `${Locale}`;
|
|
4
|
+
export type LocalizationMap = Partial<Record<DiscordLocale, string>>;
|
|
5
|
+
export type RoleConnectionMetadataInput = {
|
|
6
|
+
key: string;
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
type: RoleConnectionMetadataTypes;
|
|
10
|
+
name_localizations?: LocalizationMap;
|
|
11
|
+
description_localizations?: LocalizationMap;
|
|
12
|
+
};
|
|
13
|
+
export type RoleConnectionMetadata = APIApplicationRoleConnectionMetadata;
|
|
14
|
+
export type RegisterMetadataResult = RESTPutAPIApplicationRoleConnectionMetadataResult;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Enumerates available role connection metadata comparison types supported by Discord. */
|
|
2
|
+
export declare enum RoleConnectionMetadataTypes {
|
|
3
|
+
IntegerLessThanOrEqual = 1,
|
|
4
|
+
IntegerGreaterThanOrEqual = 2,
|
|
5
|
+
IntegerEqual = 3,
|
|
6
|
+
IntegerNotEqual = 4,
|
|
7
|
+
DateTimeLessThanOrEqual = 5,
|
|
8
|
+
DateTimeGreaterThanOrEqual = 6,
|
|
9
|
+
BooleanEqual = 7,
|
|
10
|
+
BooleanNotEqual = 8
|
|
11
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Enumerates available role connection metadata comparison types supported by Discord. */
|
|
2
|
+
export var RoleConnectionMetadataTypes;
|
|
3
|
+
(function (RoleConnectionMetadataTypes) {
|
|
4
|
+
RoleConnectionMetadataTypes[RoleConnectionMetadataTypes["IntegerLessThanOrEqual"] = 1] = "IntegerLessThanOrEqual";
|
|
5
|
+
RoleConnectionMetadataTypes[RoleConnectionMetadataTypes["IntegerGreaterThanOrEqual"] = 2] = "IntegerGreaterThanOrEqual";
|
|
6
|
+
RoleConnectionMetadataTypes[RoleConnectionMetadataTypes["IntegerEqual"] = 3] = "IntegerEqual";
|
|
7
|
+
RoleConnectionMetadataTypes[RoleConnectionMetadataTypes["IntegerNotEqual"] = 4] = "IntegerNotEqual";
|
|
8
|
+
RoleConnectionMetadataTypes[RoleConnectionMetadataTypes["DateTimeLessThanOrEqual"] = 5] = "DateTimeLessThanOrEqual";
|
|
9
|
+
RoleConnectionMetadataTypes[RoleConnectionMetadataTypes["DateTimeGreaterThanOrEqual"] = 6] = "DateTimeGreaterThanOrEqual";
|
|
10
|
+
RoleConnectionMetadataTypes[RoleConnectionMetadataTypes["BooleanEqual"] = 7] = "BooleanEqual";
|
|
11
|
+
RoleConnectionMetadataTypes[RoleConnectionMetadataTypes["BooleanNotEqual"] = 8] = "BooleanNotEqual";
|
|
12
|
+
})(RoleConnectionMetadataTypes || (RoleConnectionMetadataTypes = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import type { APICheckboxComponent, APICheckboxGroupComponent, APICheckboxGroupOption } from 'discord-api-types/v10';
|
|
3
|
+
/**
|
|
4
|
+
* Checkboxes are modal-only components.
|
|
5
|
+
* A single checkbox (type 23) holds no options; a checkbox group (type 22)
|
|
6
|
+
* holds up to 10 selectable options.
|
|
7
|
+
*
|
|
8
|
+
* @see {@link https://discord.com/developers/docs/components/reference#checkbox}
|
|
9
|
+
* @see {@link https://discord.com/developers/docs/components/reference#checkbox-group}
|
|
10
|
+
*/
|
|
11
|
+
export declare const CHECKBOX_COMPONENT_TYPE = ComponentType.Checkbox;
|
|
12
|
+
/** Type value for multi-select checkbox groups (type 22). */
|
|
13
|
+
export declare const CHECKBOX_GROUP_COMPONENT_TYPE = ComponentType.CheckboxGroup;
|
|
14
|
+
export type { APICheckboxComponent, APICheckboxGroupComponent, APICheckboxGroupOption };
|
|
15
|
+
/** Backwards-compatible alias: the options-array model belongs to checkbox groups. */
|
|
16
|
+
export type APICheckboxOption = APICheckboxGroupOption;
|