@discordjs/builders 1.1.0-dev.1658102995-dda2895 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +5 -2
- 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 +77 -0
- package/dist/components/Assertions.cjs.map +1 -0
- package/dist/components/Assertions.d.ts +48 -0
- package/dist/components/Assertions.d.ts.map +1 -0
- package/dist/components/Assertions.mjs +57 -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 +129 -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 +102 -0
- package/dist/messages/formatters.cjs.map +1 -0
- package/dist/messages/formatters.d.ts +246 -0
- package/dist/messages/formatters.d.ts.map +1 -0
- package/dist/messages/formatters.mjs +79 -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 +17 -16
- package/dist/index.js +0 -1557
- package/dist/index.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,22 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
# [@discordjs/builders@1.1.0](https://github.com/discordjs/discord.js/compare/@discordjs/builders@1.0.0...@discordjs/builders@1.1.0) - (2022-07-29)
|
|
6
|
+
|
|
7
|
+
## Bug Fixes
|
|
8
|
+
|
|
9
|
+
- Use proper format for `@link` text (#8384) ([2655639](https://github.com/discordjs/discord.js/commit/26556390a3800e954974a00c1328ff47d3e67e9a))
|
|
10
|
+
- **Formatters:** Add newline in `codeBlock` (#8369) ([5d8bd03](https://github.com/discordjs/discord.js/commit/5d8bd030d60ef364de3ef5f9963da8bda5c4efd4))
|
|
11
|
+
- **selectMenu:** Allow json to be used for select menu options (#8322) ([6a2d0d8](https://github.com/discordjs/discord.js/commit/6a2d0d8e96d157d5b85cee7f17bffdfff4240074))
|
|
12
|
+
|
|
13
|
+
## Documentation
|
|
14
|
+
|
|
15
|
+
- Use link tags (#8382) ([5494791](https://github.com/discordjs/discord.js/commit/549479131318c659f86f0eb18578d597e22522d3))
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- Add channel & message URL formatters (#8371) ([a7deb8f](https://github.com/discordjs/discord.js/commit/a7deb8f89830ead6185c5fb46a49688b6d209ed1))
|
|
20
|
+
|
|
5
21
|
# [@discordjs/builders@1.0.0](https://github.com/discordjs/discord.js/compare/@discordjs/builders@0.16.0...@discordjs/builders@1.0.0) - (2022-07-17)
|
|
6
22
|
|
|
7
23
|
## Info
|
package/README.md
CHANGED
|
@@ -4,13 +4,16 @@
|
|
|
4
4
|
<a href="https://discord.js.org"><img src="https://discord.js.org/static/logo.svg" width="546" alt="discord.js" /></a>
|
|
5
5
|
</p>
|
|
6
6
|
<br />
|
|
7
|
-
|
|
7
|
+
<p>
|
|
8
8
|
<a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
|
|
9
9
|
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/v/@discordjs/builders.svg?maxAge=3600" alt="npm version" /></a>
|
|
10
10
|
<a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/dt/@discordjs/builders.svg?maxAge=3600" alt="npm downloads" /></a>
|
|
11
11
|
<a href="https://github.com/discordjs/discord.js/actions"><img src="https://github.com/discordjs/discord.js/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
|
|
12
12
|
<a href="https://codecov.io/gh/discordjs/discord.js" ><img src="https://codecov.io/gh/discordjs/discord.js/branch/main/graph/badge.svg?precision=2&flag=builders" alt="Code coverage" /></a>
|
|
13
13
|
</p>
|
|
14
|
+
<p>
|
|
15
|
+
<a href="https://vercel.com/?utm_source=discordjs&utm_campaign=oss"><img src="https://raw.githubusercontent.com/discordjs/discord.js/main/.github/powered-by-vercel.svg" alt="Vercel" /></a>
|
|
16
|
+
</p>
|
|
14
17
|
</div>
|
|
15
18
|
|
|
16
19
|
## Installation
|
|
@@ -34,7 +37,7 @@ Here are some examples for the builders and utilities you can find in this packa
|
|
|
34
37
|
- [Website](https://discord.js.org/) ([source](https://github.com/discordjs/discord.js/tree/main/packages/website))
|
|
35
38
|
- [Documentation](https://discord.js.org/#/docs/builders)
|
|
36
39
|
- [Guide](https://discordjs.guide/) ([source](https://github.com/discordjs/guide))
|
|
37
|
-
See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-
|
|
40
|
+
See also the [Update Guide](https://discordjs.guide/additional-info/changes-in-v14.html), including updated and removed items in the library.
|
|
38
41
|
- [discord.js Discord server](https://discord.gg/djs)
|
|
39
42
|
- [Discord API Discord server](https://discord.gg/discord-api)
|
|
40
43
|
- [GitHub](https://github.com/discordjs/discord.js/tree/main/packages/builders)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const v10 = require('discord-api-types/v10');
|
|
6
|
+
const Component = require('./Component.cjs');
|
|
7
|
+
const Components = require('./Components.cjs');
|
|
8
|
+
const normalizeArray = require('../util/normalizeArray.cjs');
|
|
9
|
+
|
|
10
|
+
class ActionRowBuilder extends Component.ComponentBuilder {
|
|
11
|
+
constructor({ components, ...data } = {}) {
|
|
12
|
+
super({ type: v10.ComponentType.ActionRow, ...data });
|
|
13
|
+
this.components = components?.map((c) => Components.createComponentBuilder(c)) ?? [];
|
|
14
|
+
}
|
|
15
|
+
addComponents(...components) {
|
|
16
|
+
this.components.push(...normalizeArray.normalizeArray(components));
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
setComponents(...components) {
|
|
20
|
+
this.components.splice(0, this.components.length, ...normalizeArray.normalizeArray(components));
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
toJSON() {
|
|
24
|
+
return {
|
|
25
|
+
...this.data,
|
|
26
|
+
components: this.components.map((component) => component.toJSON())
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
exports.ActionRowBuilder = ActionRowBuilder;
|
|
32
|
+
//# sourceMappingURL=ActionRow.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionRow.cjs","sources":["../../src/components/ActionRow.ts"],"sourcesContent":["import {\n\ttype APIActionRowComponent,\n\tComponentType,\n\tAPIMessageActionRowComponent,\n\tAPIModalActionRowComponent,\n\tAPIActionRowComponentTypes,\n} from 'discord-api-types/v10';\nimport { ComponentBuilder } from './Component';\nimport { createComponentBuilder } from './Components';\nimport type { ButtonBuilder } from './button/Button';\nimport type { SelectMenuBuilder } from './selectMenu/SelectMenu';\nimport type { TextInputBuilder } from './textInput/TextInput';\nimport { normalizeArray, type RestOrArray } from '../util/normalizeArray';\n\nexport type MessageComponentBuilder =\n\t| MessageActionRowComponentBuilder\n\t| ActionRowBuilder<MessageActionRowComponentBuilder>;\nexport type ModalComponentBuilder = ModalActionRowComponentBuilder | ActionRowBuilder<ModalActionRowComponentBuilder>;\nexport type MessageActionRowComponentBuilder = ButtonBuilder | SelectMenuBuilder;\nexport type ModalActionRowComponentBuilder = TextInputBuilder;\nexport type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder;\n\n/**\n * Represents an action row component\n */\nexport class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentBuilder<\n\tAPIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>\n> {\n\t/**\n\t * The components within this action row\n\t */\n\tpublic readonly components: T[];\n\n\tpublic constructor({ components, ...data }: Partial<APIActionRowComponent<APIActionRowComponentTypes>> = {}) {\n\t\tsuper({ type: ComponentType.ActionRow, ...data });\n\t\tthis.components = (components?.map((c) => createComponentBuilder(c)) ?? []) as T[];\n\t}\n\n\t/**\n\t * Adds components to this action row.\n\t *\n\t * @param components - The components to add to this action row.\n\t */\n\tpublic addComponents(...components: RestOrArray<T>) {\n\t\tthis.components.push(...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the components in this action row\n\t *\n\t * @param components - The components to set this row to\n\t */\n\tpublic setComponents(...components: RestOrArray<T>) {\n\t\tthis.components.splice(0, this.components.length, ...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIActionRowComponent<ReturnType<T['toJSON']>> {\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\treturn {\n\t\t\t...this.data,\n\t\t\tcomponents: this.components.map((component) => component.toJSON()),\n\t\t} as APIActionRowComponent<ReturnType<T['toJSON']>>;\n\t}\n}\n"],"names":["ComponentBuilder","ComponentType","createComponentBuilder","normalizeArray"],"mappings":";;;;;;;;;AAMO,MAAM,gBAAgB,SAASA,0BAAgB,CAAC;AACvD,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE;AAC5C,IAAI,KAAK,CAAC,EAAE,IAAI,EAAEC,iBAAa,CAAC,SAAS,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AACtD,IAAI,IAAI,CAAC,UAAU,GAAG,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,KAAKC,iCAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9E,GAAG;AACH,EAAE,aAAa,CAAC,GAAG,UAAU,EAAE;AAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAGC,6BAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AACxD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,aAAa,CAAC,GAAG,UAAU,EAAE;AAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,GAAGA,6BAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AACrF,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,OAAO;AACX,MAAM,GAAG,IAAI,CAAC,IAAI;AAClB,MAAM,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;AACxE,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type APIActionRowComponent, APIMessageActionRowComponent, APIModalActionRowComponent, APIActionRowComponentTypes } from 'discord-api-types/v10';
|
|
2
|
+
import { ComponentBuilder } from './Component';
|
|
3
|
+
import type { ButtonBuilder } from './button/Button';
|
|
4
|
+
import type { SelectMenuBuilder } from './selectMenu/SelectMenu';
|
|
5
|
+
import type { TextInputBuilder } from './textInput/TextInput';
|
|
6
|
+
import { type RestOrArray } from '../util/normalizeArray';
|
|
7
|
+
export declare type MessageComponentBuilder = MessageActionRowComponentBuilder | ActionRowBuilder<MessageActionRowComponentBuilder>;
|
|
8
|
+
export declare type ModalComponentBuilder = ModalActionRowComponentBuilder | ActionRowBuilder<ModalActionRowComponentBuilder>;
|
|
9
|
+
export declare type MessageActionRowComponentBuilder = ButtonBuilder | SelectMenuBuilder;
|
|
10
|
+
export declare type ModalActionRowComponentBuilder = TextInputBuilder;
|
|
11
|
+
export declare type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder;
|
|
12
|
+
/**
|
|
13
|
+
* Represents an action row component
|
|
14
|
+
*/
|
|
15
|
+
export declare class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentBuilder<APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>> {
|
|
16
|
+
/**
|
|
17
|
+
* The components within this action row
|
|
18
|
+
*/
|
|
19
|
+
readonly components: T[];
|
|
20
|
+
constructor({ components, ...data }?: Partial<APIActionRowComponent<APIActionRowComponentTypes>>);
|
|
21
|
+
/**
|
|
22
|
+
* Adds components to this action row.
|
|
23
|
+
*
|
|
24
|
+
* @param components - The components to add to this action row.
|
|
25
|
+
*/
|
|
26
|
+
addComponents(...components: RestOrArray<T>): this;
|
|
27
|
+
/**
|
|
28
|
+
* Sets the components in this action row
|
|
29
|
+
*
|
|
30
|
+
* @param components - The components to set this row to
|
|
31
|
+
*/
|
|
32
|
+
setComponents(...components: RestOrArray<T>): this;
|
|
33
|
+
toJSON(): APIActionRowComponent<ReturnType<T['toJSON']>>;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ActionRow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionRow.d.ts","sourceRoot":"","sources":["../../src/components/ActionRow.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,qBAAqB,EAE1B,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,EAC1B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1E,oBAAY,uBAAuB,GAChC,gCAAgC,GAChC,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;AACtD,oBAAY,qBAAqB,GAAG,8BAA8B,GAAG,gBAAgB,CAAC,8BAA8B,CAAC,CAAC;AACtH,oBAAY,gCAAgC,GAAG,aAAa,GAAG,iBAAiB,CAAC;AACjF,oBAAY,8BAA8B,GAAG,gBAAgB,CAAC;AAC9D,oBAAY,mBAAmB,GAAG,gCAAgC,GAAG,8BAA8B,CAAC;AAEpG;;GAEG;AACH,qBAAa,gBAAgB,CAAC,CAAC,SAAS,mBAAmB,CAAE,SAAQ,gBAAgB,CACpF,qBAAqB,CAAC,4BAA4B,GAAG,0BAA0B,CAAC,CAChF;IACA;;OAEG;IACH,SAAgB,UAAU,EAAE,CAAC,EAAE,CAAC;gBAEb,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAE,OAAO,CAAC,qBAAqB,CAAC,0BAA0B,CAAC,CAAM;IAK3G;;;;OAIG;IACI,aAAa,CAAC,GAAG,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;IAKlD;;;;OAIG;IACI,aAAa,CAAC,GAAG,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;IAK3C,MAAM,IAAI,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;CAO/D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import { ComponentBuilder } from './Component.mjs';
|
|
3
|
+
import { createComponentBuilder } from './Components.mjs';
|
|
4
|
+
import { normalizeArray } from '../util/normalizeArray.mjs';
|
|
5
|
+
|
|
6
|
+
class ActionRowBuilder extends ComponentBuilder {
|
|
7
|
+
constructor({ components, ...data } = {}) {
|
|
8
|
+
super({ type: ComponentType.ActionRow, ...data });
|
|
9
|
+
this.components = components?.map((c) => createComponentBuilder(c)) ?? [];
|
|
10
|
+
}
|
|
11
|
+
addComponents(...components) {
|
|
12
|
+
this.components.push(...normalizeArray(components));
|
|
13
|
+
return this;
|
|
14
|
+
}
|
|
15
|
+
setComponents(...components) {
|
|
16
|
+
this.components.splice(0, this.components.length, ...normalizeArray(components));
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
toJSON() {
|
|
20
|
+
return {
|
|
21
|
+
...this.data,
|
|
22
|
+
components: this.components.map((component) => component.toJSON())
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { ActionRowBuilder };
|
|
28
|
+
//# sourceMappingURL=ActionRow.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ActionRow.mjs","sources":["../../src/components/ActionRow.ts"],"sourcesContent":["import {\n\ttype APIActionRowComponent,\n\tComponentType,\n\tAPIMessageActionRowComponent,\n\tAPIModalActionRowComponent,\n\tAPIActionRowComponentTypes,\n} from 'discord-api-types/v10';\nimport { ComponentBuilder } from './Component';\nimport { createComponentBuilder } from './Components';\nimport type { ButtonBuilder } from './button/Button';\nimport type { SelectMenuBuilder } from './selectMenu/SelectMenu';\nimport type { TextInputBuilder } from './textInput/TextInput';\nimport { normalizeArray, type RestOrArray } from '../util/normalizeArray';\n\nexport type MessageComponentBuilder =\n\t| MessageActionRowComponentBuilder\n\t| ActionRowBuilder<MessageActionRowComponentBuilder>;\nexport type ModalComponentBuilder = ModalActionRowComponentBuilder | ActionRowBuilder<ModalActionRowComponentBuilder>;\nexport type MessageActionRowComponentBuilder = ButtonBuilder | SelectMenuBuilder;\nexport type ModalActionRowComponentBuilder = TextInputBuilder;\nexport type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder;\n\n/**\n * Represents an action row component\n */\nexport class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentBuilder<\n\tAPIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>\n> {\n\t/**\n\t * The components within this action row\n\t */\n\tpublic readonly components: T[];\n\n\tpublic constructor({ components, ...data }: Partial<APIActionRowComponent<APIActionRowComponentTypes>> = {}) {\n\t\tsuper({ type: ComponentType.ActionRow, ...data });\n\t\tthis.components = (components?.map((c) => createComponentBuilder(c)) ?? []) as T[];\n\t}\n\n\t/**\n\t * Adds components to this action row.\n\t *\n\t * @param components - The components to add to this action row.\n\t */\n\tpublic addComponents(...components: RestOrArray<T>) {\n\t\tthis.components.push(...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the components in this action row\n\t *\n\t * @param components - The components to set this row to\n\t */\n\tpublic setComponents(...components: RestOrArray<T>) {\n\t\tthis.components.splice(0, this.components.length, ...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIActionRowComponent<ReturnType<T['toJSON']>> {\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\treturn {\n\t\t\t...this.data,\n\t\t\tcomponents: this.components.map((component) => component.toJSON()),\n\t\t} as APIActionRowComponent<ReturnType<T['toJSON']>>;\n\t}\n}\n"],"names":[],"mappings":";;;;;AAMO,MAAM,gBAAgB,SAAS,gBAAgB,CAAC;AACvD,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE;AAC5C,IAAI,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,SAAS,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AACtD,IAAI,IAAI,CAAC,UAAU,GAAG,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9E,GAAG;AACH,EAAE,aAAa,CAAC,GAAG,UAAU,EAAE;AAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AACxD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,aAAa,CAAC,GAAG,UAAU,EAAE;AAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AACrF,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,OAAO;AACX,MAAM,GAAG,IAAI,CAAC,IAAI;AAClB,MAAM,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;AACxE,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 SelectMenuOption = require('./selectMenu/SelectMenuOption.cjs');
|
|
8
|
+
const validation = require('../util/validation.cjs');
|
|
9
|
+
|
|
10
|
+
const customIdValidator = shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(validation.isValidationEnabled);
|
|
11
|
+
const emojiValidator = shapeshift.s.object({
|
|
12
|
+
id: shapeshift.s.string,
|
|
13
|
+
name: shapeshift.s.string,
|
|
14
|
+
animated: shapeshift.s.boolean
|
|
15
|
+
}).partial.strict.setValidationEnabled(validation.isValidationEnabled);
|
|
16
|
+
const disabledValidator = shapeshift.s.boolean;
|
|
17
|
+
const buttonLabelValidator = shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(80).setValidationEnabled(validation.isValidationEnabled);
|
|
18
|
+
const buttonStyleValidator = shapeshift.s.nativeEnum(v10.ButtonStyle);
|
|
19
|
+
const placeholderValidator = shapeshift.s.string.lengthLessThanOrEqual(150).setValidationEnabled(validation.isValidationEnabled);
|
|
20
|
+
const minMaxValidator = shapeshift.s.number.int.greaterThanOrEqual(0).lessThanOrEqual(25).setValidationEnabled(validation.isValidationEnabled);
|
|
21
|
+
const labelValueDescriptionValidator = shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(validation.isValidationEnabled);
|
|
22
|
+
const jsonOptionValidator = shapeshift.s.object({
|
|
23
|
+
label: labelValueDescriptionValidator,
|
|
24
|
+
value: labelValueDescriptionValidator,
|
|
25
|
+
description: labelValueDescriptionValidator.optional,
|
|
26
|
+
emoji: emojiValidator.optional,
|
|
27
|
+
default: shapeshift.s.boolean.optional
|
|
28
|
+
}).setValidationEnabled(validation.isValidationEnabled);
|
|
29
|
+
const optionValidator = shapeshift.s.instance(SelectMenuOption.SelectMenuOptionBuilder).setValidationEnabled(validation.isValidationEnabled);
|
|
30
|
+
const optionsValidator = optionValidator.array.lengthGreaterThanOrEqual(0).setValidationEnabled(validation.isValidationEnabled);
|
|
31
|
+
const optionsLengthValidator = shapeshift.s.number.int.greaterThanOrEqual(0).lessThanOrEqual(25).setValidationEnabled(validation.isValidationEnabled);
|
|
32
|
+
function validateRequiredSelectMenuParameters(options, customId) {
|
|
33
|
+
customIdValidator.parse(customId);
|
|
34
|
+
optionsValidator.parse(options);
|
|
35
|
+
}
|
|
36
|
+
const defaultValidator = shapeshift.s.boolean;
|
|
37
|
+
function validateRequiredSelectMenuOptionParameters(label, value) {
|
|
38
|
+
labelValueDescriptionValidator.parse(label);
|
|
39
|
+
labelValueDescriptionValidator.parse(value);
|
|
40
|
+
}
|
|
41
|
+
const urlValidator = shapeshift.s.string.url({
|
|
42
|
+
allowedProtocols: ["http:", "https:", "discord:"]
|
|
43
|
+
}).setValidationEnabled(validation.isValidationEnabled);
|
|
44
|
+
function validateRequiredButtonParameters(style, label, emoji, customId, url) {
|
|
45
|
+
if (url && customId) {
|
|
46
|
+
throw new RangeError("URL and custom id are mutually exclusive");
|
|
47
|
+
}
|
|
48
|
+
if (!label && !emoji) {
|
|
49
|
+
throw new RangeError("Buttons must have a label and/or an emoji");
|
|
50
|
+
}
|
|
51
|
+
if (style === v10.ButtonStyle.Link) {
|
|
52
|
+
if (!url) {
|
|
53
|
+
throw new RangeError("Link buttons must have a url");
|
|
54
|
+
}
|
|
55
|
+
} else if (url) {
|
|
56
|
+
throw new RangeError("Non-link buttons cannot have a url");
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
exports.buttonLabelValidator = buttonLabelValidator;
|
|
61
|
+
exports.buttonStyleValidator = buttonStyleValidator;
|
|
62
|
+
exports.customIdValidator = customIdValidator;
|
|
63
|
+
exports.defaultValidator = defaultValidator;
|
|
64
|
+
exports.disabledValidator = disabledValidator;
|
|
65
|
+
exports.emojiValidator = emojiValidator;
|
|
66
|
+
exports.jsonOptionValidator = jsonOptionValidator;
|
|
67
|
+
exports.labelValueDescriptionValidator = labelValueDescriptionValidator;
|
|
68
|
+
exports.minMaxValidator = minMaxValidator;
|
|
69
|
+
exports.optionValidator = optionValidator;
|
|
70
|
+
exports.optionsLengthValidator = optionsLengthValidator;
|
|
71
|
+
exports.optionsValidator = optionsValidator;
|
|
72
|
+
exports.placeholderValidator = placeholderValidator;
|
|
73
|
+
exports.urlValidator = urlValidator;
|
|
74
|
+
exports.validateRequiredButtonParameters = validateRequiredButtonParameters;
|
|
75
|
+
exports.validateRequiredSelectMenuOptionParameters = validateRequiredSelectMenuOptionParameters;
|
|
76
|
+
exports.validateRequiredSelectMenuParameters = validateRequiredSelectMenuParameters;
|
|
77
|
+
//# sourceMappingURL=Assertions.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Assertions.cjs","sources":["../../src/components/Assertions.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { APIMessageComponentEmoji, ButtonStyle } from 'discord-api-types/v10';\nimport { SelectMenuOptionBuilder } from './selectMenu/SelectMenuOption';\nimport { isValidationEnabled } from '../util/validation';\n\nexport const customIdValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(100)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const emojiValidator = s\n\t.object({\n\t\tid: s.string,\n\t\tname: s.string,\n\t\tanimated: s.boolean,\n\t})\n\t.partial.strict.setValidationEnabled(isValidationEnabled);\n\nexport const disabledValidator = s.boolean;\n\nexport const buttonLabelValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(80)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const buttonStyleValidator = s.nativeEnum(ButtonStyle);\n\nexport const placeholderValidator = s.string.lengthLessThanOrEqual(150).setValidationEnabled(isValidationEnabled);\nexport const minMaxValidator = s.number.int\n\t.greaterThanOrEqual(0)\n\t.lessThanOrEqual(25)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const labelValueDescriptionValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(100)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const jsonOptionValidator = s\n\t.object({\n\t\tlabel: labelValueDescriptionValidator,\n\t\tvalue: labelValueDescriptionValidator,\n\t\tdescription: labelValueDescriptionValidator.optional,\n\t\temoji: emojiValidator.optional,\n\t\tdefault: s.boolean.optional,\n\t})\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const optionValidator = s.instance(SelectMenuOptionBuilder).setValidationEnabled(isValidationEnabled);\n\nexport const optionsValidator = optionValidator.array\n\t.lengthGreaterThanOrEqual(0)\n\t.setValidationEnabled(isValidationEnabled);\nexport const optionsLengthValidator = s.number.int\n\t.greaterThanOrEqual(0)\n\t.lessThanOrEqual(25)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredSelectMenuParameters(options: SelectMenuOptionBuilder[], customId?: string) {\n\tcustomIdValidator.parse(customId);\n\toptionsValidator.parse(options);\n}\n\nexport const defaultValidator = s.boolean;\n\nexport function validateRequiredSelectMenuOptionParameters(label?: string, value?: string) {\n\tlabelValueDescriptionValidator.parse(label);\n\tlabelValueDescriptionValidator.parse(value);\n}\n\nexport const urlValidator = s.string\n\t.url({\n\t\tallowedProtocols: ['http:', 'https:', 'discord:'],\n\t})\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredButtonParameters(\n\tstyle?: ButtonStyle,\n\tlabel?: string,\n\temoji?: APIMessageComponentEmoji,\n\tcustomId?: string,\n\turl?: string,\n) {\n\tif (url && customId) {\n\t\tthrow new RangeError('URL and custom id are mutually exclusive');\n\t}\n\n\tif (!label && !emoji) {\n\t\tthrow new RangeError('Buttons must have a label and/or an emoji');\n\t}\n\n\tif (style === ButtonStyle.Link) {\n\t\tif (!url) {\n\t\t\tthrow new RangeError('Link buttons must have a url');\n\t\t}\n\t} else if (url) {\n\t\tthrow new RangeError('Non-link buttons cannot have a url');\n\t}\n}\n"],"names":["s","isValidationEnabled","ButtonStyle","SelectMenuOptionBuilder"],"mappings":"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"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { APIMessageComponentEmoji, ButtonStyle } from 'discord-api-types/v10';
|
|
2
|
+
import { SelectMenuOptionBuilder } from './selectMenu/SelectMenuOption';
|
|
3
|
+
export declare const customIdValidator: import("@sapphire/shapeshift").StringValidator<string>;
|
|
4
|
+
export declare const emojiValidator: import("@sapphire/shapeshift").ObjectValidator<{
|
|
5
|
+
id?: string | undefined;
|
|
6
|
+
name?: string | undefined;
|
|
7
|
+
animated?: boolean | undefined;
|
|
8
|
+
}, import("@sapphire/shapeshift").UndefinedToOptional<{
|
|
9
|
+
id?: string | undefined;
|
|
10
|
+
name?: string | undefined;
|
|
11
|
+
animated?: boolean | undefined;
|
|
12
|
+
}>>;
|
|
13
|
+
export declare const disabledValidator: import("@sapphire/shapeshift").BooleanValidator<boolean>;
|
|
14
|
+
export declare const buttonLabelValidator: import("@sapphire/shapeshift").StringValidator<string>;
|
|
15
|
+
export declare const buttonStyleValidator: import("@sapphire/shapeshift").NativeEnumValidator<typeof ButtonStyle>;
|
|
16
|
+
export declare const placeholderValidator: import("@sapphire/shapeshift").StringValidator<string>;
|
|
17
|
+
export declare const minMaxValidator: import("@sapphire/shapeshift").NumberValidator<number>;
|
|
18
|
+
export declare const labelValueDescriptionValidator: import("@sapphire/shapeshift").StringValidator<string>;
|
|
19
|
+
export declare const jsonOptionValidator: import("@sapphire/shapeshift").ObjectValidator<{
|
|
20
|
+
label: string;
|
|
21
|
+
value: string;
|
|
22
|
+
description: string | undefined;
|
|
23
|
+
emoji: import("@sapphire/shapeshift").UndefinedToOptional<{
|
|
24
|
+
id?: string | undefined;
|
|
25
|
+
name?: string | undefined;
|
|
26
|
+
animated?: boolean | undefined;
|
|
27
|
+
}> | undefined;
|
|
28
|
+
default: boolean | undefined;
|
|
29
|
+
}, import("@sapphire/shapeshift").UndefinedToOptional<{
|
|
30
|
+
label: string;
|
|
31
|
+
value: string;
|
|
32
|
+
description: string | undefined;
|
|
33
|
+
emoji: import("@sapphire/shapeshift").UndefinedToOptional<{
|
|
34
|
+
id?: string | undefined;
|
|
35
|
+
name?: string | undefined;
|
|
36
|
+
animated?: boolean | undefined;
|
|
37
|
+
}> | undefined;
|
|
38
|
+
default: boolean | undefined;
|
|
39
|
+
}>>;
|
|
40
|
+
export declare const optionValidator: import("@sapphire/shapeshift").InstanceValidator<SelectMenuOptionBuilder>;
|
|
41
|
+
export declare const optionsValidator: import("@sapphire/shapeshift").ArrayValidator<SelectMenuOptionBuilder[], SelectMenuOptionBuilder>;
|
|
42
|
+
export declare const optionsLengthValidator: import("@sapphire/shapeshift").NumberValidator<number>;
|
|
43
|
+
export declare function validateRequiredSelectMenuParameters(options: SelectMenuOptionBuilder[], customId?: string): void;
|
|
44
|
+
export declare const defaultValidator: import("@sapphire/shapeshift").BooleanValidator<boolean>;
|
|
45
|
+
export declare function validateRequiredSelectMenuOptionParameters(label?: string, value?: string): void;
|
|
46
|
+
export declare const urlValidator: import("@sapphire/shapeshift").StringValidator<string>;
|
|
47
|
+
export declare function validateRequiredButtonParameters(style?: ButtonStyle, label?: string, emoji?: APIMessageComponentEmoji, customId?: string, url?: string): void;
|
|
48
|
+
//# sourceMappingURL=Assertions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Assertions.d.ts","sourceRoot":"","sources":["../../src/components/Assertions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC9E,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAGxE,eAAO,MAAM,iBAAiB,wDAGa,CAAC;AAE5C,eAAO,MAAM,cAAc;;;;;;;;GAM+B,CAAC;AAE3D,eAAO,MAAM,iBAAiB,0DAAY,CAAC;AAE3C,eAAO,MAAM,oBAAoB,wDAGU,CAAC;AAE5C,eAAO,MAAM,oBAAoB,wEAA4B,CAAC;AAE9D,eAAO,MAAM,oBAAoB,wDAAgF,CAAC;AAClH,eAAO,MAAM,eAAe,wDAGe,CAAC;AAE5C,eAAO,MAAM,8BAA8B,wDAGA,CAAC;AAE5C,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;GAQW,CAAC;AAE5C,eAAO,MAAM,eAAe,2EAAgF,CAAC;AAE7G,eAAO,MAAM,gBAAgB,mGAEc,CAAC;AAC5C,eAAO,MAAM,sBAAsB,wDAGQ,CAAC;AAE5C,wBAAgB,oCAAoC,CAAC,OAAO,EAAE,uBAAuB,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,QAGzG;AAED,eAAO,MAAM,gBAAgB,0DAAY,CAAC;AAE1C,wBAAgB,0CAA0C,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,QAGxF;AAED,eAAO,MAAM,YAAY,wDAIkB,CAAC;AAE5C,wBAAgB,gCAAgC,CAC/C,KAAK,CAAC,EAAE,WAAW,EACnB,KAAK,CAAC,EAAE,MAAM,EACd,KAAK,CAAC,EAAE,wBAAwB,EAChC,QAAQ,CAAC,EAAE,MAAM,EACjB,GAAG,CAAC,EAAE,MAAM,QAiBZ"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { s } from '@sapphire/shapeshift';
|
|
2
|
+
import { ButtonStyle } from 'discord-api-types/v10';
|
|
3
|
+
import { SelectMenuOptionBuilder } from './selectMenu/SelectMenuOption.mjs';
|
|
4
|
+
import { isValidationEnabled } from '../util/validation.mjs';
|
|
5
|
+
|
|
6
|
+
const customIdValidator = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
|
7
|
+
const emojiValidator = s.object({
|
|
8
|
+
id: s.string,
|
|
9
|
+
name: s.string,
|
|
10
|
+
animated: s.boolean
|
|
11
|
+
}).partial.strict.setValidationEnabled(isValidationEnabled);
|
|
12
|
+
const disabledValidator = s.boolean;
|
|
13
|
+
const buttonLabelValidator = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(80).setValidationEnabled(isValidationEnabled);
|
|
14
|
+
const buttonStyleValidator = s.nativeEnum(ButtonStyle);
|
|
15
|
+
const placeholderValidator = s.string.lengthLessThanOrEqual(150).setValidationEnabled(isValidationEnabled);
|
|
16
|
+
const minMaxValidator = s.number.int.greaterThanOrEqual(0).lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
|
17
|
+
const labelValueDescriptionValidator = s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);
|
|
18
|
+
const jsonOptionValidator = s.object({
|
|
19
|
+
label: labelValueDescriptionValidator,
|
|
20
|
+
value: labelValueDescriptionValidator,
|
|
21
|
+
description: labelValueDescriptionValidator.optional,
|
|
22
|
+
emoji: emojiValidator.optional,
|
|
23
|
+
default: s.boolean.optional
|
|
24
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
25
|
+
const optionValidator = s.instance(SelectMenuOptionBuilder).setValidationEnabled(isValidationEnabled);
|
|
26
|
+
const optionsValidator = optionValidator.array.lengthGreaterThanOrEqual(0).setValidationEnabled(isValidationEnabled);
|
|
27
|
+
const optionsLengthValidator = s.number.int.greaterThanOrEqual(0).lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);
|
|
28
|
+
function validateRequiredSelectMenuParameters(options, customId) {
|
|
29
|
+
customIdValidator.parse(customId);
|
|
30
|
+
optionsValidator.parse(options);
|
|
31
|
+
}
|
|
32
|
+
const defaultValidator = s.boolean;
|
|
33
|
+
function validateRequiredSelectMenuOptionParameters(label, value) {
|
|
34
|
+
labelValueDescriptionValidator.parse(label);
|
|
35
|
+
labelValueDescriptionValidator.parse(value);
|
|
36
|
+
}
|
|
37
|
+
const urlValidator = s.string.url({
|
|
38
|
+
allowedProtocols: ["http:", "https:", "discord:"]
|
|
39
|
+
}).setValidationEnabled(isValidationEnabled);
|
|
40
|
+
function validateRequiredButtonParameters(style, label, emoji, customId, url) {
|
|
41
|
+
if (url && customId) {
|
|
42
|
+
throw new RangeError("URL and custom id are mutually exclusive");
|
|
43
|
+
}
|
|
44
|
+
if (!label && !emoji) {
|
|
45
|
+
throw new RangeError("Buttons must have a label and/or an emoji");
|
|
46
|
+
}
|
|
47
|
+
if (style === ButtonStyle.Link) {
|
|
48
|
+
if (!url) {
|
|
49
|
+
throw new RangeError("Link buttons must have a url");
|
|
50
|
+
}
|
|
51
|
+
} else if (url) {
|
|
52
|
+
throw new RangeError("Non-link buttons cannot have a url");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export { buttonLabelValidator, buttonStyleValidator, customIdValidator, defaultValidator, disabledValidator, emojiValidator, jsonOptionValidator, labelValueDescriptionValidator, minMaxValidator, optionValidator, optionsLengthValidator, optionsValidator, placeholderValidator, urlValidator, validateRequiredButtonParameters, validateRequiredSelectMenuOptionParameters, validateRequiredSelectMenuParameters };
|
|
57
|
+
//# sourceMappingURL=Assertions.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Assertions.mjs","sources":["../../src/components/Assertions.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { APIMessageComponentEmoji, ButtonStyle } from 'discord-api-types/v10';\nimport { SelectMenuOptionBuilder } from './selectMenu/SelectMenuOption';\nimport { isValidationEnabled } from '../util/validation';\n\nexport const customIdValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(100)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const emojiValidator = s\n\t.object({\n\t\tid: s.string,\n\t\tname: s.string,\n\t\tanimated: s.boolean,\n\t})\n\t.partial.strict.setValidationEnabled(isValidationEnabled);\n\nexport const disabledValidator = s.boolean;\n\nexport const buttonLabelValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(80)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const buttonStyleValidator = s.nativeEnum(ButtonStyle);\n\nexport const placeholderValidator = s.string.lengthLessThanOrEqual(150).setValidationEnabled(isValidationEnabled);\nexport const minMaxValidator = s.number.int\n\t.greaterThanOrEqual(0)\n\t.lessThanOrEqual(25)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const labelValueDescriptionValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(100)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const jsonOptionValidator = s\n\t.object({\n\t\tlabel: labelValueDescriptionValidator,\n\t\tvalue: labelValueDescriptionValidator,\n\t\tdescription: labelValueDescriptionValidator.optional,\n\t\temoji: emojiValidator.optional,\n\t\tdefault: s.boolean.optional,\n\t})\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const optionValidator = s.instance(SelectMenuOptionBuilder).setValidationEnabled(isValidationEnabled);\n\nexport const optionsValidator = optionValidator.array\n\t.lengthGreaterThanOrEqual(0)\n\t.setValidationEnabled(isValidationEnabled);\nexport const optionsLengthValidator = s.number.int\n\t.greaterThanOrEqual(0)\n\t.lessThanOrEqual(25)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredSelectMenuParameters(options: SelectMenuOptionBuilder[], customId?: string) {\n\tcustomIdValidator.parse(customId);\n\toptionsValidator.parse(options);\n}\n\nexport const defaultValidator = s.boolean;\n\nexport function validateRequiredSelectMenuOptionParameters(label?: string, value?: string) {\n\tlabelValueDescriptionValidator.parse(label);\n\tlabelValueDescriptionValidator.parse(value);\n}\n\nexport const urlValidator = s.string\n\t.url({\n\t\tallowedProtocols: ['http:', 'https:', 'discord:'],\n\t})\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredButtonParameters(\n\tstyle?: ButtonStyle,\n\tlabel?: string,\n\temoji?: APIMessageComponentEmoji,\n\tcustomId?: string,\n\turl?: string,\n) {\n\tif (url && customId) {\n\t\tthrow new RangeError('URL and custom id are mutually exclusive');\n\t}\n\n\tif (!label && !emoji) {\n\t\tthrow new RangeError('Buttons must have a label and/or an emoji');\n\t}\n\n\tif (style === ButtonStyle.Link) {\n\t\tif (!url) {\n\t\t\tthrow new RangeError('Link buttons must have a url');\n\t\t}\n\t} else if (url) {\n\t\tthrow new RangeError('Non-link buttons cannot have a url');\n\t}\n}\n"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Component.cjs","sources":["../../src/components/Component.ts"],"sourcesContent":["import type {\n\tAPIActionRowComponent,\n\tAPIActionRowComponentTypes,\n\tAPIBaseComponent,\n\tComponentType,\n} from 'discord-api-types/v10';\nimport type { JSONEncodable } from '../util/jsonEncodable';\n\nexport type AnyAPIActionRowComponent = APIActionRowComponentTypes | APIActionRowComponent<APIActionRowComponentTypes>;\n\n/**\n * Represents a discord component\n */\nexport abstract class ComponentBuilder<\n\tDataType extends Partial<APIBaseComponent<ComponentType>> = APIBaseComponent<ComponentType>,\n> implements JSONEncodable<AnyAPIActionRowComponent>\n{\n\t/**\n\t * The API data associated with this component\n\t */\n\tpublic readonly data: Partial<DataType>;\n\n\tpublic abstract toJSON(): AnyAPIActionRowComponent;\n\n\tpublic constructor(data: Partial<DataType>) {\n\t\tthis.data = data;\n\t}\n}\n"],"names":[],"mappings":";;;;AAAO,MAAM,gBAAgB,CAAC;AAC9B,EAAE,WAAW,CAAC,IAAI,EAAE;AACpB,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACrB,GAAG;AACH;;;;"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { APIActionRowComponent, APIActionRowComponentTypes, APIBaseComponent, ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import type { JSONEncodable } from '../util/jsonEncodable';
|
|
3
|
+
export declare type AnyAPIActionRowComponent = APIActionRowComponentTypes | APIActionRowComponent<APIActionRowComponentTypes>;
|
|
4
|
+
/**
|
|
5
|
+
* Represents a discord component
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class ComponentBuilder<DataType extends Partial<APIBaseComponent<ComponentType>> = APIBaseComponent<ComponentType>> implements JSONEncodable<AnyAPIActionRowComponent> {
|
|
8
|
+
/**
|
|
9
|
+
* The API data associated with this component
|
|
10
|
+
*/
|
|
11
|
+
readonly data: Partial<DataType>;
|
|
12
|
+
abstract toJSON(): AnyAPIActionRowComponent;
|
|
13
|
+
constructor(data: Partial<DataType>);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=Component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Component.d.ts","sourceRoot":"","sources":["../../src/components/Component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,qBAAqB,EACrB,0BAA0B,EAC1B,gBAAgB,EAChB,aAAa,EACb,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,oBAAY,wBAAwB,GAAG,0BAA0B,GAAG,qBAAqB,CAAC,0BAA0B,CAAC,CAAC;AAEtH;;GAEG;AACH,8BAAsB,gBAAgB,CACrC,QAAQ,SAAS,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,GAAG,gBAAgB,CAAC,aAAa,CAAC,CAC1F,YAAW,aAAa,CAAC,wBAAwB,CAAC;IAEnD;;OAEG;IACH,SAAgB,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;aAExB,MAAM,IAAI,wBAAwB;gBAE/B,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC;CAG1C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Component.mjs","sources":["../../src/components/Component.ts"],"sourcesContent":["import type {\n\tAPIActionRowComponent,\n\tAPIActionRowComponentTypes,\n\tAPIBaseComponent,\n\tComponentType,\n} from 'discord-api-types/v10';\nimport type { JSONEncodable } from '../util/jsonEncodable';\n\nexport type AnyAPIActionRowComponent = APIActionRowComponentTypes | APIActionRowComponent<APIActionRowComponentTypes>;\n\n/**\n * Represents a discord component\n */\nexport abstract class ComponentBuilder<\n\tDataType extends Partial<APIBaseComponent<ComponentType>> = APIBaseComponent<ComponentType>,\n> implements JSONEncodable<AnyAPIActionRowComponent>\n{\n\t/**\n\t * The API data associated with this component\n\t */\n\tpublic readonly data: Partial<DataType>;\n\n\tpublic abstract toJSON(): AnyAPIActionRowComponent;\n\n\tpublic constructor(data: Partial<DataType>) {\n\t\tthis.data = data;\n\t}\n}\n"],"names":[],"mappings":"AAAO,MAAM,gBAAgB,CAAC;AAC9B,EAAE,WAAW,CAAC,IAAI,EAAE;AACpB,IAAI,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;AACrB,GAAG;AACH;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const v10 = require('discord-api-types/v10');
|
|
6
|
+
const ActionRow = require('./ActionRow.cjs');
|
|
7
|
+
const Component = require('./Component.cjs');
|
|
8
|
+
const Button = require('./button/Button.cjs');
|
|
9
|
+
const SelectMenu = require('./selectMenu/SelectMenu.cjs');
|
|
10
|
+
const TextInput = require('./textInput/TextInput.cjs');
|
|
11
|
+
|
|
12
|
+
function createComponentBuilder(data) {
|
|
13
|
+
if (data instanceof Component.ComponentBuilder) {
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
switch (data.type) {
|
|
17
|
+
case v10.ComponentType.ActionRow:
|
|
18
|
+
return new ActionRow.ActionRowBuilder(data);
|
|
19
|
+
case v10.ComponentType.Button:
|
|
20
|
+
return new Button.ButtonBuilder(data);
|
|
21
|
+
case v10.ComponentType.SelectMenu:
|
|
22
|
+
return new SelectMenu.SelectMenuBuilder(data);
|
|
23
|
+
case v10.ComponentType.TextInput:
|
|
24
|
+
return new TextInput.TextInputBuilder(data);
|
|
25
|
+
default:
|
|
26
|
+
throw new Error(`Cannot properly serialize component type: ${data.type}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
exports.createComponentBuilder = createComponentBuilder;
|
|
31
|
+
//# sourceMappingURL=Components.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Components.cjs","sources":["../../src/components/Components.ts"],"sourcesContent":["import { APIMessageComponent, APIModalComponent, ComponentType } from 'discord-api-types/v10';\nimport {\n\tActionRowBuilder,\n\ttype AnyComponentBuilder,\n\ttype MessageComponentBuilder,\n\ttype ModalComponentBuilder,\n} from './ActionRow';\nimport { ComponentBuilder } from './Component';\nimport { ButtonBuilder } from './button/Button';\nimport { SelectMenuBuilder } from './selectMenu/SelectMenu';\nimport { TextInputBuilder } from './textInput/TextInput';\n\nexport interface MappedComponentTypes {\n\t[ComponentType.ActionRow]: ActionRowBuilder<AnyComponentBuilder>;\n\t[ComponentType.Button]: ButtonBuilder;\n\t[ComponentType.SelectMenu]: SelectMenuBuilder;\n\t[ComponentType.TextInput]: TextInputBuilder;\n}\n\n/**\n * Factory for creating components from API data\n *\n * @param data - The api data to transform to a component class\n */\nexport function createComponentBuilder<T extends keyof MappedComponentTypes>(\n\tdata: (APIMessageComponent | APIModalComponent) & { type: T },\n): MappedComponentTypes[T];\nexport function createComponentBuilder<C extends MessageComponentBuilder | ModalComponentBuilder>(data: C): C;\nexport function createComponentBuilder(\n\tdata: APIMessageComponent | APIModalComponent | MessageComponentBuilder,\n): ComponentBuilder {\n\tif (data instanceof ComponentBuilder) {\n\t\treturn data;\n\t}\n\n\tswitch (data.type) {\n\t\tcase ComponentType.ActionRow:\n\t\t\treturn new ActionRowBuilder(data);\n\t\tcase ComponentType.Button:\n\t\t\treturn new ButtonBuilder(data);\n\t\tcase ComponentType.SelectMenu:\n\t\t\treturn new SelectMenuBuilder(data);\n\t\tcase ComponentType.TextInput:\n\t\t\treturn new TextInputBuilder(data);\n\t\tdefault:\n\t\t\t// @ts-expect-error\n\t\t\t// eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n\t\t\tthrow new Error(`Cannot properly serialize component type: ${data.type}`);\n\t}\n}\n"],"names":["ComponentBuilder","ComponentType","ActionRowBuilder","ButtonBuilder","SelectMenuBuilder","TextInputBuilder"],"mappings":";;;;;;;;;;;AAQO,SAAS,sBAAsB,CAAC,IAAI,EAAE;AAC7C,EAAE,IAAI,IAAI,YAAYA,0BAAgB,EAAE;AACxC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,IAAI,CAAC,IAAI;AACnB,IAAI,KAAKC,iBAAa,CAAC,SAAS;AAChC,MAAM,OAAO,IAAIC,0BAAgB,CAAC,IAAI,CAAC,CAAC;AACxC,IAAI,KAAKD,iBAAa,CAAC,MAAM;AAC7B,MAAM,OAAO,IAAIE,oBAAa,CAAC,IAAI,CAAC,CAAC;AACrC,IAAI,KAAKF,iBAAa,CAAC,UAAU;AACjC,MAAM,OAAO,IAAIG,4BAAiB,CAAC,IAAI,CAAC,CAAC;AACzC,IAAI,KAAKH,iBAAa,CAAC,SAAS;AAChC,MAAM,OAAO,IAAII,0BAAgB,CAAC,IAAI,CAAC,CAAC;AACxC,IAAI;AACJ,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC,0CAA0C,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAChF,GAAG;AACH;;;;"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { APIMessageComponent, APIModalComponent, ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import { ActionRowBuilder, type AnyComponentBuilder, type MessageComponentBuilder, type ModalComponentBuilder } from './ActionRow';
|
|
3
|
+
import { ButtonBuilder } from './button/Button';
|
|
4
|
+
import { SelectMenuBuilder } from './selectMenu/SelectMenu';
|
|
5
|
+
import { TextInputBuilder } from './textInput/TextInput';
|
|
6
|
+
export interface MappedComponentTypes {
|
|
7
|
+
[ComponentType.ActionRow]: ActionRowBuilder<AnyComponentBuilder>;
|
|
8
|
+
[ComponentType.Button]: ButtonBuilder;
|
|
9
|
+
[ComponentType.SelectMenu]: SelectMenuBuilder;
|
|
10
|
+
[ComponentType.TextInput]: TextInputBuilder;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Factory for creating components from API data
|
|
14
|
+
*
|
|
15
|
+
* @param data - The api data to transform to a component class
|
|
16
|
+
*/
|
|
17
|
+
export declare function createComponentBuilder<T extends keyof MappedComponentTypes>(data: (APIMessageComponent | APIModalComponent) & {
|
|
18
|
+
type: T;
|
|
19
|
+
}): MappedComponentTypes[T];
|
|
20
|
+
export declare function createComponentBuilder<C extends MessageComponentBuilder | ModalComponentBuilder>(data: C): C;
|
|
21
|
+
//# sourceMappingURL=Components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Components.d.ts","sourceRoot":"","sources":["../../src/components/Components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EACN,gBAAgB,EAChB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAEzD,MAAM,WAAW,oBAAoB;IACpC,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC,mBAAmB,CAAC,CAAC;IACjE,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC;IACtC,CAAC,aAAa,CAAC,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC9C,CAAC,aAAa,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC;CAC5C;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,MAAM,oBAAoB,EAC1E,IAAI,EAAE,CAAC,mBAAmB,GAAG,iBAAiB,CAAC,GAAG;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,GAC3D,oBAAoB,CAAC,CAAC,CAAC,CAAC;AAC3B,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,uBAAuB,GAAG,qBAAqB,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ComponentType } from 'discord-api-types/v10';
|
|
2
|
+
import { ActionRowBuilder } from './ActionRow.mjs';
|
|
3
|
+
import { ComponentBuilder } from './Component.mjs';
|
|
4
|
+
import { ButtonBuilder } from './button/Button.mjs';
|
|
5
|
+
import { SelectMenuBuilder } from './selectMenu/SelectMenu.mjs';
|
|
6
|
+
import { TextInputBuilder } from './textInput/TextInput.mjs';
|
|
7
|
+
|
|
8
|
+
function createComponentBuilder(data) {
|
|
9
|
+
if (data instanceof ComponentBuilder) {
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
switch (data.type) {
|
|
13
|
+
case ComponentType.ActionRow:
|
|
14
|
+
return new ActionRowBuilder(data);
|
|
15
|
+
case ComponentType.Button:
|
|
16
|
+
return new ButtonBuilder(data);
|
|
17
|
+
case ComponentType.SelectMenu:
|
|
18
|
+
return new SelectMenuBuilder(data);
|
|
19
|
+
case ComponentType.TextInput:
|
|
20
|
+
return new TextInputBuilder(data);
|
|
21
|
+
default:
|
|
22
|
+
throw new Error(`Cannot properly serialize component type: ${data.type}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export { createComponentBuilder };
|
|
27
|
+
//# sourceMappingURL=Components.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Components.mjs","sources":["../../src/components/Components.ts"],"sourcesContent":["import { APIMessageComponent, APIModalComponent, ComponentType } from 'discord-api-types/v10';\nimport {\n\tActionRowBuilder,\n\ttype AnyComponentBuilder,\n\ttype MessageComponentBuilder,\n\ttype ModalComponentBuilder,\n} from './ActionRow';\nimport { ComponentBuilder } from './Component';\nimport { ButtonBuilder } from './button/Button';\nimport { SelectMenuBuilder } from './selectMenu/SelectMenu';\nimport { TextInputBuilder } from './textInput/TextInput';\n\nexport interface MappedComponentTypes {\n\t[ComponentType.ActionRow]: ActionRowBuilder<AnyComponentBuilder>;\n\t[ComponentType.Button]: ButtonBuilder;\n\t[ComponentType.SelectMenu]: SelectMenuBuilder;\n\t[ComponentType.TextInput]: TextInputBuilder;\n}\n\n/**\n * Factory for creating components from API data\n *\n * @param data - The api data to transform to a component class\n */\nexport function createComponentBuilder<T extends keyof MappedComponentTypes>(\n\tdata: (APIMessageComponent | APIModalComponent) & { type: T },\n): MappedComponentTypes[T];\nexport function createComponentBuilder<C extends MessageComponentBuilder | ModalComponentBuilder>(data: C): C;\nexport function createComponentBuilder(\n\tdata: APIMessageComponent | APIModalComponent | MessageComponentBuilder,\n): ComponentBuilder {\n\tif (data instanceof ComponentBuilder) {\n\t\treturn data;\n\t}\n\n\tswitch (data.type) {\n\t\tcase ComponentType.ActionRow:\n\t\t\treturn new ActionRowBuilder(data);\n\t\tcase ComponentType.Button:\n\t\t\treturn new ButtonBuilder(data);\n\t\tcase ComponentType.SelectMenu:\n\t\t\treturn new SelectMenuBuilder(data);\n\t\tcase ComponentType.TextInput:\n\t\t\treturn new TextInputBuilder(data);\n\t\tdefault:\n\t\t\t// @ts-expect-error\n\t\t\t// eslint-disable-next-line @typescript-eslint/restrict-template-expressions\n\t\t\tthrow new Error(`Cannot properly serialize component type: ${data.type}`);\n\t}\n}\n"],"names":[],"mappings":";;;;;;;AAQO,SAAS,sBAAsB,CAAC,IAAI,EAAE;AAC7C,EAAE,IAAI,IAAI,YAAY,gBAAgB,EAAE;AACxC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,IAAI,CAAC,IAAI;AACnB,IAAI,KAAK,aAAa,CAAC,SAAS;AAChC,MAAM,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;AACxC,IAAI,KAAK,aAAa,CAAC,MAAM;AAC7B,MAAM,OAAO,IAAI,aAAa,CAAC,IAAI,CAAC,CAAC;AACrC,IAAI,KAAK,aAAa,CAAC,UAAU;AACjC,MAAM,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;AACzC,IAAI,KAAK,aAAa,CAAC,SAAS;AAChC,MAAM,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAC;AACxC,IAAI;AACJ,MAAM,MAAM,IAAI,KAAK,CAAC,CAAC,0CAA0C,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAChF,GAAG;AACH;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const v10 = require('discord-api-types/v10');
|
|
6
|
+
const Assertions = require('../Assertions.cjs');
|
|
7
|
+
const Component = require('../Component.cjs');
|
|
8
|
+
|
|
9
|
+
class ButtonBuilder extends Component.ComponentBuilder {
|
|
10
|
+
constructor(data) {
|
|
11
|
+
super({ type: v10.ComponentType.Button, ...data });
|
|
12
|
+
}
|
|
13
|
+
setStyle(style) {
|
|
14
|
+
this.data.style = Assertions.buttonStyleValidator.parse(style);
|
|
15
|
+
return this;
|
|
16
|
+
}
|
|
17
|
+
setURL(url) {
|
|
18
|
+
this.data.url = Assertions.urlValidator.parse(url);
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
setCustomId(customId) {
|
|
22
|
+
this.data.custom_id = Assertions.customIdValidator.parse(customId);
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
setEmoji(emoji) {
|
|
26
|
+
this.data.emoji = Assertions.emojiValidator.parse(emoji);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
setDisabled(disabled = true) {
|
|
30
|
+
this.data.disabled = Assertions.disabledValidator.parse(disabled);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
setLabel(label) {
|
|
34
|
+
this.data.label = Assertions.buttonLabelValidator.parse(label);
|
|
35
|
+
return this;
|
|
36
|
+
}
|
|
37
|
+
toJSON() {
|
|
38
|
+
Assertions.validateRequiredButtonParameters(this.data.style, this.data.label, this.data.emoji, this.data.custom_id, this.data.url);
|
|
39
|
+
return {
|
|
40
|
+
...this.data
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
exports.ButtonBuilder = ButtonBuilder;
|
|
46
|
+
//# sourceMappingURL=Button.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Button.cjs","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":["ComponentBuilder","ComponentType","buttonStyleValidator","urlValidator","customIdValidator","emojiValidator","disabledValidator","buttonLabelValidator","validateRequiredButtonParameters"],"mappings":";;;;;;;;AAaO,MAAM,aAAa,SAASA,0BAAgB,CAAC;AACpD,EAAE,WAAW,CAAC,IAAI,EAAE;AACpB,IAAI,KAAK,CAAC,EAAE,IAAI,EAAEC,iBAAa,CAAC,MAAM,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AACnD,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAGC,+BAAoB,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,GAAGC,uBAAY,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,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,yBAAc,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,4BAAiB,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,GAAGC,+BAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AACxD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAIC,2CAAgC,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;;;;"}
|