@discordjs/builders 0.16.0 → 1.0.1-dev.1658330984-a05386a.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/CHANGELOG.md +6 -0
- package/README.md +4 -1
- package/dist/components/ActionRow.cjs +32 -0
- package/dist/components/ActionRow.cjs.map +1 -0
- package/dist/components/ActionRow.d.ts +35 -0
- package/dist/components/ActionRow.d.ts.map +1 -0
- package/dist/components/ActionRow.mjs +28 -0
- package/dist/components/ActionRow.mjs.map +1 -0
- package/dist/components/Assertions.cjs +75 -0
- package/dist/components/Assertions.cjs.map +1 -0
- package/dist/components/Assertions.d.ts +57 -0
- package/dist/components/Assertions.d.ts.map +1 -0
- package/dist/components/Assertions.mjs +56 -0
- package/dist/components/Assertions.mjs.map +1 -0
- package/dist/components/Component.cjs +12 -0
- package/dist/components/Component.cjs.map +1 -0
- package/dist/components/Component.d.ts +15 -0
- package/dist/components/Component.d.ts.map +1 -0
- package/dist/components/Component.mjs +8 -0
- package/dist/components/Component.mjs.map +1 -0
- package/dist/components/Components.cjs +31 -0
- package/dist/components/Components.cjs.map +1 -0
- package/dist/components/Components.d.ts +21 -0
- package/dist/components/Components.d.ts.map +1 -0
- package/dist/components/Components.mjs +27 -0
- package/dist/components/Components.mjs.map +1 -0
- package/dist/components/button/Button.cjs +46 -0
- package/dist/components/button/Button.cjs.map +1 -0
- package/dist/components/button/Button.d.ts +46 -0
- package/dist/components/button/Button.d.ts.map +1 -0
- package/dist/components/button/Button.mjs +42 -0
- package/dist/components/button/Button.mjs.map +1 -0
- package/dist/components/selectMenu/SelectMenu.cjs +59 -0
- package/dist/components/selectMenu/SelectMenu.cjs.map +1 -0
- package/dist/components/selectMenu/SelectMenu.d.ts +59 -0
- package/dist/components/selectMenu/SelectMenu.d.ts.map +1 -0
- package/dist/components/selectMenu/SelectMenu.mjs +55 -0
- package/dist/components/selectMenu/SelectMenu.mjs.map +1 -0
- package/dist/components/selectMenu/SelectMenuOption.cjs +40 -0
- package/dist/components/selectMenu/SelectMenuOption.cjs.map +1 -0
- package/dist/components/selectMenu/SelectMenuOption.d.ts +40 -0
- package/dist/components/selectMenu/SelectMenuOption.d.ts.map +1 -0
- package/dist/components/selectMenu/SelectMenuOption.mjs +36 -0
- package/dist/components/selectMenu/SelectMenuOption.mjs.map +1 -0
- package/dist/components/textInput/Assertions.cjs +31 -0
- package/dist/components/textInput/Assertions.cjs.map +1 -0
- package/dist/components/textInput/Assertions.d.ts +10 -0
- package/dist/components/textInput/Assertions.d.ts.map +1 -0
- package/dist/components/textInput/Assertions.mjs +20 -0
- package/dist/components/textInput/Assertions.mjs.map +1 -0
- package/dist/components/textInput/TextInput.cjs +67 -0
- package/dist/components/textInput/TextInput.cjs.map +1 -0
- package/dist/components/textInput/TextInput.d.ts +59 -0
- package/dist/components/textInput/TextInput.d.ts.map +1 -0
- package/dist/components/textInput/TextInput.mjs +59 -0
- package/dist/components/textInput/TextInput.mjs.map +1 -0
- package/dist/index.cjs +127 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +40 -1406
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +46 -1482
- package/dist/index.mjs.map +1 -1
- package/dist/interactions/contextMenuCommands/Assertions.cjs +40 -0
- package/dist/interactions/contextMenuCommands/Assertions.cjs.map +1 -0
- package/dist/interactions/contextMenuCommands/Assertions.d.ts +8 -0
- package/dist/interactions/contextMenuCommands/Assertions.d.ts.map +1 -0
- package/dist/interactions/contextMenuCommands/Assertions.mjs +31 -0
- package/dist/interactions/contextMenuCommands/Assertions.mjs.map +1 -0
- package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.cjs +71 -0
- package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.cjs.map +1 -0
- package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.d.ts +94 -0
- package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.d.ts.map +1 -0
- package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.mjs +67 -0
- package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.mjs.map +1 -0
- package/dist/interactions/modals/Assertions.cjs +21 -0
- package/dist/interactions/modals/Assertions.cjs.map +1 -0
- package/dist/interactions/modals/Assertions.d.ts +5 -0
- package/dist/interactions/modals/Assertions.d.ts.map +1 -0
- package/dist/interactions/modals/Assertions.mjs +15 -0
- package/dist/interactions/modals/Assertions.mjs.map +1 -0
- package/dist/interactions/modals/Modal.cjs +43 -0
- package/dist/interactions/modals/Modal.cjs.map +1 -0
- package/dist/interactions/modals/Modal.d.ts +35 -0
- package/dist/interactions/modals/Modal.d.ts.map +1 -0
- package/dist/interactions/modals/Modal.mjs +39 -0
- package/dist/interactions/modals/Modal.mjs.map +1 -0
- package/dist/interactions/slashCommands/Assertions.cjs +70 -0
- package/dist/interactions/slashCommands/Assertions.cjs.map +1 -0
- package/dist/interactions/slashCommands/Assertions.d.ts +18 -0
- package/dist/interactions/slashCommands/Assertions.d.ts.map +1 -0
- package/dist/interactions/slashCommands/Assertions.mjs +54 -0
- package/dist/interactions/slashCommands/Assertions.mjs.map +1 -0
- package/dist/interactions/slashCommands/SlashCommandBuilder.cjs +75 -0
- package/dist/interactions/slashCommands/SlashCommandBuilder.cjs.map +1 -0
- package/dist/interactions/slashCommands/SlashCommandBuilder.d.ts +100 -0
- package/dist/interactions/slashCommands/SlashCommandBuilder.d.ts.map +1 -0
- package/dist/interactions/slashCommands/SlashCommandBuilder.mjs +73 -0
- package/dist/interactions/slashCommands/SlashCommandBuilder.mjs.map +1 -0
- package/dist/interactions/slashCommands/SlashCommandSubcommands.cjs +72 -0
- package/dist/interactions/slashCommands/SlashCommandSubcommands.cjs.map +1 -0
- package/dist/interactions/slashCommands/SlashCommandSubcommands.d.ts +56 -0
- package/dist/interactions/slashCommands/SlashCommandSubcommands.d.ts.map +1 -0
- package/dist/interactions/slashCommands/SlashCommandSubcommands.mjs +70 -0
- package/dist/interactions/slashCommands/SlashCommandSubcommands.mjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.cjs +9 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.cjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.d.ts +17 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.d.ts.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.mjs +5 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.mjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.cjs +27 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.cjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.d.ts +15 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.d.ts.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.mjs +23 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionBase.mjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.cjs +30 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.cjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.d.ts +14 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.d.ts.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.mjs +26 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.mjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.cjs +57 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.cjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.d.ts +19 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.d.ts.map +1 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.mjs +53 -0
- package/dist/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.mjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/NameAndDescription.cjs +65 -0
- package/dist/interactions/slashCommands/mixins/NameAndDescription.cjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/NameAndDescription.d.ts +46 -0
- package/dist/interactions/slashCommands/mixins/NameAndDescription.d.ts.map +1 -0
- package/dist/interactions/slashCommands/mixins/NameAndDescription.mjs +61 -0
- package/dist/interactions/slashCommands/mixins/NameAndDescription.mjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.cjs +55 -0
- package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.cjs.map +1 -0
- package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.d.ts +69 -0
- package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.d.ts.map +1 -0
- package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.mjs +51 -0
- package/dist/interactions/slashCommands/mixins/SharedSlashCommandOptions.mjs.map +1 -0
- package/dist/interactions/slashCommands/options/attachment.cjs +20 -0
- package/dist/interactions/slashCommands/options/attachment.cjs.map +1 -0
- package/dist/interactions/slashCommands/options/attachment.d.ts +7 -0
- package/dist/interactions/slashCommands/options/attachment.d.ts.map +1 -0
- package/dist/interactions/slashCommands/options/attachment.mjs +16 -0
- package/dist/interactions/slashCommands/options/attachment.mjs.map +1 -0
- package/dist/interactions/slashCommands/options/boolean.cjs +20 -0
- package/dist/interactions/slashCommands/options/boolean.cjs.map +1 -0
- package/dist/interactions/slashCommands/options/boolean.d.ts +7 -0
- package/dist/interactions/slashCommands/options/boolean.d.ts.map +1 -0
- package/dist/interactions/slashCommands/options/boolean.mjs +16 -0
- package/dist/interactions/slashCommands/options/boolean.mjs.map +1 -0
- package/dist/interactions/slashCommands/options/channel.cjs +34 -0
- package/dist/interactions/slashCommands/options/channel.cjs.map +1 -0
- package/dist/interactions/slashCommands/options/channel.d.ts +10 -0
- package/dist/interactions/slashCommands/options/channel.d.ts.map +1 -0
- package/dist/interactions/slashCommands/options/channel.mjs +32 -0
- package/dist/interactions/slashCommands/options/channel.mjs.map +1 -0
- package/dist/interactions/slashCommands/options/integer.cjs +50 -0
- package/dist/interactions/slashCommands/options/integer.cjs.map +1 -0
- package/dist/interactions/slashCommands/options/integer.d.ts +13 -0
- package/dist/interactions/slashCommands/options/integer.d.ts.map +1 -0
- package/dist/interactions/slashCommands/options/integer.mjs +48 -0
- package/dist/interactions/slashCommands/options/integer.mjs.map +1 -0
- package/dist/interactions/slashCommands/options/mentionable.cjs +20 -0
- package/dist/interactions/slashCommands/options/mentionable.cjs.map +1 -0
- package/dist/interactions/slashCommands/options/mentionable.d.ts +7 -0
- package/dist/interactions/slashCommands/options/mentionable.d.ts.map +1 -0
- package/dist/interactions/slashCommands/options/mentionable.mjs +16 -0
- package/dist/interactions/slashCommands/options/mentionable.mjs.map +1 -0
- package/dist/interactions/slashCommands/options/number.cjs +50 -0
- package/dist/interactions/slashCommands/options/number.cjs.map +1 -0
- package/dist/interactions/slashCommands/options/number.d.ts +13 -0
- package/dist/interactions/slashCommands/options/number.d.ts.map +1 -0
- package/dist/interactions/slashCommands/options/number.mjs +48 -0
- package/dist/interactions/slashCommands/options/number.mjs.map +1 -0
- package/dist/interactions/slashCommands/options/role.cjs +20 -0
- package/dist/interactions/slashCommands/options/role.cjs.map +1 -0
- package/dist/interactions/slashCommands/options/role.d.ts +7 -0
- package/dist/interactions/slashCommands/options/role.d.ts.map +1 -0
- package/dist/interactions/slashCommands/options/role.mjs +16 -0
- package/dist/interactions/slashCommands/options/role.mjs.map +1 -0
- package/dist/interactions/slashCommands/options/string.cjs +50 -0
- package/dist/interactions/slashCommands/options/string.cjs.map +1 -0
- package/dist/interactions/slashCommands/options/string.d.ts +24 -0
- package/dist/interactions/slashCommands/options/string.d.ts.map +1 -0
- package/dist/interactions/slashCommands/options/string.mjs +48 -0
- package/dist/interactions/slashCommands/options/string.mjs.map +1 -0
- package/dist/interactions/slashCommands/options/user.cjs +20 -0
- package/dist/interactions/slashCommands/options/user.cjs.map +1 -0
- package/dist/interactions/slashCommands/options/user.d.ts +7 -0
- package/dist/interactions/slashCommands/options/user.d.ts.map +1 -0
- package/dist/interactions/slashCommands/options/user.mjs +16 -0
- package/dist/interactions/slashCommands/options/user.mjs.map +1 -0
- package/dist/messages/embed/Assertions.cjs +62 -0
- package/dist/messages/embed/Assertions.cjs.map +1 -0
- package/dist/messages/embed/Assertions.d.ts +50 -0
- package/dist/messages/embed/Assertions.d.ts.map +1 -0
- package/dist/messages/embed/Assertions.mjs +41 -0
- package/dist/messages/embed/Assertions.mjs.map +1 -0
- package/dist/messages/embed/Embed.cjs +101 -0
- package/dist/messages/embed/Embed.cjs.map +1 -0
- package/dist/messages/embed/Embed.d.ts +108 -0
- package/dist/messages/embed/Embed.d.ts.map +1 -0
- package/dist/messages/embed/Embed.mjs +97 -0
- package/dist/messages/embed/Embed.mjs.map +1 -0
- package/dist/messages/formatters.cjs +92 -0
- package/dist/messages/formatters.cjs.map +1 -0
- package/dist/messages/formatters.d.ts +218 -0
- package/dist/messages/formatters.d.ts.map +1 -0
- package/dist/messages/formatters.mjs +71 -0
- package/dist/messages/formatters.mjs.map +1 -0
- package/dist/util/componentUtil.cjs +10 -0
- package/dist/util/componentUtil.cjs.map +1 -0
- package/dist/util/componentUtil.d.ts +3 -0
- package/dist/util/componentUtil.d.ts.map +1 -0
- package/dist/util/componentUtil.mjs +6 -0
- package/dist/util/componentUtil.mjs.map +1 -0
- package/dist/util/equatable.cjs +10 -0
- package/dist/util/equatable.cjs.map +1 -0
- package/dist/util/equatable.d.ts +12 -0
- package/dist/util/equatable.d.ts.map +1 -0
- package/dist/util/equatable.mjs +6 -0
- package/dist/util/equatable.mjs.map +1 -0
- package/dist/util/jsonEncodable.cjs +10 -0
- package/dist/util/jsonEncodable.cjs.map +1 -0
- package/dist/util/jsonEncodable.d.ts +12 -0
- package/dist/util/jsonEncodable.d.ts.map +1 -0
- package/dist/util/jsonEncodable.mjs +6 -0
- package/dist/util/jsonEncodable.mjs.map +1 -0
- package/dist/util/normalizeArray.cjs +12 -0
- package/dist/util/normalizeArray.cjs.map +1 -0
- package/dist/util/normalizeArray.d.ts +3 -0
- package/dist/util/normalizeArray.d.ts.map +1 -0
- package/dist/util/normalizeArray.mjs +8 -0
- package/dist/util/normalizeArray.mjs.map +1 -0
- package/dist/util/validation.cjs +13 -0
- package/dist/util/validation.cjs.map +1 -0
- package/dist/util/validation.d.ts +4 -0
- package/dist/util/validation.d.ts.map +1 -0
- package/dist/util/validation.mjs +7 -0
- package/dist/util/validation.mjs.map +1 -0
- package/package.json +11 -8
- package/dist/index.js +0 -1557
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ButtonStyle, type APIMessageComponentEmoji, type APIButtonComponent } from 'discord-api-types/v10';
|
|
2
|
+
import { ComponentBuilder } from '../Component';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a button component
|
|
5
|
+
*/
|
|
6
|
+
export declare class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
|
7
|
+
constructor(data?: Partial<APIButtonComponent>);
|
|
8
|
+
/**
|
|
9
|
+
* Sets the style of this button
|
|
10
|
+
*
|
|
11
|
+
* @param style - The style of the button
|
|
12
|
+
*/
|
|
13
|
+
setStyle(style: ButtonStyle): this;
|
|
14
|
+
/**
|
|
15
|
+
* Sets the URL for this button
|
|
16
|
+
*
|
|
17
|
+
* @param url - The URL to open when this button is clicked
|
|
18
|
+
*/
|
|
19
|
+
setURL(url: string): this;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the custom id for this button
|
|
22
|
+
*
|
|
23
|
+
* @param customId - The custom id to use for this button
|
|
24
|
+
*/
|
|
25
|
+
setCustomId(customId: string): this;
|
|
26
|
+
/**
|
|
27
|
+
* Sets the emoji to display on this button
|
|
28
|
+
*
|
|
29
|
+
* @param emoji - The emoji to display on this button
|
|
30
|
+
*/
|
|
31
|
+
setEmoji(emoji: APIMessageComponentEmoji): this;
|
|
32
|
+
/**
|
|
33
|
+
* Sets whether this button is disabled
|
|
34
|
+
*
|
|
35
|
+
* @param disabled - Whether to disable this button
|
|
36
|
+
*/
|
|
37
|
+
setDisabled(disabled?: boolean): this;
|
|
38
|
+
/**
|
|
39
|
+
* Sets the label for this button
|
|
40
|
+
*
|
|
41
|
+
* @param label - The label to display on this button
|
|
42
|
+
*/
|
|
43
|
+
setLabel(label: string): this;
|
|
44
|
+
toJSON(): APIButtonComponent;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=Button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.d.ts","sourceRoot":"","sources":["../../../src/components/button/Button.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,WAAW,EACX,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EAGvB,MAAM,uBAAuB,CAAC;AAU/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;GAEG;AACH,qBAAa,aAAc,SAAQ,gBAAgB,CAAC,kBAAkB,CAAC;gBACnD,IAAI,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAIrD;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,WAAW;IAKlC;;;;OAIG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM;IAKzB;;;;OAIG;IACI,WAAW,CAAC,QAAQ,EAAE,MAAM;IAKnC;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,wBAAwB;IAK/C;;;;OAIG;IACI,WAAW,CAAC,QAAQ,UAAO;IAKlC;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM;IAKtB,MAAM,IAAI,kBAAkB;CAanC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import { buttonStyleValidator, urlValidator, customIdValidator, emojiValidator, disabledValidator, buttonLabelValidator, validateRequiredButtonParameters } from '../Assertions.mjs';
|
|
3
|
+
import { ComponentBuilder } from '../Component.mjs';
|
|
4
|
+
|
|
5
|
+
class ButtonBuilder extends ComponentBuilder {
|
|
6
|
+
constructor(data) {
|
|
7
|
+
super({ type: ComponentType.Button, ...data });
|
|
8
|
+
}
|
|
9
|
+
setStyle(style) {
|
|
10
|
+
this.data.style = buttonStyleValidator.parse(style);
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
setURL(url) {
|
|
14
|
+
this.data.url = urlValidator.parse(url);
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
setCustomId(customId) {
|
|
18
|
+
this.data.custom_id = customIdValidator.parse(customId);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
setEmoji(emoji) {
|
|
22
|
+
this.data.emoji = emojiValidator.parse(emoji);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
setDisabled(disabled = true) {
|
|
26
|
+
this.data.disabled = disabledValidator.parse(disabled);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
setLabel(label) {
|
|
30
|
+
this.data.label = buttonLabelValidator.parse(label);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
toJSON() {
|
|
34
|
+
validateRequiredButtonParameters(this.data.style, this.data.label, this.data.emoji, this.data.custom_id, this.data.url);
|
|
35
|
+
return {
|
|
36
|
+
...this.data
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export { ButtonBuilder };
|
|
42
|
+
//# sourceMappingURL=Button.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.mjs","sources":["../../../src/components/button/Button.ts"],"sourcesContent":["import {\n\tComponentType,\n\tButtonStyle,\n\ttype APIMessageComponentEmoji,\n\ttype APIButtonComponent,\n\ttype APIButtonComponentWithURL,\n\ttype APIButtonComponentWithCustomId,\n} from 'discord-api-types/v10';\nimport {\n\tbuttonLabelValidator,\n\tbuttonStyleValidator,\n\tcustomIdValidator,\n\tdisabledValidator,\n\temojiValidator,\n\turlValidator,\n\tvalidateRequiredButtonParameters,\n} from '../Assertions';\nimport { ComponentBuilder } from '../Component';\n\n/**\n * Represents a button component\n */\nexport class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {\n\tpublic constructor(data?: Partial<APIButtonComponent>) {\n\t\tsuper({ type: ComponentType.Button, ...data });\n\t}\n\n\t/**\n\t * Sets the style of this button\n\t *\n\t * @param style - The style of the button\n\t */\n\tpublic setStyle(style: ButtonStyle) {\n\t\tthis.data.style = buttonStyleValidator.parse(style);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL for this button\n\t *\n\t * @param url - The URL to open when this button is clicked\n\t */\n\tpublic setURL(url: string) {\n\t\t(this.data as APIButtonComponentWithURL).url = urlValidator.parse(url);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id for this button\n\t *\n\t * @param customId - The custom id to use for this button\n\t */\n\tpublic setCustomId(customId: string) {\n\t\t(this.data as APIButtonComponentWithCustomId).custom_id = customIdValidator.parse(customId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the emoji to display on this button\n\t *\n\t * @param emoji - The emoji to display on this button\n\t */\n\tpublic setEmoji(emoji: APIMessageComponentEmoji) {\n\t\tthis.data.emoji = emojiValidator.parse(emoji);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether this button is disabled\n\t *\n\t * @param disabled - Whether to disable this button\n\t */\n\tpublic setDisabled(disabled = true) {\n\t\tthis.data.disabled = disabledValidator.parse(disabled);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the label for this button\n\t *\n\t * @param label - The label to display on this button\n\t */\n\tpublic setLabel(label: string) {\n\t\tthis.data.label = buttonLabelValidator.parse(label);\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIButtonComponent {\n\t\tvalidateRequiredButtonParameters(\n\t\t\tthis.data.style,\n\t\t\tthis.data.label,\n\t\t\tthis.data.emoji,\n\t\t\t(this.data as APIButtonComponentWithCustomId).custom_id,\n\t\t\t(this.data as APIButtonComponentWithURL).url,\n\t\t);\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\treturn {\n\t\t\t...this.data,\n\t\t} as APIButtonComponent;\n\t}\n}\n"],"names":[],"mappings":";;;;AAaO,MAAM,aAAa,SAAS,gBAAgB,CAAC;AACpD,EAAE,WAAW,CAAC,IAAI,EAAE;AACpB,IAAI,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AACnD,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACxD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,CAAC,GAAG,EAAE;AACd,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5C,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,WAAW,CAAC,QAAQ,EAAE;AACxB,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC5D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,WAAW,CAAC,QAAQ,GAAG,IAAI,EAAE;AAC/B,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC3D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACxD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,gCAAgC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5H,IAAI,OAAO;AACX,MAAM,GAAG,IAAI,CAAC,IAAI;AAClB,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const v10 = require('discord-api-types/v10');
|
|
6
|
+
const SelectMenuOption = require('./SelectMenuOption.cjs');
|
|
7
|
+
const normalizeArray = require('../../util/normalizeArray.cjs');
|
|
8
|
+
const Assertions = require('../Assertions.cjs');
|
|
9
|
+
const Component = require('../Component.cjs');
|
|
10
|
+
|
|
11
|
+
class SelectMenuBuilder extends Component.ComponentBuilder {
|
|
12
|
+
constructor(data) {
|
|
13
|
+
const { options, ...initData } = data ?? {};
|
|
14
|
+
super({ type: v10.ComponentType.SelectMenu, ...initData });
|
|
15
|
+
this.options = options?.map((o) => new SelectMenuOption.SelectMenuOptionBuilder(o)) ?? [];
|
|
16
|
+
}
|
|
17
|
+
setPlaceholder(placeholder) {
|
|
18
|
+
this.data.placeholder = Assertions.placeholderValidator.parse(placeholder);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
setMinValues(minValues) {
|
|
22
|
+
this.data.min_values = Assertions.minMaxValidator.parse(minValues);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
setMaxValues(maxValues) {
|
|
26
|
+
this.data.max_values = Assertions.minMaxValidator.parse(maxValues);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
setCustomId(customId) {
|
|
30
|
+
this.data.custom_id = Assertions.customIdValidator.parse(customId);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
setDisabled(disabled = true) {
|
|
34
|
+
this.data.disabled = Assertions.disabledValidator.parse(disabled);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
addOptions(...options) {
|
|
38
|
+
options = normalizeArray.normalizeArray(options);
|
|
39
|
+
Assertions.optionsLengthValidator.parse(this.options.length + options.length);
|
|
40
|
+
this.options.push(...options.map((option) => option instanceof SelectMenuOption.SelectMenuOptionBuilder ? option : new SelectMenuOption.SelectMenuOptionBuilder(Assertions.optionValidator.parse(option))));
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
setOptions(...options) {
|
|
44
|
+
options = normalizeArray.normalizeArray(options);
|
|
45
|
+
Assertions.optionsLengthValidator.parse(options.length);
|
|
46
|
+
this.options.splice(0, this.options.length, ...options.map((option) => option instanceof SelectMenuOption.SelectMenuOptionBuilder ? option : new SelectMenuOption.SelectMenuOptionBuilder(Assertions.optionValidator.parse(option))));
|
|
47
|
+
return this;
|
|
48
|
+
}
|
|
49
|
+
toJSON() {
|
|
50
|
+
Assertions.validateRequiredSelectMenuParameters(this.options, this.data.custom_id);
|
|
51
|
+
return {
|
|
52
|
+
...this.data,
|
|
53
|
+
options: this.options.map((o) => o.toJSON())
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
exports.SelectMenuBuilder = SelectMenuBuilder;
|
|
59
|
+
//# sourceMappingURL=SelectMenu.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectMenu.cjs","sources":["../../../src/components/selectMenu/SelectMenu.ts"],"sourcesContent":["import { APISelectMenuOption, ComponentType, type APISelectMenuComponent } from 'discord-api-types/v10';\nimport { SelectMenuOptionBuilder } from './SelectMenuOption';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\nimport {\n\tcustomIdValidator,\n\tdisabledValidator,\n\tminMaxValidator,\n\toptionsLengthValidator,\n\toptionValidator,\n\tplaceholderValidator,\n\tvalidateRequiredSelectMenuParameters,\n} from '../Assertions';\nimport { ComponentBuilder } from '../Component';\n\n/**\n * Represents a select menu component\n */\nexport class SelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent> {\n\t/**\n\t * The options within this select menu\n\t */\n\tpublic readonly options: SelectMenuOptionBuilder[];\n\n\tpublic constructor(data?: Partial<APISelectMenuComponent>) {\n\t\tconst { options, ...initData } = data ?? {};\n\t\tsuper({ type: ComponentType.SelectMenu, ...initData });\n\t\tthis.options = options?.map((o) => new SelectMenuOptionBuilder(o)) ?? [];\n\t}\n\n\t/**\n\t * Sets the placeholder for this select menu\n\t *\n\t * @param placeholder - The placeholder to use for this select menu\n\t */\n\tpublic setPlaceholder(placeholder: string) {\n\t\tthis.data.placeholder = placeholderValidator.parse(placeholder);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the minimum values that must be selected in the select menu\n\t *\n\t * @param minValues - The minimum values that must be selected\n\t */\n\tpublic setMinValues(minValues: number) {\n\t\tthis.data.min_values = minMaxValidator.parse(minValues);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum values that must be selected in the select menu\n\t *\n\t * @param maxValues - The maximum values that must be selected\n\t */\n\tpublic setMaxValues(maxValues: number) {\n\t\tthis.data.max_values = minMaxValidator.parse(maxValues);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id for this select menu\n\t *\n\t * @param customId - The custom id to use for this select menu\n\t */\n\tpublic setCustomId(customId: string) {\n\t\tthis.data.custom_id = customIdValidator.parse(customId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether this select menu is disabled\n\t *\n\t * @param disabled - Whether this select menu is disabled\n\t */\n\tpublic setDisabled(disabled = true) {\n\t\tthis.data.disabled = disabledValidator.parse(disabled);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds options to this select menu\n\t *\n\t * @param options - The options to add to this select menu\n\t * @returns\n\t */\n\tpublic addOptions(...options: RestOrArray<SelectMenuOptionBuilder | APISelectMenuOption>) {\n\t\toptions = normalizeArray(options);\n\t\toptionsLengthValidator.parse(this.options.length + options.length);\n\t\tthis.options.push(\n\t\t\t...options.map((option) =>\n\t\t\t\toption instanceof SelectMenuOptionBuilder\n\t\t\t\t\t? option\n\t\t\t\t\t: new SelectMenuOptionBuilder(optionValidator.parse<APISelectMenuOption>(option)),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the options on this select menu\n\t *\n\t * @param options - The options to set on this select menu\n\t */\n\tpublic setOptions(...options: RestOrArray<SelectMenuOptionBuilder | APISelectMenuOption>) {\n\t\toptions = normalizeArray(options);\n\t\toptionsLengthValidator.parse(options.length);\n\t\tthis.options.splice(\n\t\t\t0,\n\t\t\tthis.options.length,\n\t\t\t...options.map((option) =>\n\t\t\t\toption instanceof SelectMenuOptionBuilder\n\t\t\t\t\t? option\n\t\t\t\t\t: new SelectMenuOptionBuilder(optionValidator.parse<APISelectMenuOption>(option)),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APISelectMenuComponent {\n\t\tvalidateRequiredSelectMenuParameters(this.options, this.data.custom_id);\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\treturn {\n\t\t\t...this.data,\n\t\t\toptions: this.options.map((o) => o.toJSON()),\n\t\t} as APISelectMenuComponent;\n\t}\n}\n"],"names":["ComponentBuilder","ComponentType","SelectMenuOptionBuilder","placeholderValidator","minMaxValidator","customIdValidator","disabledValidator","normalizeArray","optionsLengthValidator","optionValidator","validateRequiredSelectMenuParameters"],"mappings":"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"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { APISelectMenuOption, type APISelectMenuComponent } from 'discord-api-types/v10';
|
|
2
|
+
import { SelectMenuOptionBuilder } from './SelectMenuOption';
|
|
3
|
+
import { type RestOrArray } from '../../util/normalizeArray';
|
|
4
|
+
import { ComponentBuilder } from '../Component';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a select menu component
|
|
7
|
+
*/
|
|
8
|
+
export declare class SelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent> {
|
|
9
|
+
/**
|
|
10
|
+
* The options within this select menu
|
|
11
|
+
*/
|
|
12
|
+
readonly options: SelectMenuOptionBuilder[];
|
|
13
|
+
constructor(data?: Partial<APISelectMenuComponent>);
|
|
14
|
+
/**
|
|
15
|
+
* Sets the placeholder for this select menu
|
|
16
|
+
*
|
|
17
|
+
* @param placeholder - The placeholder to use for this select menu
|
|
18
|
+
*/
|
|
19
|
+
setPlaceholder(placeholder: string): this;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the minimum values that must be selected in the select menu
|
|
22
|
+
*
|
|
23
|
+
* @param minValues - The minimum values that must be selected
|
|
24
|
+
*/
|
|
25
|
+
setMinValues(minValues: number): this;
|
|
26
|
+
/**
|
|
27
|
+
* Sets the maximum values that must be selected in the select menu
|
|
28
|
+
*
|
|
29
|
+
* @param maxValues - The maximum values that must be selected
|
|
30
|
+
*/
|
|
31
|
+
setMaxValues(maxValues: number): this;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the custom id for this select menu
|
|
34
|
+
*
|
|
35
|
+
* @param customId - The custom id to use for this select menu
|
|
36
|
+
*/
|
|
37
|
+
setCustomId(customId: string): this;
|
|
38
|
+
/**
|
|
39
|
+
* Sets whether this select menu is disabled
|
|
40
|
+
*
|
|
41
|
+
* @param disabled - Whether this select menu is disabled
|
|
42
|
+
*/
|
|
43
|
+
setDisabled(disabled?: boolean): this;
|
|
44
|
+
/**
|
|
45
|
+
* Adds options to this select menu
|
|
46
|
+
*
|
|
47
|
+
* @param options - The options to add to this select menu
|
|
48
|
+
* @returns
|
|
49
|
+
*/
|
|
50
|
+
addOptions(...options: RestOrArray<SelectMenuOptionBuilder | APISelectMenuOption>): this;
|
|
51
|
+
/**
|
|
52
|
+
* Sets the options on this select menu
|
|
53
|
+
*
|
|
54
|
+
* @param options - The options to set on this select menu
|
|
55
|
+
*/
|
|
56
|
+
setOptions(...options: RestOrArray<SelectMenuOptionBuilder | APISelectMenuOption>): this;
|
|
57
|
+
toJSON(): APISelectMenuComponent;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=SelectMenu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectMenu.d.ts","sourceRoot":"","sources":["../../../src/components/selectMenu/SelectMenu.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAiB,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACxG,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAU7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,gBAAgB,CAAC,sBAAsB,CAAC;IAC9E;;OAEG;IACH,SAAgB,OAAO,EAAE,uBAAuB,EAAE,CAAC;gBAEhC,IAAI,CAAC,EAAE,OAAO,CAAC,sBAAsB,CAAC;IAMzD;;;;OAIG;IACI,cAAc,CAAC,WAAW,EAAE,MAAM;IAKzC;;;;OAIG;IACI,YAAY,CAAC,SAAS,EAAE,MAAM;IAKrC;;;;OAIG;IACI,YAAY,CAAC,SAAS,EAAE,MAAM;IAKrC;;;;OAIG;IACI,WAAW,CAAC,QAAQ,EAAE,MAAM;IAKnC;;;;OAIG;IACI,WAAW,CAAC,QAAQ,UAAO;IAKlC;;;;;OAKG;IACI,UAAU,CAAC,GAAG,OAAO,EAAE,WAAW,CAAC,uBAAuB,GAAG,mBAAmB,CAAC;IAaxF;;;;OAIG;IACI,UAAU,CAAC,GAAG,OAAO,EAAE,WAAW,CAAC,uBAAuB,GAAG,mBAAmB,CAAC;IAejF,MAAM,IAAI,sBAAsB;CAQvC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import { SelectMenuOptionBuilder } from './SelectMenuOption.mjs';
|
|
3
|
+
import { normalizeArray } from '../../util/normalizeArray.mjs';
|
|
4
|
+
import { placeholderValidator, minMaxValidator, customIdValidator, disabledValidator, optionsLengthValidator, optionValidator, validateRequiredSelectMenuParameters } from '../Assertions.mjs';
|
|
5
|
+
import { ComponentBuilder } from '../Component.mjs';
|
|
6
|
+
|
|
7
|
+
class SelectMenuBuilder extends ComponentBuilder {
|
|
8
|
+
constructor(data) {
|
|
9
|
+
const { options, ...initData } = data ?? {};
|
|
10
|
+
super({ type: ComponentType.SelectMenu, ...initData });
|
|
11
|
+
this.options = options?.map((o) => new SelectMenuOptionBuilder(o)) ?? [];
|
|
12
|
+
}
|
|
13
|
+
setPlaceholder(placeholder) {
|
|
14
|
+
this.data.placeholder = placeholderValidator.parse(placeholder);
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
setMinValues(minValues) {
|
|
18
|
+
this.data.min_values = minMaxValidator.parse(minValues);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
setMaxValues(maxValues) {
|
|
22
|
+
this.data.max_values = minMaxValidator.parse(maxValues);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
setCustomId(customId) {
|
|
26
|
+
this.data.custom_id = customIdValidator.parse(customId);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
setDisabled(disabled = true) {
|
|
30
|
+
this.data.disabled = disabledValidator.parse(disabled);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
addOptions(...options) {
|
|
34
|
+
options = normalizeArray(options);
|
|
35
|
+
optionsLengthValidator.parse(this.options.length + options.length);
|
|
36
|
+
this.options.push(...options.map((option) => option instanceof SelectMenuOptionBuilder ? option : new SelectMenuOptionBuilder(optionValidator.parse(option))));
|
|
37
|
+
return this;
|
|
38
|
+
}
|
|
39
|
+
setOptions(...options) {
|
|
40
|
+
options = normalizeArray(options);
|
|
41
|
+
optionsLengthValidator.parse(options.length);
|
|
42
|
+
this.options.splice(0, this.options.length, ...options.map((option) => option instanceof SelectMenuOptionBuilder ? option : new SelectMenuOptionBuilder(optionValidator.parse(option))));
|
|
43
|
+
return this;
|
|
44
|
+
}
|
|
45
|
+
toJSON() {
|
|
46
|
+
validateRequiredSelectMenuParameters(this.options, this.data.custom_id);
|
|
47
|
+
return {
|
|
48
|
+
...this.data,
|
|
49
|
+
options: this.options.map((o) => o.toJSON())
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { SelectMenuBuilder };
|
|
55
|
+
//# sourceMappingURL=SelectMenu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectMenu.mjs","sources":["../../../src/components/selectMenu/SelectMenu.ts"],"sourcesContent":["import { APISelectMenuOption, ComponentType, type APISelectMenuComponent } from 'discord-api-types/v10';\nimport { SelectMenuOptionBuilder } from './SelectMenuOption';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\nimport {\n\tcustomIdValidator,\n\tdisabledValidator,\n\tminMaxValidator,\n\toptionsLengthValidator,\n\toptionValidator,\n\tplaceholderValidator,\n\tvalidateRequiredSelectMenuParameters,\n} from '../Assertions';\nimport { ComponentBuilder } from '../Component';\n\n/**\n * Represents a select menu component\n */\nexport class SelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent> {\n\t/**\n\t * The options within this select menu\n\t */\n\tpublic readonly options: SelectMenuOptionBuilder[];\n\n\tpublic constructor(data?: Partial<APISelectMenuComponent>) {\n\t\tconst { options, ...initData } = data ?? {};\n\t\tsuper({ type: ComponentType.SelectMenu, ...initData });\n\t\tthis.options = options?.map((o) => new SelectMenuOptionBuilder(o)) ?? [];\n\t}\n\n\t/**\n\t * Sets the placeholder for this select menu\n\t *\n\t * @param placeholder - The placeholder to use for this select menu\n\t */\n\tpublic setPlaceholder(placeholder: string) {\n\t\tthis.data.placeholder = placeholderValidator.parse(placeholder);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the minimum values that must be selected in the select menu\n\t *\n\t * @param minValues - The minimum values that must be selected\n\t */\n\tpublic setMinValues(minValues: number) {\n\t\tthis.data.min_values = minMaxValidator.parse(minValues);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum values that must be selected in the select menu\n\t *\n\t * @param maxValues - The maximum values that must be selected\n\t */\n\tpublic setMaxValues(maxValues: number) {\n\t\tthis.data.max_values = minMaxValidator.parse(maxValues);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id for this select menu\n\t *\n\t * @param customId - The custom id to use for this select menu\n\t */\n\tpublic setCustomId(customId: string) {\n\t\tthis.data.custom_id = customIdValidator.parse(customId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether this select menu is disabled\n\t *\n\t * @param disabled - Whether this select menu is disabled\n\t */\n\tpublic setDisabled(disabled = true) {\n\t\tthis.data.disabled = disabledValidator.parse(disabled);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds options to this select menu\n\t *\n\t * @param options - The options to add to this select menu\n\t * @returns\n\t */\n\tpublic addOptions(...options: RestOrArray<SelectMenuOptionBuilder | APISelectMenuOption>) {\n\t\toptions = normalizeArray(options);\n\t\toptionsLengthValidator.parse(this.options.length + options.length);\n\t\tthis.options.push(\n\t\t\t...options.map((option) =>\n\t\t\t\toption instanceof SelectMenuOptionBuilder\n\t\t\t\t\t? option\n\t\t\t\t\t: new SelectMenuOptionBuilder(optionValidator.parse<APISelectMenuOption>(option)),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the options on this select menu\n\t *\n\t * @param options - The options to set on this select menu\n\t */\n\tpublic setOptions(...options: RestOrArray<SelectMenuOptionBuilder | APISelectMenuOption>) {\n\t\toptions = normalizeArray(options);\n\t\toptionsLengthValidator.parse(options.length);\n\t\tthis.options.splice(\n\t\t\t0,\n\t\t\tthis.options.length,\n\t\t\t...options.map((option) =>\n\t\t\t\toption instanceof SelectMenuOptionBuilder\n\t\t\t\t\t? option\n\t\t\t\t\t: new SelectMenuOptionBuilder(optionValidator.parse<APISelectMenuOption>(option)),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APISelectMenuComponent {\n\t\tvalidateRequiredSelectMenuParameters(this.options, this.data.custom_id);\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\treturn {\n\t\t\t...this.data,\n\t\t\toptions: this.options.map((o) => o.toJSON()),\n\t\t} as APISelectMenuComponent;\n\t}\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const Assertions = require('../Assertions.cjs');
|
|
6
|
+
|
|
7
|
+
class SelectMenuOptionBuilder {
|
|
8
|
+
constructor(data = {}) {
|
|
9
|
+
this.data = data;
|
|
10
|
+
}
|
|
11
|
+
setLabel(label) {
|
|
12
|
+
this.data.label = Assertions.labelValueDescriptionValidator.parse(label);
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
setValue(value) {
|
|
16
|
+
this.data.value = Assertions.labelValueDescriptionValidator.parse(value);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
setDescription(description) {
|
|
20
|
+
this.data.description = Assertions.labelValueDescriptionValidator.parse(description);
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
setDefault(isDefault = true) {
|
|
24
|
+
this.data.default = Assertions.defaultValidator.parse(isDefault);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
setEmoji(emoji) {
|
|
28
|
+
this.data.emoji = Assertions.emojiValidator.parse(emoji);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
toJSON() {
|
|
32
|
+
Assertions.validateRequiredSelectMenuOptionParameters(this.data.label, this.data.value);
|
|
33
|
+
return {
|
|
34
|
+
...this.data
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
exports.SelectMenuOptionBuilder = SelectMenuOptionBuilder;
|
|
40
|
+
//# sourceMappingURL=SelectMenuOption.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectMenuOption.cjs","sources":["../../../src/components/selectMenu/SelectMenuOption.ts"],"sourcesContent":["import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v10';\n\nimport {\n\tdefaultValidator,\n\temojiValidator,\n\tlabelValueDescriptionValidator,\n\tvalidateRequiredSelectMenuOptionParameters,\n} from '../Assertions';\n\n/**\n * Represents a option within a select menu component\n */\nexport class SelectMenuOptionBuilder {\n\tpublic constructor(public data: Partial<APISelectMenuOption> = {}) {}\n\n\t/**\n\t * Sets the label of this option\n\t *\n\t * @param label - The label to show on this option\n\t */\n\tpublic setLabel(label: string) {\n\t\tthis.data.label = labelValueDescriptionValidator.parse(label);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the value of this option\n\t *\n\t * @param value - The value of this option\n\t */\n\tpublic setValue(value: string) {\n\t\tthis.data.value = labelValueDescriptionValidator.parse(value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this option\n\t *\n\t * @param description - The description of this option\n\t */\n\tpublic setDescription(description: string) {\n\t\tthis.data.description = labelValueDescriptionValidator.parse(description);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether this option is selected by default\n\t *\n\t * @param isDefault - Whether this option is selected by default\n\t */\n\tpublic setDefault(isDefault = true) {\n\t\tthis.data.default = defaultValidator.parse(isDefault);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the emoji to display on this option\n\t *\n\t * @param emoji - The emoji to display on this option\n\t */\n\tpublic setEmoji(emoji: APIMessageComponentEmoji) {\n\t\tthis.data.emoji = emojiValidator.parse(emoji);\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APISelectMenuOption {\n\t\tvalidateRequiredSelectMenuOptionParameters(this.data.label, this.data.value);\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\treturn {\n\t\t\t...this.data,\n\t\t} as APISelectMenuOption;\n\t}\n}\n"],"names":["labelValueDescriptionValidator","defaultValidator","emojiValidator","validateRequiredSelectMenuOptionParameters"],"mappings":";;;;;;AAMO,MAAM,uBAAuB,CAAC;AACrC,EAAE,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACrB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAGA,yCAA8B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClE,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAGA,yCAA8B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClE,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,cAAc,CAAC,WAAW,EAAE;AAC9B,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,GAAGA,yCAA8B,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAC9E,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,UAAU,CAAC,SAAS,GAAG,IAAI,EAAE;AAC/B,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,GAAGC,2BAAgB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAC1D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAGC,yBAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAIC,qDAA0C,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjF,IAAI,OAAO;AACX,MAAM,GAAG,IAAI,CAAC,IAAI;AAClB,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v10';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a option within a select menu component
|
|
4
|
+
*/
|
|
5
|
+
export declare class SelectMenuOptionBuilder {
|
|
6
|
+
data: Partial<APISelectMenuOption>;
|
|
7
|
+
constructor(data?: Partial<APISelectMenuOption>);
|
|
8
|
+
/**
|
|
9
|
+
* Sets the label of this option
|
|
10
|
+
*
|
|
11
|
+
* @param label - The label to show on this option
|
|
12
|
+
*/
|
|
13
|
+
setLabel(label: string): this;
|
|
14
|
+
/**
|
|
15
|
+
* Sets the value of this option
|
|
16
|
+
*
|
|
17
|
+
* @param value - The value of this option
|
|
18
|
+
*/
|
|
19
|
+
setValue(value: string): this;
|
|
20
|
+
/**
|
|
21
|
+
* Sets the description of this option
|
|
22
|
+
*
|
|
23
|
+
* @param description - The description of this option
|
|
24
|
+
*/
|
|
25
|
+
setDescription(description: string): this;
|
|
26
|
+
/**
|
|
27
|
+
* Sets whether this option is selected by default
|
|
28
|
+
*
|
|
29
|
+
* @param isDefault - Whether this option is selected by default
|
|
30
|
+
*/
|
|
31
|
+
setDefault(isDefault?: boolean): this;
|
|
32
|
+
/**
|
|
33
|
+
* Sets the emoji to display on this option
|
|
34
|
+
*
|
|
35
|
+
* @param emoji - The emoji to display on this option
|
|
36
|
+
*/
|
|
37
|
+
setEmoji(emoji: APIMessageComponentEmoji): this;
|
|
38
|
+
toJSON(): APISelectMenuOption;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=SelectMenuOption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectMenuOption.d.ts","sourceRoot":"","sources":["../../../src/components/selectMenu/SelectMenuOption.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAS3F;;GAEG;AACH,qBAAa,uBAAuB;IACT,IAAI,EAAE,OAAO,CAAC,mBAAmB,CAAC;gBAAlC,IAAI,GAAE,OAAO,CAAC,mBAAmB,CAAM;IAEjE;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM;IAK7B;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM;IAK7B;;;;OAIG;IACI,cAAc,CAAC,WAAW,EAAE,MAAM;IAKzC;;;;OAIG;IACI,UAAU,CAAC,SAAS,UAAO;IAKlC;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,wBAAwB;IAKxC,MAAM,IAAI,mBAAmB;CAOpC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { labelValueDescriptionValidator, defaultValidator, emojiValidator, validateRequiredSelectMenuOptionParameters } from '../Assertions.mjs';
|
|
2
|
+
|
|
3
|
+
class SelectMenuOptionBuilder {
|
|
4
|
+
constructor(data = {}) {
|
|
5
|
+
this.data = data;
|
|
6
|
+
}
|
|
7
|
+
setLabel(label) {
|
|
8
|
+
this.data.label = labelValueDescriptionValidator.parse(label);
|
|
9
|
+
return this;
|
|
10
|
+
}
|
|
11
|
+
setValue(value) {
|
|
12
|
+
this.data.value = labelValueDescriptionValidator.parse(value);
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
setDescription(description) {
|
|
16
|
+
this.data.description = labelValueDescriptionValidator.parse(description);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
setDefault(isDefault = true) {
|
|
20
|
+
this.data.default = defaultValidator.parse(isDefault);
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
setEmoji(emoji) {
|
|
24
|
+
this.data.emoji = emojiValidator.parse(emoji);
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
toJSON() {
|
|
28
|
+
validateRequiredSelectMenuOptionParameters(this.data.label, this.data.value);
|
|
29
|
+
return {
|
|
30
|
+
...this.data
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export { SelectMenuOptionBuilder };
|
|
36
|
+
//# sourceMappingURL=SelectMenuOption.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectMenuOption.mjs","sources":["../../../src/components/selectMenu/SelectMenuOption.ts"],"sourcesContent":["import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v10';\n\nimport {\n\tdefaultValidator,\n\temojiValidator,\n\tlabelValueDescriptionValidator,\n\tvalidateRequiredSelectMenuOptionParameters,\n} from '../Assertions';\n\n/**\n * Represents a option within a select menu component\n */\nexport class SelectMenuOptionBuilder {\n\tpublic constructor(public data: Partial<APISelectMenuOption> = {}) {}\n\n\t/**\n\t * Sets the label of this option\n\t *\n\t * @param label - The label to show on this option\n\t */\n\tpublic setLabel(label: string) {\n\t\tthis.data.label = labelValueDescriptionValidator.parse(label);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the value of this option\n\t *\n\t * @param value - The value of this option\n\t */\n\tpublic setValue(value: string) {\n\t\tthis.data.value = labelValueDescriptionValidator.parse(value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this option\n\t *\n\t * @param description - The description of this option\n\t */\n\tpublic setDescription(description: string) {\n\t\tthis.data.description = labelValueDescriptionValidator.parse(description);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether this option is selected by default\n\t *\n\t * @param isDefault - Whether this option is selected by default\n\t */\n\tpublic setDefault(isDefault = true) {\n\t\tthis.data.default = defaultValidator.parse(isDefault);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the emoji to display on this option\n\t *\n\t * @param emoji - The emoji to display on this option\n\t */\n\tpublic setEmoji(emoji: APIMessageComponentEmoji) {\n\t\tthis.data.emoji = emojiValidator.parse(emoji);\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APISelectMenuOption {\n\t\tvalidateRequiredSelectMenuOptionParameters(this.data.label, this.data.value);\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\treturn {\n\t\t\t...this.data,\n\t\t} as APISelectMenuOption;\n\t}\n}\n"],"names":[],"mappings":";;AAMO,MAAM,uBAAuB,CAAC;AACrC,EAAE,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACrB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,8BAA8B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClE,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,8BAA8B,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClE,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,cAAc,CAAC,WAAW,EAAE;AAC9B,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,8BAA8B,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAC9E,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,UAAU,CAAC,SAAS,GAAG,IAAI,EAAE;AAC/B,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAC1D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,0CAA0C,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjF,IAAI,OAAO;AACX,MAAM,GAAG,IAAI,CAAC,IAAI;AAClB,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const shapeshift = require('@sapphire/shapeshift');
|
|
6
|
+
const v10 = require('discord-api-types/v10');
|
|
7
|
+
const validation = require('../../util/validation.cjs');
|
|
8
|
+
const Assertions$1 = require('../Assertions.cjs');
|
|
9
|
+
|
|
10
|
+
const textInputStyleValidator = shapeshift.s.nativeEnum(v10.TextInputStyle);
|
|
11
|
+
const minLengthValidator = shapeshift.s.number.int.greaterThanOrEqual(0).lessThanOrEqual(4e3).setValidationEnabled(validation.isValidationEnabled);
|
|
12
|
+
const maxLengthValidator = shapeshift.s.number.int.greaterThanOrEqual(1).lessThanOrEqual(4e3).setValidationEnabled(validation.isValidationEnabled);
|
|
13
|
+
const requiredValidator = shapeshift.s.boolean;
|
|
14
|
+
const valueValidator = shapeshift.s.string.lengthLessThanOrEqual(4e3).setValidationEnabled(validation.isValidationEnabled);
|
|
15
|
+
const placeholderValidator = shapeshift.s.string.lengthLessThanOrEqual(100).setValidationEnabled(validation.isValidationEnabled);
|
|
16
|
+
const labelValidator = shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(validation.isValidationEnabled);
|
|
17
|
+
function validateRequiredParameters(customId, style, label) {
|
|
18
|
+
Assertions$1.customIdValidator.parse(customId);
|
|
19
|
+
textInputStyleValidator.parse(style);
|
|
20
|
+
labelValidator.parse(label);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
exports.labelValidator = labelValidator;
|
|
24
|
+
exports.maxLengthValidator = maxLengthValidator;
|
|
25
|
+
exports.minLengthValidator = minLengthValidator;
|
|
26
|
+
exports.placeholderValidator = placeholderValidator;
|
|
27
|
+
exports.requiredValidator = requiredValidator;
|
|
28
|
+
exports.textInputStyleValidator = textInputStyleValidator;
|
|
29
|
+
exports.validateRequiredParameters = validateRequiredParameters;
|
|
30
|
+
exports.valueValidator = valueValidator;
|
|
31
|
+
//# sourceMappingURL=Assertions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Assertions.cjs","sources":["../../../src/components/textInput/Assertions.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { TextInputStyle } from 'discord-api-types/v10';\nimport { isValidationEnabled } from '../../util/validation';\nimport { customIdValidator } from '../Assertions';\n\nexport const textInputStyleValidator = s.nativeEnum(TextInputStyle);\nexport const minLengthValidator = s.number.int\n\t.greaterThanOrEqual(0)\n\t.lessThanOrEqual(4000)\n\t.setValidationEnabled(isValidationEnabled);\nexport const maxLengthValidator = s.number.int\n\t.greaterThanOrEqual(1)\n\t.lessThanOrEqual(4000)\n\t.setValidationEnabled(isValidationEnabled);\nexport const requiredValidator = s.boolean;\nexport const valueValidator = s.string.lengthLessThanOrEqual(4000).setValidationEnabled(isValidationEnabled);\nexport const placeholderValidator = s.string.lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);\nexport const labelValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(45)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredParameters(customId?: string, style?: TextInputStyle, label?: string) {\n\tcustomIdValidator.parse(customId);\n\ttextInputStyleValidator.parse(style);\n\tlabelValidator.parse(label);\n}\n"],"names":["s","TextInputStyle","isValidationEnabled","customIdValidator"],"mappings":";;;;;;;;;AAIY,MAAC,uBAAuB,GAAGA,YAAC,CAAC,UAAU,CAACC,kBAAc,EAAE;AACxD,MAAC,kBAAkB,GAAGD,YAAC,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAACE,8BAAmB,EAAE;AACxH,MAAC,kBAAkB,GAAGF,YAAC,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAACE,8BAAmB,EAAE;AACxH,MAAC,iBAAiB,GAAGF,YAAC,CAAC,QAAQ;AAC/B,MAAC,cAAc,GAAGA,YAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAACE,8BAAmB,EAAE;AAChG,MAAC,oBAAoB,GAAGF,YAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAACE,8BAAmB,EAAE;AACtG,MAAC,cAAc,GAAGF,YAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,oBAAoB,CAACE,8BAAmB,EAAE;AAChI,SAAS,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE;AACnE,EAAEC,8BAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACpC,EAAE,uBAAuB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACvC,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9B;;;;;;;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { TextInputStyle } from 'discord-api-types/v10';
|
|
2
|
+
export declare const textInputStyleValidator: import("@sapphire/shapeshift").NativeEnumValidator<typeof TextInputStyle>;
|
|
3
|
+
export declare const minLengthValidator: import("@sapphire/shapeshift").NumberValidator<number>;
|
|
4
|
+
export declare const maxLengthValidator: import("@sapphire/shapeshift").NumberValidator<number>;
|
|
5
|
+
export declare const requiredValidator: import("@sapphire/shapeshift").BooleanValidator<boolean>;
|
|
6
|
+
export declare const valueValidator: import("@sapphire/shapeshift").StringValidator<string>;
|
|
7
|
+
export declare const placeholderValidator: import("@sapphire/shapeshift").StringValidator<string>;
|
|
8
|
+
export declare const labelValidator: import("@sapphire/shapeshift").StringValidator<string>;
|
|
9
|
+
export declare function validateRequiredParameters(customId?: string, style?: TextInputStyle, label?: string): void;
|
|
10
|
+
//# sourceMappingURL=Assertions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Assertions.d.ts","sourceRoot":"","sources":["../../../src/components/textInput/Assertions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAIvD,eAAO,MAAM,uBAAuB,2EAA+B,CAAC;AACpE,eAAO,MAAM,kBAAkB,wDAGY,CAAC;AAC5C,eAAO,MAAM,kBAAkB,wDAGY,CAAC;AAC5C,eAAO,MAAM,iBAAiB,0DAAY,CAAC;AAC3C,eAAO,MAAM,cAAc,wDAAiF,CAAC;AAC7G,eAAO,MAAM,oBAAoB,wDAAgF,CAAC;AAClH,eAAO,MAAM,cAAc,wDAGgB,CAAC;AAE5C,wBAAgB,0BAA0B,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,EAAE,MAAM,QAInG"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { s } from '@sapphire/shapeshift';
|
|
2
|
+
import { TextInputStyle } from 'discord-api-types/v10';
|
|
3
|
+
import { isValidationEnabled } from '../../util/validation.mjs';
|
|
4
|
+
import { customIdValidator } from '../Assertions.mjs';
|
|
5
|
+
|
|
6
|
+
const textInputStyleValidator = s.nativeEnum(TextInputStyle);
|
|
7
|
+
const minLengthValidator = s.number.int.greaterThanOrEqual(0).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
8
|
+
const maxLengthValidator = s.number.int.greaterThanOrEqual(1).lessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
9
|
+
const requiredValidator = s.boolean;
|
|
10
|
+
const valueValidator = s.string.lengthLessThanOrEqual(4e3).setValidationEnabled(isValidationEnabled);
|
|
11
|
+
const placeholderValidator = s.string.lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
|
12
|
+
const labelValidator = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(45).setValidationEnabled(isValidationEnabled);
|
|
13
|
+
function validateRequiredParameters(customId, style, label) {
|
|
14
|
+
customIdValidator.parse(customId);
|
|
15
|
+
textInputStyleValidator.parse(style);
|
|
16
|
+
labelValidator.parse(label);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { labelValidator, maxLengthValidator, minLengthValidator, placeholderValidator, requiredValidator, textInputStyleValidator, validateRequiredParameters, valueValidator };
|
|
20
|
+
//# sourceMappingURL=Assertions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Assertions.mjs","sources":["../../../src/components/textInput/Assertions.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { TextInputStyle } from 'discord-api-types/v10';\nimport { isValidationEnabled } from '../../util/validation';\nimport { customIdValidator } from '../Assertions';\n\nexport const textInputStyleValidator = s.nativeEnum(TextInputStyle);\nexport const minLengthValidator = s.number.int\n\t.greaterThanOrEqual(0)\n\t.lessThanOrEqual(4000)\n\t.setValidationEnabled(isValidationEnabled);\nexport const maxLengthValidator = s.number.int\n\t.greaterThanOrEqual(1)\n\t.lessThanOrEqual(4000)\n\t.setValidationEnabled(isValidationEnabled);\nexport const requiredValidator = s.boolean;\nexport const valueValidator = s.string.lengthLessThanOrEqual(4000).setValidationEnabled(isValidationEnabled);\nexport const placeholderValidator = s.string.lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);\nexport const labelValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(45)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredParameters(customId?: string, style?: TextInputStyle, label?: string) {\n\tcustomIdValidator.parse(customId);\n\ttextInputStyleValidator.parse(style);\n\tlabelValidator.parse(label);\n}\n"],"names":[],"mappings":";;;;;AAIY,MAAC,uBAAuB,GAAG,CAAC,CAAC,UAAU,CAAC,cAAc,EAAE;AACxD,MAAC,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,mBAAmB,EAAE;AACxH,MAAC,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,mBAAmB,EAAE;AACxH,MAAC,iBAAiB,GAAG,CAAC,CAAC,QAAQ;AAC/B,MAAC,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,mBAAmB,EAAE;AAChG,MAAC,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,oBAAoB,CAAC,mBAAmB,EAAE;AACtG,MAAC,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC,oBAAoB,CAAC,mBAAmB,EAAE;AAChI,SAAS,0BAA0B,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE;AACnE,EAAE,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AACpC,EAAE,uBAAuB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACvC,EAAE,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC9B;;;;"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const v10 = require('discord-api-types/v10');
|
|
6
|
+
const isEqual = require('fast-deep-equal');
|
|
7
|
+
const Assertions$1 = require('./Assertions.cjs');
|
|
8
|
+
const jsonEncodable = require('../../util/jsonEncodable.cjs');
|
|
9
|
+
const Assertions = require('../Assertions.cjs');
|
|
10
|
+
const Component = require('../Component.cjs');
|
|
11
|
+
|
|
12
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
13
|
+
|
|
14
|
+
const isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
15
|
+
|
|
16
|
+
class TextInputBuilder extends Component.ComponentBuilder {
|
|
17
|
+
constructor(data) {
|
|
18
|
+
super({ type: v10.ComponentType.TextInput, ...data });
|
|
19
|
+
}
|
|
20
|
+
setCustomId(customId) {
|
|
21
|
+
this.data.custom_id = Assertions.customIdValidator.parse(customId);
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
setLabel(label) {
|
|
25
|
+
this.data.label = Assertions$1.labelValidator.parse(label);
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
setStyle(style) {
|
|
29
|
+
this.data.style = Assertions$1.textInputStyleValidator.parse(style);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
setMinLength(minLength) {
|
|
33
|
+
this.data.min_length = Assertions$1.minLengthValidator.parse(minLength);
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
setMaxLength(maxLength) {
|
|
37
|
+
this.data.max_length = Assertions$1.maxLengthValidator.parse(maxLength);
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
setPlaceholder(placeholder) {
|
|
41
|
+
this.data.placeholder = Assertions$1.placeholderValidator.parse(placeholder);
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
setValue(value) {
|
|
45
|
+
this.data.value = Assertions$1.valueValidator.parse(value);
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
setRequired(required = true) {
|
|
49
|
+
this.data.required = Assertions$1.requiredValidator.parse(required);
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
toJSON() {
|
|
53
|
+
Assertions$1.validateRequiredParameters(this.data.custom_id, this.data.style, this.data.label);
|
|
54
|
+
return {
|
|
55
|
+
...this.data
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
equals(other) {
|
|
59
|
+
if (jsonEncodable.isJSONEncodable(other)) {
|
|
60
|
+
return isEqual__default(other.toJSON(), this.data);
|
|
61
|
+
}
|
|
62
|
+
return isEqual__default(other, this.data);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
exports.TextInputBuilder = TextInputBuilder;
|
|
67
|
+
//# sourceMappingURL=TextInput.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextInput.cjs","sources":["../../../src/components/textInput/TextInput.ts"],"sourcesContent":["import { ComponentType, type TextInputStyle, type APITextInputComponent } from 'discord-api-types/v10';\nimport isEqual from 'fast-deep-equal';\nimport {\n\tmaxLengthValidator,\n\tminLengthValidator,\n\tplaceholderValidator,\n\trequiredValidator,\n\tvalueValidator,\n\tvalidateRequiredParameters,\n\tlabelValidator,\n\ttextInputStyleValidator,\n} from './Assertions';\nimport { isJSONEncodable, type JSONEncodable } from '../../util/jsonEncodable';\nimport { customIdValidator } from '../Assertions';\nimport { ComponentBuilder } from '../Component';\n\nexport class TextInputBuilder extends ComponentBuilder<APITextInputComponent> {\n\tpublic constructor(data?: APITextInputComponent & { type?: ComponentType.TextInput }) {\n\t\tsuper({ type: ComponentType.TextInput, ...data });\n\t}\n\n\t/**\n\t * Sets the custom id for this text input\n\t *\n\t * @param customId - The custom id of this text input\n\t */\n\tpublic setCustomId(customId: string) {\n\t\tthis.data.custom_id = customIdValidator.parse(customId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the label for this text input\n\t *\n\t * @param label - The label for this text input\n\t */\n\tpublic setLabel(label: string) {\n\t\tthis.data.label = labelValidator.parse(label);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the style for this text input\n\t *\n\t * @param style - The style for this text input\n\t */\n\tpublic setStyle(style: TextInputStyle) {\n\t\tthis.data.style = textInputStyleValidator.parse(style);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the minimum length of text for this text input\n\t *\n\t * @param minLength - The minimum length of text for this text input\n\t */\n\tpublic setMinLength(minLength: number) {\n\t\tthis.data.min_length = minLengthValidator.parse(minLength);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum length of text for this text input\n\t *\n\t * @param maxLength - The maximum length of text for this text input\n\t */\n\tpublic setMaxLength(maxLength: number) {\n\t\tthis.data.max_length = maxLengthValidator.parse(maxLength);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the placeholder of this text input\n\t *\n\t * @param placeholder - The placeholder of this text input\n\t */\n\tpublic setPlaceholder(placeholder: string) {\n\t\tthis.data.placeholder = placeholderValidator.parse(placeholder);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the value of this text input\n\t *\n\t * @param value - The value for this text input\n\t */\n\tpublic setValue(value: string) {\n\t\tthis.data.value = valueValidator.parse(value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether this text input is required\n\t *\n\t * @param required - Whether this text input is required\n\t */\n\tpublic setRequired(required = true) {\n\t\tthis.data.required = requiredValidator.parse(required);\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APITextInputComponent {\n\t\tvalidateRequiredParameters(this.data.custom_id, this.data.style, this.data.label);\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\treturn {\n\t\t\t...this.data,\n\t\t} as APITextInputComponent;\n\t}\n\n\tpublic equals(other: JSONEncodable<APITextInputComponent> | APITextInputComponent): boolean {\n\t\tif (isJSONEncodable(other)) {\n\t\t\treturn isEqual(other.toJSON(), this.data);\n\t\t}\n\n\t\treturn isEqual(other, this.data);\n\t}\n}\n"],"names":["ComponentBuilder","ComponentType","customIdValidator","labelValidator","textInputStyleValidator","minLengthValidator","maxLengthValidator","placeholderValidator","valueValidator","requiredValidator","validateRequiredParameters","isJSONEncodable","isEqual"],"mappings":";;;;;;;;;;;;;;;AAeO,MAAM,gBAAgB,SAASA,0BAAgB,CAAC;AACvD,EAAE,WAAW,CAAC,IAAI,EAAE;AACpB,IAAI,KAAK,CAAC,EAAE,IAAI,EAAEC,iBAAa,CAAC,SAAS,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AACtD,GAAG;AACH,EAAE,WAAW,CAAC,QAAQ,EAAE;AACxB,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAGC,4BAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC5D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAGC,2BAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAGC,oCAAuB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAC3D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,YAAY,CAAC,SAAS,EAAE;AAC1B,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,GAAGC,+BAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAC/D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,YAAY,CAAC,SAAS,EAAE;AAC1B,IAAI,IAAI,CAAC,IAAI,CAAC,UAAU,GAAGC,+BAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAC/D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,cAAc,CAAC,WAAW,EAAE;AAC9B,IAAI,IAAI,CAAC,IAAI,CAAC,WAAW,GAAGC,iCAAoB,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AACpE,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAGC,2BAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAClD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,WAAW,CAAC,QAAQ,GAAG,IAAI,EAAE;AAC/B,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,GAAGC,8BAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC3D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAIC,uCAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtF,IAAI,OAAO;AACX,MAAM,GAAG,IAAI,CAAC,IAAI;AAClB,KAAK,CAAC;AACN,GAAG;AACH,EAAE,MAAM,CAAC,KAAK,EAAE;AAChB,IAAI,IAAIC,6BAAe,CAAC,KAAK,CAAC,EAAE;AAChC,MAAM,OAAOC,gBAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAChD,KAAK;AACL,IAAI,OAAOA,gBAAO,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AACrC,GAAG;AACH;;;;"}
|