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,46 @@
|
|
|
1
|
+
import type { APIMessageComponentEmoji, APISelectMenuOption } from "discord-api-types/v10";
|
|
2
|
+
import type { JSONEncodable } from "./shared.js";
|
|
3
|
+
/** Shape describing initial string select menu option data accepted by the builder. */
|
|
4
|
+
export type StringSelectMenuOptionBuilderData = {
|
|
5
|
+
label?: string;
|
|
6
|
+
value?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
emoji?: string | APIMessageComponentEmoji;
|
|
9
|
+
default?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** Builder for Discord string select menu option components. */
|
|
12
|
+
export declare class StringSelectMenuOptionBuilder implements JSONEncodable<APISelectMenuOption> {
|
|
13
|
+
private data;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new string select menu option builder with optional seed data.
|
|
16
|
+
*/
|
|
17
|
+
constructor(data?: StringSelectMenuOptionBuilderData);
|
|
18
|
+
/**
|
|
19
|
+
* Sets the user-facing name of the option (max 100 characters).
|
|
20
|
+
*/
|
|
21
|
+
setLabel(label: string): this;
|
|
22
|
+
/**
|
|
23
|
+
* Sets the dev-defined value of the option (max 100 characters).
|
|
24
|
+
*/
|
|
25
|
+
setValue(value: string): this;
|
|
26
|
+
/**
|
|
27
|
+
* Sets an additional description of the option (max 100 characters).
|
|
28
|
+
*/
|
|
29
|
+
setDescription(description: string | null | undefined): this;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the emoji to display to the left of the option.
|
|
32
|
+
* Accepts:
|
|
33
|
+
* - Unicode emoji: "😀"
|
|
34
|
+
* - Custom emoji string: "<:name:id>" or "<a:name:id>"
|
|
35
|
+
* - Emoji object: { name: "😀" } or { name: "name", id: "id", animated: true }
|
|
36
|
+
*/
|
|
37
|
+
setEmoji(emoji: string | APIMessageComponentEmoji | null | undefined): this;
|
|
38
|
+
/**
|
|
39
|
+
* Sets whether this option should be already-selected by default.
|
|
40
|
+
*/
|
|
41
|
+
setDefault(isDefault: boolean): this;
|
|
42
|
+
/**
|
|
43
|
+
* Serialises the builder into an API compatible select menu option payload.
|
|
44
|
+
*/
|
|
45
|
+
toJSON(): APISelectMenuOption;
|
|
46
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses an emoji string into an APIMessageComponentEmoji object.
|
|
3
|
+
* Supports:
|
|
4
|
+
* - Unicode emojis: "😀"
|
|
5
|
+
* - Custom emojis: "<:name:id>" or "<a:name:id>"
|
|
6
|
+
* - Emoji objects: { name: "😀" } or { name: "name", id: "id" }
|
|
7
|
+
*/
|
|
8
|
+
function parseEmoji(emoji) {
|
|
9
|
+
if (typeof emoji === "object") {
|
|
10
|
+
return emoji;
|
|
11
|
+
}
|
|
12
|
+
// Check for custom emoji format: <:name:id> or <a:name:id>
|
|
13
|
+
const customEmojiMatch = emoji.match(/^<(a)?:([^:]+):(\d+)>$/);
|
|
14
|
+
if (customEmojiMatch) {
|
|
15
|
+
return {
|
|
16
|
+
name: customEmojiMatch[2],
|
|
17
|
+
id: customEmojiMatch[3],
|
|
18
|
+
animated: customEmojiMatch[1] === "a",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
// Treat as unicode emoji
|
|
22
|
+
return { name: emoji };
|
|
23
|
+
}
|
|
24
|
+
/** Builder for Discord string select menu option components. */
|
|
25
|
+
export class StringSelectMenuOptionBuilder {
|
|
26
|
+
data;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new string select menu option builder with optional seed data.
|
|
29
|
+
*/
|
|
30
|
+
constructor(data = {}) {
|
|
31
|
+
this.data = {
|
|
32
|
+
label: data.label,
|
|
33
|
+
value: data.value,
|
|
34
|
+
description: data.description,
|
|
35
|
+
emoji: data.emoji ? parseEmoji(data.emoji) : undefined,
|
|
36
|
+
default: data.default,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Sets the user-facing name of the option (max 100 characters).
|
|
41
|
+
*/
|
|
42
|
+
setLabel(label) {
|
|
43
|
+
this.data.label = label;
|
|
44
|
+
return this;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Sets the dev-defined value of the option (max 100 characters).
|
|
48
|
+
*/
|
|
49
|
+
setValue(value) {
|
|
50
|
+
this.data.value = value;
|
|
51
|
+
return this;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Sets an additional description of the option (max 100 characters).
|
|
55
|
+
*/
|
|
56
|
+
setDescription(description) {
|
|
57
|
+
this.data.description = description ?? undefined;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Sets the emoji to display to the left of the option.
|
|
62
|
+
* Accepts:
|
|
63
|
+
* - Unicode emoji: "😀"
|
|
64
|
+
* - Custom emoji string: "<:name:id>" or "<a:name:id>"
|
|
65
|
+
* - Emoji object: { name: "😀" } or { name: "name", id: "id", animated: true }
|
|
66
|
+
*/
|
|
67
|
+
setEmoji(emoji) {
|
|
68
|
+
this.data.emoji = emoji ? parseEmoji(emoji) : undefined;
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Sets whether this option should be already-selected by default.
|
|
73
|
+
*/
|
|
74
|
+
setDefault(isDefault) {
|
|
75
|
+
this.data.default = isDefault;
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Serialises the builder into an API compatible select menu option payload.
|
|
80
|
+
*/
|
|
81
|
+
toJSON() {
|
|
82
|
+
const { label, value } = this.data;
|
|
83
|
+
if (!label) {
|
|
84
|
+
throw new Error("[StringSelectMenuOptionBuilder] label is required.");
|
|
85
|
+
}
|
|
86
|
+
if (!value) {
|
|
87
|
+
throw new Error("[StringSelectMenuOptionBuilder] value is required.");
|
|
88
|
+
}
|
|
89
|
+
if (label.length > 100) {
|
|
90
|
+
throw new Error("[StringSelectMenuOptionBuilder] label must be 100 characters or less.");
|
|
91
|
+
}
|
|
92
|
+
if (value.length > 100) {
|
|
93
|
+
throw new Error("[StringSelectMenuOptionBuilder] value must be 100 characters or less.");
|
|
94
|
+
}
|
|
95
|
+
if (this.data.description && this.data.description.length > 100) {
|
|
96
|
+
throw new Error("[StringSelectMenuOptionBuilder] description must be 100 characters or less.");
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
label,
|
|
100
|
+
value,
|
|
101
|
+
description: this.data.description,
|
|
102
|
+
emoji: this.data.emoji ? { ...this.data.emoji } : undefined,
|
|
103
|
+
default: this.data.default,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TextInputStyle, type APITextInputComponent } from 'discord-api-types/v10';
|
|
2
|
+
import { type JSONEncodable } from './shared.js';
|
|
3
|
+
export type TextInputBuilderData = {
|
|
4
|
+
customId?: string;
|
|
5
|
+
style?: TextInputStyle;
|
|
6
|
+
minLength?: number;
|
|
7
|
+
maxLength?: number;
|
|
8
|
+
required?: boolean;
|
|
9
|
+
value?: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class TextInputBuilder implements JSONEncodable<APITextInputComponent> {
|
|
13
|
+
private readonly data;
|
|
14
|
+
constructor(data?: TextInputBuilderData);
|
|
15
|
+
setCustomId(customId: string): this;
|
|
16
|
+
setStyle(style: TextInputStyle): this;
|
|
17
|
+
setMinLength(minLength: number): this;
|
|
18
|
+
setMaxLength(maxLength: number): this;
|
|
19
|
+
setRequired(required: boolean): this;
|
|
20
|
+
setValue(value: string): this;
|
|
21
|
+
setPlaceholder(placeholder: string): this;
|
|
22
|
+
toJSON(): APITextInputComponent;
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ComponentType, TextInputStyle } from 'discord-api-types/v10';
|
|
2
|
+
import { assertDefined, assertRange, assertStringLength } from '../types/validation.js';
|
|
3
|
+
export class TextInputBuilder {
|
|
4
|
+
data;
|
|
5
|
+
constructor(data = {}) { this.data = { style: TextInputStyle.Short, ...data }; }
|
|
6
|
+
setCustomId(customId) { this.data.customId = customId; return this; }
|
|
7
|
+
setStyle(style) { this.data.style = style; return this; }
|
|
8
|
+
setMinLength(minLength) { this.data.minLength = minLength; return this; }
|
|
9
|
+
setMaxLength(maxLength) { this.data.maxLength = maxLength; return this; }
|
|
10
|
+
setRequired(required) { this.data.required = required; return this; }
|
|
11
|
+
setValue(value) { this.data.value = value; return this; }
|
|
12
|
+
setPlaceholder(placeholder) { this.data.placeholder = placeholder; return this; }
|
|
13
|
+
toJSON() {
|
|
14
|
+
const customId = assertDefined('TextInputBuilder', 'custom_id', this.data.customId);
|
|
15
|
+
assertStringLength('TextInputBuilder', 'custom_id', customId, 1, 100);
|
|
16
|
+
if (this.data.minLength !== undefined)
|
|
17
|
+
assertRange('TextInputBuilder', 'min_length', this.data.minLength, 0, 4000);
|
|
18
|
+
if (this.data.maxLength !== undefined)
|
|
19
|
+
assertRange('TextInputBuilder', 'max_length', this.data.maxLength, 1, 4000);
|
|
20
|
+
if (this.data.placeholder)
|
|
21
|
+
assertStringLength('TextInputBuilder', 'placeholder', this.data.placeholder, 1, 100);
|
|
22
|
+
if (this.data.value)
|
|
23
|
+
assertStringLength('TextInputBuilder', 'value', this.data.value, 0, 4000);
|
|
24
|
+
return { type: ComponentType.TextInput, custom_id: customId, style: this.data.style ?? TextInputStyle.Short, min_length: this.data.minLength, max_length: this.data.maxLength, required: this.data.required, value: this.data.value, placeholder: this.data.placeholder };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Re-exports component builders and shared types for convenience. */
|
|
2
|
+
export { ActionRowBuilder } from "./ActionRowBuilder.js";
|
|
3
|
+
export type { ActionRowComponentLike } from "./ActionRowBuilder.js";
|
|
4
|
+
export { ButtonBuilder } from "./ButtonBuilder.js";
|
|
5
|
+
export type { ButtonBuilderData } from "./ButtonBuilder.js";
|
|
6
|
+
export { StringSelectMenuBuilder } from "./StringSelectMenuBuilder.js";
|
|
7
|
+
export type { StringSelectMenuBuilderData } from "./StringSelectMenuBuilder.js";
|
|
8
|
+
export { StringSelectMenuOptionBuilder } from "./StringSelectMenuOptionBuilder.js";
|
|
9
|
+
export type { StringSelectMenuOptionBuilderData } from "./StringSelectMenuOptionBuilder.js";
|
|
10
|
+
export { RoleSelectMenuBuilder } from "./RoleSelectMenuBuilder.js";
|
|
11
|
+
export type { RoleSelectMenuBuilderData } from "./RoleSelectMenuBuilder.js";
|
|
12
|
+
export { ChannelSelectMenuBuilder } from "./ChannelSelectMenuBuilder.js";
|
|
13
|
+
export type { ChannelSelectMenuBuilderData } from "./ChannelSelectMenuBuilder.js";
|
|
14
|
+
export { ModalStringSelectMenuBuilder } from "./ModalStringSelectMenuBuilder.js";
|
|
15
|
+
export type { ModalStringSelectMenuBuilderData } from "./ModalStringSelectMenuBuilder.js";
|
|
16
|
+
export { ModalRoleSelectMenuBuilder } from "./ModalRoleSelectMenuBuilder.js";
|
|
17
|
+
export type { ModalRoleSelectMenuBuilderData } from "./ModalRoleSelectMenuBuilder.js";
|
|
18
|
+
export { ModalUserSelectMenuBuilder } from "./ModalUserSelectMenuBuilder.js";
|
|
19
|
+
export type { ModalUserSelectMenuBuilderData } from "./ModalUserSelectMenuBuilder.js";
|
|
20
|
+
export { ModalChannelSelectMenuBuilder } from "./ModalChannelSelectMenuBuilder.js";
|
|
21
|
+
export type { ModalChannelSelectMenuBuilderData } from "./ModalChannelSelectMenuBuilder.js";
|
|
22
|
+
export { ModalMentionableSelectMenuBuilder } from "./ModalMentionableSelectMenuBuilder.js";
|
|
23
|
+
export type { ModalMentionableSelectMenuBuilderData } from "./ModalMentionableSelectMenuBuilder.js";
|
|
24
|
+
export { ModalBuilder } from "./ModalBuilder.js";
|
|
25
|
+
export type { ModalBuilderData, ModalComponentLike } from "./ModalBuilder.js";
|
|
26
|
+
export { TextInputBuilder } from "./TextInputBuilder.js";
|
|
27
|
+
export type { TextInputBuilderData } from "./TextInputBuilder.js";
|
|
28
|
+
export { LabelBuilder } from "./LabelBuilder.js";
|
|
29
|
+
export type { LabelBuilderData, LabelComponentLike } from "./LabelBuilder.js";
|
|
30
|
+
export { FileUploadBuilder } from "./FileUploadBuilder.js";
|
|
31
|
+
export type { FileUploadBuilderData } from "./FileUploadBuilder.js";
|
|
32
|
+
export { AutomodRuleBuilder } from "./AutomodRuleBuilder.js";
|
|
33
|
+
export type { AutomodRuleBuilderData } from "./AutomodRuleBuilder.js";
|
|
34
|
+
export { EmbedBuilder } from "./EmbedBuilder.js";
|
|
35
|
+
export type { EmbedBuilderData } from "./EmbedBuilder.js";
|
|
36
|
+
export { ContainerBuilder, SectionBuilder, TextDisplayBuilder, SeparatorBuilder, GalleryBuilder, GalleryItemBuilder, ThumbnailBuilder, } from "./MiniContainerBuilder.js";
|
|
37
|
+
export type { ContainerBuilderData, SectionBuilderData, TextDisplayBuilderData, SeparatorBuilderData, GalleryBuilderData, GalleryItemBuilderData, ThumbnailBuilderData, MiniContainerComponent, MiniSectionComponent, MiniTextDisplayComponent, MiniSeparatorComponent, MiniGalleryComponent, MiniGalleryItemComponent, MiniThumbnailComponent, MiniContentComponent, MiniSectionAccessoryComponent, } from "./MiniContainerBuilder.js";
|
|
38
|
+
export type { JSONEncodable } from "./shared.js";
|
|
39
|
+
export { RadioBuilder } from "./RadioBuilder.js";
|
|
40
|
+
export type { RadioBuilderData } from "./RadioBuilder.js";
|
|
41
|
+
export { CheckboxBuilder } from "./CheckboxBuilder.js";
|
|
42
|
+
export type { CheckboxBuilderData } from "./CheckboxBuilder.js";
|
|
43
|
+
export { CheckboxGroupBuilder } from "./CheckboxGroupBuilder.js";
|
|
44
|
+
export type { CheckboxGroupBuilderData } from "./CheckboxGroupBuilder.js";
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Re-exports component builders and shared types for convenience. */
|
|
2
|
+
export { ActionRowBuilder } from "./ActionRowBuilder.js";
|
|
3
|
+
export { ButtonBuilder } from "./ButtonBuilder.js";
|
|
4
|
+
export { StringSelectMenuBuilder } from "./StringSelectMenuBuilder.js";
|
|
5
|
+
export { StringSelectMenuOptionBuilder } from "./StringSelectMenuOptionBuilder.js";
|
|
6
|
+
export { RoleSelectMenuBuilder } from "./RoleSelectMenuBuilder.js";
|
|
7
|
+
export { ChannelSelectMenuBuilder } from "./ChannelSelectMenuBuilder.js";
|
|
8
|
+
export { ModalStringSelectMenuBuilder } from "./ModalStringSelectMenuBuilder.js";
|
|
9
|
+
export { ModalRoleSelectMenuBuilder } from "./ModalRoleSelectMenuBuilder.js";
|
|
10
|
+
export { ModalUserSelectMenuBuilder } from "./ModalUserSelectMenuBuilder.js";
|
|
11
|
+
export { ModalChannelSelectMenuBuilder } from "./ModalChannelSelectMenuBuilder.js";
|
|
12
|
+
export { ModalMentionableSelectMenuBuilder } from "./ModalMentionableSelectMenuBuilder.js";
|
|
13
|
+
export { ModalBuilder } from "./ModalBuilder.js";
|
|
14
|
+
export { TextInputBuilder } from "./TextInputBuilder.js";
|
|
15
|
+
export { LabelBuilder } from "./LabelBuilder.js";
|
|
16
|
+
export { FileUploadBuilder } from "./FileUploadBuilder.js";
|
|
17
|
+
export { AutomodRuleBuilder } from "./AutomodRuleBuilder.js";
|
|
18
|
+
export { EmbedBuilder } from "./EmbedBuilder.js";
|
|
19
|
+
export { ContainerBuilder, SectionBuilder, TextDisplayBuilder, SeparatorBuilder, GalleryBuilder, GalleryItemBuilder, ThumbnailBuilder, } from "./MiniContainerBuilder.js";
|
|
20
|
+
export { RadioBuilder } from "./RadioBuilder.js";
|
|
21
|
+
export { CheckboxBuilder } from "./CheckboxBuilder.js";
|
|
22
|
+
export { CheckboxGroupBuilder } from "./CheckboxGroupBuilder.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Interface describing objects capable of encoding themselves as JSON payloads. */
|
|
2
|
+
export interface JSONEncodable<T> {
|
|
3
|
+
toJSON(): T;
|
|
4
|
+
}
|
|
5
|
+
/** Type guard that checks whether a value provides a `toJSON` method. */
|
|
6
|
+
export declare function isJSONEncodable<T>(value: JSONEncodable<T> | unknown): value is JSONEncodable<T>;
|
|
7
|
+
/** Normalises a value that might either be a JSON encodable object or plain payload. */
|
|
8
|
+
export declare function resolveJSONEncodable<T>(value: JSONEncodable<T> | T): T;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Type guard that checks whether a value provides a `toJSON` method. */
|
|
2
|
+
export function isJSONEncodable(value) {
|
|
3
|
+
return (typeof value === "object" &&
|
|
4
|
+
value !== null &&
|
|
5
|
+
"toJSON" in value &&
|
|
6
|
+
typeof value.toJSON === "function");
|
|
7
|
+
}
|
|
8
|
+
/** Normalises a value that might either be a JSON encodable object or plain payload. */
|
|
9
|
+
export function resolveJSONEncodable(value) {
|
|
10
|
+
return isJSONEncodable(value) ? value.toJSON() : value;
|
|
11
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { ChannelType, type APIApplicationCommandAttachmentOption, type APIApplicationCommandBasicOption, type APIApplicationCommandChannelOption, type APIApplicationCommandMentionableOption, type APIApplicationCommandNumberOption, type APIApplicationCommandOption, type APIApplicationCommandOptionChoice, type APIApplicationCommandRoleOption, type APIApplicationCommandStringOption, type APIApplicationCommandSubcommandGroupOption, type APIApplicationCommandSubcommandOption, type APIApplicationCommandUserOption, type LocalizationMap, type Permissions, type RESTPostAPIChatInputApplicationCommandsJSONBody } from "discord-api-types/v10";
|
|
2
|
+
/** Supported integration types for Discord application commands. */
|
|
3
|
+
export declare enum IntegrationType {
|
|
4
|
+
GuildInstall = 0,
|
|
5
|
+
UserInstall = 1
|
|
6
|
+
}
|
|
7
|
+
/** Supported contexts where a command can be invoked. */
|
|
8
|
+
export declare enum CommandContext {
|
|
9
|
+
Guild = 0,
|
|
10
|
+
Bot = 1,
|
|
11
|
+
DM = 2
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Provides shared builder utilities for application command option definitions.
|
|
15
|
+
*/
|
|
16
|
+
declare abstract class BaseOptionBuilder<Data extends APIApplicationCommandOption> {
|
|
17
|
+
protected readonly data: Data;
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new option builder wrapper around an underlying option payload.
|
|
20
|
+
*/
|
|
21
|
+
protected constructor(data: Data);
|
|
22
|
+
/**
|
|
23
|
+
* Sets the option name while validating Discord's requirements.
|
|
24
|
+
*/
|
|
25
|
+
setName(name: string): this;
|
|
26
|
+
/**
|
|
27
|
+
* Sets localized translations for the option name.
|
|
28
|
+
*/
|
|
29
|
+
setNameLocalizations(localizations: LocalizationMap | null): this;
|
|
30
|
+
/**
|
|
31
|
+
* Sets the option description while validating Discord's length requirements.
|
|
32
|
+
*/
|
|
33
|
+
setDescription(description: string): this;
|
|
34
|
+
/**
|
|
35
|
+
* Sets localized translations for the option description.
|
|
36
|
+
*/
|
|
37
|
+
setDescriptionLocalizations(localizations: LocalizationMap | null): this;
|
|
38
|
+
/**
|
|
39
|
+
* Produces a deep copy of the built option payload for safe reuse.
|
|
40
|
+
*/
|
|
41
|
+
toJSON(): Data;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Extends {@link BaseOptionBuilder} with helpers specific to basic command options.
|
|
45
|
+
*/
|
|
46
|
+
declare abstract class BaseCommandOptionBuilder<Data extends APIApplicationCommandBasicOption> extends BaseOptionBuilder<Data> {
|
|
47
|
+
/**
|
|
48
|
+
* Marks the option as required within its parent context.
|
|
49
|
+
*/
|
|
50
|
+
setRequired(required?: boolean): this;
|
|
51
|
+
}
|
|
52
|
+
/** Builder for attachment command options. */
|
|
53
|
+
declare class AttachmentOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandAttachmentOption> {
|
|
54
|
+
constructor();
|
|
55
|
+
}
|
|
56
|
+
/** Builder for user command options. */
|
|
57
|
+
declare class UserOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandUserOption> {
|
|
58
|
+
constructor();
|
|
59
|
+
}
|
|
60
|
+
/** Builder for role command options. */
|
|
61
|
+
declare class RoleOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandRoleOption> {
|
|
62
|
+
constructor();
|
|
63
|
+
}
|
|
64
|
+
/** Builder for mentionable command options. */
|
|
65
|
+
declare class MentionableOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandMentionableOption> {
|
|
66
|
+
constructor();
|
|
67
|
+
}
|
|
68
|
+
/** Builder for channel command options with channel type filtering support. */
|
|
69
|
+
declare class ChannelOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandChannelOption> {
|
|
70
|
+
constructor();
|
|
71
|
+
/**
|
|
72
|
+
* Limits selectable channels to the provided channel types.
|
|
73
|
+
*/
|
|
74
|
+
addChannelTypes(...channelTypes: ChannelType[]): this;
|
|
75
|
+
}
|
|
76
|
+
/** Builder for string command options, including choice and autocomplete support. */
|
|
77
|
+
declare class StringOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandStringOption> {
|
|
78
|
+
constructor();
|
|
79
|
+
/**
|
|
80
|
+
* Adds a single choice option for the string command option.
|
|
81
|
+
*/
|
|
82
|
+
addChoice(name: string, value: string): this;
|
|
83
|
+
/**
|
|
84
|
+
* Adds multiple choice entries for the string command option.
|
|
85
|
+
*/
|
|
86
|
+
addChoices(...choices: APIApplicationCommandOptionChoice<string>[]): this;
|
|
87
|
+
/**
|
|
88
|
+
* Replaces the existing choice set with the provided entries.
|
|
89
|
+
*/
|
|
90
|
+
setChoices(...choices: APIApplicationCommandOptionChoice<string>[]): this;
|
|
91
|
+
/**
|
|
92
|
+
* Enables or disables autocomplete for the string option.
|
|
93
|
+
*/
|
|
94
|
+
setAutocomplete(autocomplete?: boolean): this;
|
|
95
|
+
/**
|
|
96
|
+
* Sets the minimum string length accepted for the option value.
|
|
97
|
+
*/
|
|
98
|
+
setMinLength(minLength: number): this;
|
|
99
|
+
/**
|
|
100
|
+
* Sets the maximum string length accepted for the option value.
|
|
101
|
+
*/
|
|
102
|
+
setMaxLength(maxLength: number): this;
|
|
103
|
+
}
|
|
104
|
+
/** Builder for numeric command options with choice and range support. */
|
|
105
|
+
declare class NumberOptionBuilder extends BaseCommandOptionBuilder<APIApplicationCommandNumberOption> {
|
|
106
|
+
constructor();
|
|
107
|
+
/**
|
|
108
|
+
* Adds a single numeric choice for the option.
|
|
109
|
+
*/
|
|
110
|
+
addChoice(name: string, value: number): this;
|
|
111
|
+
/**
|
|
112
|
+
* Adds multiple numeric choice entries for the option.
|
|
113
|
+
*/
|
|
114
|
+
addChoices(...choices: APIApplicationCommandOptionChoice<number>[]): this;
|
|
115
|
+
/**
|
|
116
|
+
* Replaces the current choice set with the provided entries.
|
|
117
|
+
*/
|
|
118
|
+
setChoices(...choices: APIApplicationCommandOptionChoice<number>[]): this;
|
|
119
|
+
/**
|
|
120
|
+
* Enables or disables autocomplete for the numeric option.
|
|
121
|
+
*/
|
|
122
|
+
setAutocomplete(autocomplete?: boolean): this;
|
|
123
|
+
/**
|
|
124
|
+
* Sets the minimum numeric value allowed for the option.
|
|
125
|
+
*/
|
|
126
|
+
setMinValue(minValue: number): this;
|
|
127
|
+
/**
|
|
128
|
+
* Sets the maximum numeric value allowed for the option.
|
|
129
|
+
*/
|
|
130
|
+
setMaxValue(maxValue: number): this;
|
|
131
|
+
}
|
|
132
|
+
/** Callback type accepted by option builder helper methods for customization. */
|
|
133
|
+
type OptionBuilderCallback<Builder> = (builder: Builder) => Builder | void;
|
|
134
|
+
/** Builder used to compose individual slash command subcommands. */
|
|
135
|
+
declare class SubcommandBuilder extends BaseOptionBuilder<APIApplicationCommandSubcommandOption> {
|
|
136
|
+
constructor();
|
|
137
|
+
/**
|
|
138
|
+
* Ensures the subcommand does not exceed Discord's option limit.
|
|
139
|
+
*/
|
|
140
|
+
private assertOptionLimit;
|
|
141
|
+
/**
|
|
142
|
+
* Adds a string option configured through the supplied callback.
|
|
143
|
+
*/
|
|
144
|
+
addStringOption(callback: OptionBuilderCallback<StringOptionBuilder>): this;
|
|
145
|
+
/**
|
|
146
|
+
* Adds a number option configured through the supplied callback.
|
|
147
|
+
*/
|
|
148
|
+
addNumberOption(callback: OptionBuilderCallback<NumberOptionBuilder>): this;
|
|
149
|
+
/**
|
|
150
|
+
* Adds an attachment option configured through the supplied callback.
|
|
151
|
+
*/
|
|
152
|
+
addAttachmentOption(callback: OptionBuilderCallback<AttachmentOptionBuilder>): this;
|
|
153
|
+
/**
|
|
154
|
+
* Adds a user option configured through the supplied callback.
|
|
155
|
+
*/
|
|
156
|
+
addUserOption(callback: OptionBuilderCallback<UserOptionBuilder>): this;
|
|
157
|
+
/**
|
|
158
|
+
* Adds a role option configured through the supplied callback.
|
|
159
|
+
*/
|
|
160
|
+
addRoleOption(callback: OptionBuilderCallback<RoleOptionBuilder>): this;
|
|
161
|
+
/**
|
|
162
|
+
* Adds a mentionable option configured through the supplied callback.
|
|
163
|
+
*/
|
|
164
|
+
addMentionableOption(callback: OptionBuilderCallback<MentionableOptionBuilder>): this;
|
|
165
|
+
/**
|
|
166
|
+
* Adds a channel option configured through the supplied callback.
|
|
167
|
+
*/
|
|
168
|
+
addChannelOption(callback: OptionBuilderCallback<ChannelOptionBuilder>): this;
|
|
169
|
+
/**
|
|
170
|
+
* Produces a serialisable representation of the subcommand configuration.
|
|
171
|
+
*/
|
|
172
|
+
toJSON(): APIApplicationCommandSubcommandOption;
|
|
173
|
+
}
|
|
174
|
+
/** Builder used to compose groups of subcommands. */
|
|
175
|
+
declare class SubcommandGroupBuilder extends BaseOptionBuilder<APIApplicationCommandSubcommandGroupOption> {
|
|
176
|
+
constructor();
|
|
177
|
+
/**
|
|
178
|
+
* Ensures the group does not exceed Discord's subcommand limit.
|
|
179
|
+
*/
|
|
180
|
+
private assertSubcommandLimit;
|
|
181
|
+
/**
|
|
182
|
+
* Adds a subcommand configured through the supplied callback.
|
|
183
|
+
*/
|
|
184
|
+
addSubcommand(callback: OptionBuilderCallback<SubcommandBuilder>): this;
|
|
185
|
+
/**
|
|
186
|
+
* Produces a serialisable representation of the subcommand group configuration.
|
|
187
|
+
*/
|
|
188
|
+
toJSON(): APIApplicationCommandSubcommandGroupOption;
|
|
189
|
+
}
|
|
190
|
+
/** Fluent builder for constructing Discord chat input command payloads. */
|
|
191
|
+
export declare class CommandBuilder {
|
|
192
|
+
private readonly data;
|
|
193
|
+
/**
|
|
194
|
+
* Ensures the command does not exceed Discord's option limit.
|
|
195
|
+
*/
|
|
196
|
+
private assertOptionLimit;
|
|
197
|
+
/**
|
|
198
|
+
* Sets the command name while validating Discord's requirements.
|
|
199
|
+
*/
|
|
200
|
+
setName(name: string): this;
|
|
201
|
+
/**
|
|
202
|
+
* Sets localized translations for the command name.
|
|
203
|
+
*/
|
|
204
|
+
setNameLocalizations(localizations: LocalizationMap | null): this;
|
|
205
|
+
/**
|
|
206
|
+
* Sets the command description while enforcing Discord's length rules.
|
|
207
|
+
*/
|
|
208
|
+
setDescription(description: string): this;
|
|
209
|
+
/**
|
|
210
|
+
* Sets localized translations for the command description.
|
|
211
|
+
*/
|
|
212
|
+
setDescriptionLocalizations(localizations: LocalizationMap | null): this;
|
|
213
|
+
/**
|
|
214
|
+
* Configures the default member permissions required to use the command.
|
|
215
|
+
*/
|
|
216
|
+
setDefaultMemberPermissions(permissions: Permissions | bigint | number | string | null): this;
|
|
217
|
+
/**
|
|
218
|
+
* Sets whether the command is available in direct messages.
|
|
219
|
+
*/
|
|
220
|
+
setDMPermission(dmPermission: boolean): this;
|
|
221
|
+
/**
|
|
222
|
+
* Marks the command as not safe for work.
|
|
223
|
+
*/
|
|
224
|
+
setNSFW(nsfw: boolean): this;
|
|
225
|
+
/**
|
|
226
|
+
* Limits the contexts in which the command can appear.
|
|
227
|
+
*/
|
|
228
|
+
setContexts(contexts: CommandContext[] | null): this;
|
|
229
|
+
/**
|
|
230
|
+
* Specifies the integration types supported by the command.
|
|
231
|
+
*/
|
|
232
|
+
setIntegrationTypes(integrationTypes: IntegrationType[]): this;
|
|
233
|
+
/**
|
|
234
|
+
* Adds a subcommand to the command definition.
|
|
235
|
+
*/
|
|
236
|
+
addSubcommand(callback: OptionBuilderCallback<SubcommandBuilder>): this;
|
|
237
|
+
/**
|
|
238
|
+
* Adds a subcommand group to the command definition.
|
|
239
|
+
*/
|
|
240
|
+
addSubcommandGroup(callback: OptionBuilderCallback<SubcommandGroupBuilder>): this;
|
|
241
|
+
/**
|
|
242
|
+
* Adds a string option to the command definition.
|
|
243
|
+
*/
|
|
244
|
+
addStringOption(callback: OptionBuilderCallback<StringOptionBuilder>): this;
|
|
245
|
+
/**
|
|
246
|
+
* Adds a number option to the command definition.
|
|
247
|
+
*/
|
|
248
|
+
addNumberOption(callback: OptionBuilderCallback<NumberOptionBuilder>): this;
|
|
249
|
+
/**
|
|
250
|
+
* Adds an attachment option to the command definition.
|
|
251
|
+
*/
|
|
252
|
+
addAttachmentOption(callback: OptionBuilderCallback<AttachmentOptionBuilder>): this;
|
|
253
|
+
/**
|
|
254
|
+
* Adds a user option to the command definition.
|
|
255
|
+
*/
|
|
256
|
+
addUserOption(callback: OptionBuilderCallback<UserOptionBuilder>): this;
|
|
257
|
+
/**
|
|
258
|
+
* Adds a role option to the command definition.
|
|
259
|
+
*/
|
|
260
|
+
addRoleOption(callback: OptionBuilderCallback<RoleOptionBuilder>): this;
|
|
261
|
+
/**
|
|
262
|
+
* Adds a mentionable option to the command definition.
|
|
263
|
+
*/
|
|
264
|
+
addMentionableOption(callback: OptionBuilderCallback<MentionableOptionBuilder>): this;
|
|
265
|
+
/**
|
|
266
|
+
* Adds a channel option to the command definition.
|
|
267
|
+
*/
|
|
268
|
+
addChannelOption(callback: OptionBuilderCallback<ChannelOptionBuilder>): this;
|
|
269
|
+
/**
|
|
270
|
+
* Produces the final REST payload for the configured command.
|
|
271
|
+
*/
|
|
272
|
+
toJSON(): RESTPostAPIChatInputApplicationCommandsJSONBody;
|
|
273
|
+
/**
|
|
274
|
+
* Allows the builder to be coerced into its JSON payload automatically.
|
|
275
|
+
*/
|
|
276
|
+
valueOf(): RESTPostAPIChatInputApplicationCommandsJSONBody;
|
|
277
|
+
}
|
|
278
|
+
export type { AttachmentOptionBuilder, ChannelOptionBuilder, MentionableOptionBuilder, NumberOptionBuilder, RoleOptionBuilder, StringOptionBuilder, SubcommandBuilder, SubcommandGroupBuilder, UserOptionBuilder, };
|