@discordjs/builders 1.2.0-dev.1660997042-8028813.0 → 1.3.0-dev.1661213491-2ecb862.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 +13 -0
- package/dist/components/ActionRow.cjs.map +1 -1
- package/dist/components/ActionRow.d.ts +1 -1
- package/dist/components/ActionRow.mjs.map +1 -1
- package/dist/components/Component.cjs.map +1 -1
- package/dist/components/Component.d.ts +5 -1
- package/dist/components/Component.d.ts.map +1 -1
- package/dist/components/Component.mjs.map +1 -1
- package/dist/components/button/Button.cjs.map +1 -1
- package/dist/components/button/Button.d.ts +37 -1
- package/dist/components/button/Button.d.ts.map +1 -1
- package/dist/components/button/Button.mjs.map +1 -1
- package/dist/components/selectMenu/SelectMenu.cjs.map +1 -1
- package/dist/components/selectMenu/SelectMenu.d.ts +1 -1
- package/dist/components/selectMenu/SelectMenu.mjs.map +1 -1
- package/dist/components/selectMenu/SelectMenuOption.cjs.map +1 -1
- package/dist/components/selectMenu/SelectMenuOption.d.ts +1 -1
- package/dist/components/selectMenu/SelectMenuOption.mjs.map +1 -1
- package/dist/components/textInput/TextInput.cjs.map +1 -1
- package/dist/components/textInput/TextInput.d.ts +1 -1
- package/dist/components/textInput/TextInput.mjs.map +1 -1
- package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.cjs.map +1 -1
- package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.d.ts +2 -2
- package/dist/interactions/contextMenuCommands/ContextMenuCommandBuilder.mjs.map +1 -1
- package/dist/interactions/modals/Modal.cjs.map +1 -1
- package/dist/interactions/modals/Modal.d.ts +3 -0
- package/dist/interactions/modals/Modal.d.ts.map +1 -1
- package/dist/interactions/modals/Modal.mjs.map +1 -1
- package/dist/interactions/slashCommands/options/integer.cjs.map +1 -1
- package/dist/interactions/slashCommands/options/integer.d.ts +6 -0
- package/dist/interactions/slashCommands/options/integer.d.ts.map +1 -1
- package/dist/interactions/slashCommands/options/integer.mjs.map +1 -1
- package/dist/interactions/slashCommands/options/number.cjs.map +1 -1
- package/dist/interactions/slashCommands/options/number.d.ts +6 -0
- package/dist/interactions/slashCommands/options/number.d.ts.map +1 -1
- package/dist/interactions/slashCommands/options/number.mjs.map +1 -1
- package/dist/messages/embed/Embed.cjs.map +1 -1
- package/dist/messages/embed/Embed.d.ts +14 -14
- package/dist/messages/embed/Embed.mjs.map +1 -1
- package/package.json +14 -13
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
# [@discordjs/builders@1.2.0](https://github.com/discordjs/discord.js/compare/@discordjs/builders@1.1.0...@discordjs/builders@1.2.0) - (2022-08-22)
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **website:** Show `constructor` information (#8540) ([e42fd16](https://github.com/discordjs/discord.js/commit/e42fd1636973b10dd7ed6fb4280ee1a4a8f82007))
|
|
10
|
+
- **website:** Show descriptions for `@typeParam` blocks (#8523) ([e475b63](https://github.com/discordjs/discord.js/commit/e475b63f257f6261d73cb89fee9ecbcdd84e2a6b))
|
|
11
|
+
- **website:** Show parameter descriptions (#8519) ([7f415a2](https://github.com/discordjs/discord.js/commit/7f415a2502bf7ce2025dbcfed9017b0635a19966))
|
|
12
|
+
- **WebSocketShard:** Support new resume url (#8480) ([bc06cc6](https://github.com/discordjs/discord.js/commit/bc06cc638d2f57ab5c600e8cdb6afc8eb2180166))
|
|
13
|
+
|
|
14
|
+
## Refactor
|
|
15
|
+
|
|
16
|
+
- Docs design (#8487) ([4ab1d09](https://github.com/discordjs/discord.js/commit/4ab1d09997a18879a9eb9bda39df6f15aa22557e))
|
|
17
|
+
|
|
5
18
|
# [@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
19
|
|
|
7
20
|
## Bug Fixes
|
|
@@ -1 +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 *\n * @typeParam T - The types of components this action row holds\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\t/**\n\t * {@inheritDoc
|
|
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 *\n * @typeParam T - The types of components this action row holds\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\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\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;;;;"}
|
|
@@ -33,7 +33,7 @@ export declare class ActionRowBuilder<T extends AnyComponentBuilder> extends Com
|
|
|
33
33
|
*/
|
|
34
34
|
setComponents(...components: RestOrArray<T>): this;
|
|
35
35
|
/**
|
|
36
|
-
* {@inheritDoc
|
|
36
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
37
37
|
*/
|
|
38
38
|
toJSON(): APIActionRowComponent<ReturnType<T['toJSON']>>;
|
|
39
39
|
}
|
|
@@ -1 +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 *\n * @typeParam T - The types of components this action row holds\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\t/**\n\t * {@inheritDoc
|
|
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 *\n * @typeParam T - The types of components this action row holds\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\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\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;;;;"}
|
|
@@ -1 +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 *\n * @typeParam DataType - The type of internal API data that is stored within the 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\t/**\n\t *
|
|
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 *\n * @typeParam DataType - The type of internal API data that is stored within the 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\t/**\n\t * Serializes this component to an API-compatible JSON object\n\t *\n\t * @remarks\n\t * This method runs validations on the data before serializing it.\n\t * As such, it may throw an error if the data is invalid.\n\t */\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;;;;"}
|
|
@@ -12,7 +12,11 @@ export declare abstract class ComponentBuilder<DataType extends Partial<APIBaseC
|
|
|
12
12
|
*/
|
|
13
13
|
readonly data: Partial<DataType>;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Serializes this component to an API-compatible JSON object
|
|
16
|
+
*
|
|
17
|
+
* @remarks
|
|
18
|
+
* This method runs validations on the data before serializing it.
|
|
19
|
+
* As such, it may throw an error if the data is invalid.
|
|
16
20
|
*/
|
|
17
21
|
abstract toJSON(): AnyAPIActionRowComponent;
|
|
18
22
|
constructor(data: Partial<DataType>);
|
|
@@ -1 +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;;;;GAIG;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;IAExC
|
|
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;;;;GAIG;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;IAExC;;;;;;OAMG;aACa,MAAM,IAAI,wBAAwB;gBAE/B,IAAI,EAAE,OAAO,CAAC,QAAQ,CAAC;CAG1C"}
|
|
@@ -1 +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 *\n * @typeParam DataType - The type of internal API data that is stored within the 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\t/**\n\t *
|
|
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 *\n * @typeParam DataType - The type of internal API data that is stored within the 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\t/**\n\t * Serializes this component to an API-compatible JSON object\n\t *\n\t * @remarks\n\t * This method runs validations on the data before serializing it.\n\t * As such, it may throw an error if the data is invalid.\n\t */\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;;;;"}
|
|
@@ -1 +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\t/**\n\t * {@inheritDoc
|
|
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\t/**\n\t * Creates a new button from API data\n\t * @param data - The API data to create this button with\n\t *\n\t * @example\n\t * Creating a button from an API data object\n\t * ```ts\n\t * const button = new ButtonBuilder({\n\t * \tstyle: 'primary',\n\t * \tlabel: 'Click Me',\n\t * \temoji: {\n\t * \t\tname: ':smile:',\n\t * \t\tid: '12345678901234567890123456789012',\n\t * \t},\n\t * custom_id: '12345678901234567890123456789012',\n\t * });\n\t * ```\n\t *\n\t * @example\n\t * Creating a button using setters and API data\n\t * ```ts\n\t * const button = new ButtonBuilder({\n\t * \tstyle: 'primary',\n\t * \tlabel: 'Click Me',\n\t * })\n\t * .setEmoji({ name: ':smile:', id: '12345678901234567890123456789012' })\n\t * .setCustomId('12345678901234567890123456789012');\n\t * ```\n\t */\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 * @remarks\n\t * This method is only available to buttons using the `Link` button style.\n\t * Only three types of URL schemes are currently supported: `https://`, `http://` and `discord://`\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 * @remarks\n\t * This method is only applicable to buttons that are not using the `Link` button style.\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\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\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;AACpC,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK;AACrB,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK;AACrB,MAAM,IAAI,CAAC,IAAI,CAAC,KAAK;AACrB,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS;AACzB,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG;AACnB,KAAK,CAAC;AACN,IAAI,OAAO;AACX,MAAM,GAAG,IAAI,CAAC,IAAI;AAClB,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
|
|
@@ -4,6 +4,35 @@ import { ComponentBuilder } from '../Component';
|
|
|
4
4
|
* Represents a button component
|
|
5
5
|
*/
|
|
6
6
|
export declare class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new button from API data
|
|
9
|
+
* @param data - The API data to create this button with
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* Creating a button from an API data object
|
|
13
|
+
* ```ts
|
|
14
|
+
* const button = new ButtonBuilder({
|
|
15
|
+
* style: 'primary',
|
|
16
|
+
* label: 'Click Me',
|
|
17
|
+
* emoji: {
|
|
18
|
+
* name: ':smile:',
|
|
19
|
+
* id: '12345678901234567890123456789012',
|
|
20
|
+
* },
|
|
21
|
+
* custom_id: '12345678901234567890123456789012',
|
|
22
|
+
* });
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* Creating a button using setters and API data
|
|
27
|
+
* ```ts
|
|
28
|
+
* const button = new ButtonBuilder({
|
|
29
|
+
* style: 'primary',
|
|
30
|
+
* label: 'Click Me',
|
|
31
|
+
* })
|
|
32
|
+
* .setEmoji({ name: ':smile:', id: '12345678901234567890123456789012' })
|
|
33
|
+
* .setCustomId('12345678901234567890123456789012');
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
7
36
|
constructor(data?: Partial<APIButtonComponent>);
|
|
8
37
|
/**
|
|
9
38
|
* Sets the style of this button
|
|
@@ -14,12 +43,19 @@ export declare class ButtonBuilder extends ComponentBuilder<APIButtonComponent>
|
|
|
14
43
|
/**
|
|
15
44
|
* Sets the URL for this button
|
|
16
45
|
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* This method is only available to buttons using the `Link` button style.
|
|
48
|
+
* Only three types of URL schemes are currently supported: `https://`, `http://` and `discord://`
|
|
49
|
+
*
|
|
17
50
|
* @param url - The URL to open when this button is clicked
|
|
18
51
|
*/
|
|
19
52
|
setURL(url: string): this;
|
|
20
53
|
/**
|
|
21
54
|
* Sets the custom id for this button
|
|
22
55
|
*
|
|
56
|
+
* @remarks
|
|
57
|
+
* This method is only applicable to buttons that are not using the `Link` button style.
|
|
58
|
+
*
|
|
23
59
|
* @param customId - The custom id to use for this button
|
|
24
60
|
*/
|
|
25
61
|
setCustomId(customId: string): this;
|
|
@@ -42,7 +78,7 @@ export declare class ButtonBuilder extends ComponentBuilder<APIButtonComponent>
|
|
|
42
78
|
*/
|
|
43
79
|
setLabel(label: string): this;
|
|
44
80
|
/**
|
|
45
|
-
* {@inheritDoc
|
|
81
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
46
82
|
*/
|
|
47
83
|
toJSON(): APIButtonComponent;
|
|
48
84
|
}
|
|
@@ -1 +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;
|
|
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;IACtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA4BG;gBACgB,IAAI,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAIrD;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EAAE,WAAW;IAKlC;;;;;;;;OAQG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM;IAKzB;;;;;;;OAOG;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;IAK7B;;OAEG;IACI,MAAM,IAAI,kBAAkB;CAanC"}
|
|
@@ -1 +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\t/**\n\t * {@inheritDoc
|
|
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\t/**\n\t * Creates a new button from API data\n\t * @param data - The API data to create this button with\n\t *\n\t * @example\n\t * Creating a button from an API data object\n\t * ```ts\n\t * const button = new ButtonBuilder({\n\t * \tstyle: 'primary',\n\t * \tlabel: 'Click Me',\n\t * \temoji: {\n\t * \t\tname: ':smile:',\n\t * \t\tid: '12345678901234567890123456789012',\n\t * \t},\n\t * custom_id: '12345678901234567890123456789012',\n\t * });\n\t * ```\n\t *\n\t * @example\n\t * Creating a button using setters and API data\n\t * ```ts\n\t * const button = new ButtonBuilder({\n\t * \tstyle: 'primary',\n\t * \tlabel: 'Click Me',\n\t * })\n\t * .setEmoji({ name: ':smile:', id: '12345678901234567890123456789012' })\n\t * .setCustomId('12345678901234567890123456789012');\n\t * ```\n\t */\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 * @remarks\n\t * This method is only available to buttons using the `Link` button style.\n\t * Only three types of URL schemes are currently supported: `https://`, `http://` and `discord://`\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 * @remarks\n\t * This method is only applicable to buttons that are not using the `Link` button style.\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\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\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,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AACN,GAAG;AACH;;;;"}
|
|
@@ -1 +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\tjsonOptionValidator,\n\tminMaxValidator,\n\toptionsLengthValidator,\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(jsonOptionValidator.parse(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(jsonOptionValidator.parse(option)),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc
|
|
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\tjsonOptionValidator,\n\tminMaxValidator,\n\toptionsLengthValidator,\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(jsonOptionValidator.parse(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(jsonOptionValidator.parse(option)),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\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","jsonOptionValidator","validateRequiredSelectMenuParameters"],"mappings":";;;;;;;;;;AAaO,MAAM,iBAAiB,SAASA,0BAAgB,CAAC;AACxD,EAAE,WAAW,CAAC,IAAI,EAAE;AACpB,IAAI,MAAM,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,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G;AACH;;;;"}
|
|
@@ -55,7 +55,7 @@ export declare class SelectMenuBuilder extends ComponentBuilder<APISelectMenuCom
|
|
|
55
55
|
*/
|
|
56
56
|
setOptions(...options: RestOrArray<SelectMenuOptionBuilder | APISelectMenuOption>): this;
|
|
57
57
|
/**
|
|
58
|
-
* {@inheritDoc
|
|
58
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
59
59
|
*/
|
|
60
60
|
toJSON(): APISelectMenuComponent;
|
|
61
61
|
}
|
|
@@ -1 +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\tjsonOptionValidator,\n\tminMaxValidator,\n\toptionsLengthValidator,\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(jsonOptionValidator.parse(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(jsonOptionValidator.parse(option)),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc
|
|
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\tjsonOptionValidator,\n\tminMaxValidator,\n\toptionsLengthValidator,\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(jsonOptionValidator.parse(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(jsonOptionValidator.parse(option)),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\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}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B,MAAM,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC;AAClD,KAAK,CAAC;AACN,GAAG;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMenuOption.cjs","sources":["../../../src/components/selectMenu/SelectMenuOption.ts"],"sourcesContent":["import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v10';\nimport type { JSONEncodable } from '../../util/jsonEncodable';\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 implements JSONEncodable<APISelectMenuOption> {\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\t/**\n\t * {@inheritDoc
|
|
1
|
+
{"version":3,"file":"SelectMenuOption.cjs","sources":["../../../src/components/selectMenu/SelectMenuOption.ts"],"sourcesContent":["import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v10';\nimport type { JSONEncodable } from '../../util/jsonEncodable';\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 implements JSONEncodable<APISelectMenuOption> {\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\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\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;;;;"}
|
|
@@ -37,7 +37,7 @@ export declare class SelectMenuOptionBuilder implements JSONEncodable<APISelectM
|
|
|
37
37
|
*/
|
|
38
38
|
setEmoji(emoji: APIMessageComponentEmoji): this;
|
|
39
39
|
/**
|
|
40
|
-
* {@inheritDoc
|
|
40
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
41
41
|
*/
|
|
42
42
|
toJSON(): APISelectMenuOption;
|
|
43
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectMenuOption.mjs","sources":["../../../src/components/selectMenu/SelectMenuOption.ts"],"sourcesContent":["import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v10';\nimport type { JSONEncodable } from '../../util/jsonEncodable';\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 implements JSONEncodable<APISelectMenuOption> {\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\t/**\n\t * {@inheritDoc
|
|
1
|
+
{"version":3,"file":"SelectMenuOption.mjs","sources":["../../../src/components/selectMenu/SelectMenuOption.ts"],"sourcesContent":["import type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v10';\nimport type { JSONEncodable } from '../../util/jsonEncodable';\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 implements JSONEncodable<APISelectMenuOption> {\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\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\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;;;;"}
|
|
@@ -1 +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 type { Equatable } from '../../util/equatable';\nimport { isJSONEncodable, type JSONEncodable } from '../../util/jsonEncodable';\nimport { customIdValidator } from '../Assertions';\nimport { ComponentBuilder } from '../Component';\n\nexport class TextInputBuilder\n\textends ComponentBuilder<APITextInputComponent>\n\timplements Equatable<JSONEncodable<APITextInputComponent> | APITextInputComponent>\n{\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\t/**\n\t * {@inheritDoc
|
|
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 type { Equatable } from '../../util/equatable';\nimport { isJSONEncodable, type JSONEncodable } from '../../util/jsonEncodable';\nimport { customIdValidator } from '../Assertions';\nimport { ComponentBuilder } from '../Component';\n\nexport class TextInputBuilder\n\textends ComponentBuilder<APITextInputComponent>\n\timplements Equatable<JSONEncodable<APITextInputComponent> | APITextInputComponent>\n{\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\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\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\t/**\n\t * {@inheritDoc Equatable.equals}\n\t */\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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C;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;;;;"}
|
|
@@ -55,7 +55,7 @@ export declare class TextInputBuilder extends ComponentBuilder<APITextInputCompo
|
|
|
55
55
|
*/
|
|
56
56
|
setRequired(required?: boolean): this;
|
|
57
57
|
/**
|
|
58
|
-
* {@inheritDoc
|
|
58
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
59
59
|
*/
|
|
60
60
|
toJSON(): APITextInputComponent;
|
|
61
61
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextInput.mjs","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 type { Equatable } from '../../util/equatable';\nimport { isJSONEncodable, type JSONEncodable } from '../../util/jsonEncodable';\nimport { customIdValidator } from '../Assertions';\nimport { ComponentBuilder } from '../Component';\n\nexport class TextInputBuilder\n\textends ComponentBuilder<APITextInputComponent>\n\timplements Equatable<JSONEncodable<APITextInputComponent> | APITextInputComponent>\n{\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\t/**\n\t * {@inheritDoc
|
|
1
|
+
{"version":3,"file":"TextInput.mjs","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 type { Equatable } from '../../util/equatable';\nimport { isJSONEncodable, type JSONEncodable } from '../../util/jsonEncodable';\nimport { customIdValidator } from '../Assertions';\nimport { ComponentBuilder } from '../Component';\n\nexport class TextInputBuilder\n\textends ComponentBuilder<APITextInputComponent>\n\timplements Equatable<JSONEncodable<APITextInputComponent> | APITextInputComponent>\n{\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\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\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\t/**\n\t * {@inheritDoc Equatable.equals}\n\t */\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":[],"mappings":";;;;;;;AAeO,MAAM,gBAAgB,SAAS,gBAAgB,CAAC;AACvD,EAAE,WAAW,CAAC,IAAI,EAAE;AACpB,IAAI,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,CAAC,SAAS,EAAE,GAAG,IAAI,EAAE,CAAC,CAAC;AACtD,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,CAA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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,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE;AAChC,MAAM,OAAO,OAAO,CAAC,KAAK,CAAC,MAAM,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AAChD,KAAK;AACL,IAAI,OAAO,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AACrC,GAAG;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuCommandBuilder.cjs","sources":["../../../src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts"],"sourcesContent":["import type {\n\tApplicationCommandType,\n\tLocaleString,\n\tLocalizationMap,\n\tPermissions,\n\tRESTPostAPIApplicationCommandsJSONBody,\n} from 'discord-api-types/v10';\nimport {\n\tvalidateRequiredParameters,\n\tvalidateName,\n\tvalidateType,\n\tvalidateDefaultPermission,\n\tvalidateDefaultMemberPermissions,\n\tvalidateDMPermission,\n} from './Assertions';\nimport { validateLocale, validateLocalizationMap } from '../slashCommands/Assertions';\n\nexport class ContextMenuCommandBuilder {\n\t/**\n\t * The name of this context menu command\n\t */\n\tpublic readonly name: string = undefined!;\n\n\t/**\n\t * The localized names for this command\n\t */\n\tpublic readonly name_localizations?: LocalizationMap;\n\n\t/**\n\t * The type of this context menu command\n\t */\n\tpublic readonly type: ContextMenuCommandType = undefined!;\n\n\t/**\n\t * Whether the command is enabled by default when the app is added to a guild\n\t *\n\t * @deprecated This property is deprecated and will be removed in the future.\n\t * You should use
|
|
1
|
+
{"version":3,"file":"ContextMenuCommandBuilder.cjs","sources":["../../../src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts"],"sourcesContent":["import type {\n\tApplicationCommandType,\n\tLocaleString,\n\tLocalizationMap,\n\tPermissions,\n\tRESTPostAPIApplicationCommandsJSONBody,\n} from 'discord-api-types/v10';\nimport {\n\tvalidateRequiredParameters,\n\tvalidateName,\n\tvalidateType,\n\tvalidateDefaultPermission,\n\tvalidateDefaultMemberPermissions,\n\tvalidateDMPermission,\n} from './Assertions';\nimport { validateLocale, validateLocalizationMap } from '../slashCommands/Assertions';\n\nexport class ContextMenuCommandBuilder {\n\t/**\n\t * The name of this context menu command\n\t */\n\tpublic readonly name: string = undefined!;\n\n\t/**\n\t * The localized names for this command\n\t */\n\tpublic readonly name_localizations?: LocalizationMap;\n\n\t/**\n\t * The type of this context menu command\n\t */\n\tpublic readonly type: ContextMenuCommandType = undefined!;\n\n\t/**\n\t * Whether the command is enabled by default when the app is added to a guild\n\t *\n\t * @deprecated This property is deprecated and will be removed in the future.\n\t * You should use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.\n\t */\n\tpublic readonly default_permission: boolean | undefined = undefined;\n\n\t/**\n\t * Set of permissions represented as a bit set for the command\n\t */\n\tpublic readonly default_member_permissions: Permissions | null | undefined = undefined;\n\n\t/**\n\t * Indicates whether the command is available in DMs with the application, only for globally-scoped commands.\n\t * By default, commands are visible.\n\t */\n\tpublic readonly dm_permission: boolean | undefined = undefined;\n\n\t/**\n\t * Sets the name\n\t *\n\t * @param name - The name\n\t */\n\tpublic setName(name: string) {\n\t\t// Assert the name matches the conditions\n\t\tvalidateName(name);\n\n\t\tReflect.set(this, 'name', name);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the type\n\t *\n\t * @param type - The type\n\t */\n\tpublic setType(type: ContextMenuCommandType) {\n\t\t// Assert the type is valid\n\t\tvalidateType(type);\n\n\t\tReflect.set(this, 'type', type);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether the command is enabled by default when the application is added to a guild.\n\t *\n\t * **Note**: If set to `false`, you will have to later `PUT` the permissions for this command.\n\t *\n\t * @param value - Whether or not to enable this command by default\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t * @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.\n\t */\n\tpublic setDefaultPermission(value: boolean) {\n\t\t// Assert the value matches the conditions\n\t\tvalidateDefaultPermission(value);\n\n\t\tReflect.set(this, 'default_permission', value);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the default permissions a member should have in order to run the command.\n\t *\n\t * **Note:** You can set this to `'0'` to disable the command by default.\n\t *\n\t * @param permissions - The permissions bit field to set\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t */\n\tpublic setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined) {\n\t\t// Assert the value and parse it\n\t\tconst permissionValue = validateDefaultMemberPermissions(permissions);\n\n\t\tReflect.set(this, 'default_member_permissions', permissionValue);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets if the command is available in DMs with the application, only for globally-scoped commands.\n\t * By default, commands are visible.\n\t *\n\t * @param enabled - If the command should be enabled in DMs\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t */\n\tpublic setDMPermission(enabled: boolean | null | undefined) {\n\t\t// Assert the value matches the conditions\n\t\tvalidateDMPermission(enabled);\n\n\t\tReflect.set(this, 'dm_permission', enabled);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets a name localization\n\t *\n\t * @param locale - The locale to set a description for\n\t * @param localizedName - The localized description for the given locale\n\t */\n\tpublic setNameLocalization(locale: LocaleString, localizedName: string | null) {\n\t\tif (!this.name_localizations) {\n\t\t\tReflect.set(this, 'name_localizations', {});\n\t\t}\n\n\t\tconst parsedLocale = validateLocale(locale);\n\n\t\tif (localizedName === null) {\n\t\t\tthis.name_localizations![parsedLocale] = null;\n\t\t\treturn this;\n\t\t}\n\n\t\tvalidateName(localizedName);\n\n\t\tthis.name_localizations![parsedLocale] = localizedName;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the name localizations\n\t *\n\t * @param localizedNames - The dictionary of localized descriptions to set\n\t */\n\tpublic setNameLocalizations(localizedNames: LocalizationMap | null) {\n\t\tif (localizedNames === null) {\n\t\t\tReflect.set(this, 'name_localizations', null);\n\t\t\treturn this;\n\t\t}\n\n\t\tReflect.set(this, 'name_localizations', {});\n\n\t\tObject.entries(localizedNames).forEach((args) =>\n\t\t\tthis.setNameLocalization(...(args as [LocaleString, string | null])),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the final data that should be sent to Discord.\n\t *\n\t * **Note:** Calling this function will validate required properties based on their conditions.\n\t */\n\tpublic toJSON(): RESTPostAPIApplicationCommandsJSONBody {\n\t\tvalidateRequiredParameters(this.name, this.type);\n\n\t\tvalidateLocalizationMap(this.name_localizations);\n\n\t\treturn { ...this };\n\t}\n}\n\nexport type ContextMenuCommandType = ApplicationCommandType.User | ApplicationCommandType.Message;\n"],"names":["validateName","validateType","validateDefaultPermission","validateDefaultMemberPermissions","validateDMPermission","validateLocale","validateRequiredParameters","validateLocalizationMap"],"mappings":";;;;;;;AASO,MAAM,yBAAyB,CAAC;AACvC,EAAE,WAAW,GAAG;AAChB,IAAI,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AACvB,IAAI,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AACvB,IAAI,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACrC,IAAI,IAAI,CAAC,0BAA0B,GAAG,KAAK,CAAC,CAAC;AAC7C,IAAI,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AAChC,GAAG;AACH,EAAE,OAAO,CAAC,IAAI,EAAE;AAChB,IAAIA,uBAAY,CAAC,IAAI,CAAC,CAAC;AACvB,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAA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,GAAG,IAAI,CAAC;AACnD,MAAM,OAAO,IAAI,CAAC;AAClB,KAAK;AACL,IAAIL,uBAAY,CAAC,aAAa,CAAC,CAAC;AAChC,IAAI,IAAI,CAAC,kBAAkB,CAAC,YAAY,CAAC,GAAG,aAAa,CAAC;AAC1D,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,oBAAoB,CAAC,cAAc,EAAE;AACvC,IAAI,IAAI,cAAc,KAAK,IAAI,EAAE;AACjC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAC;AACpD,MAAM,OAAO,IAAI,CAAC;AAClB,KAAK;AACL,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,CAAC,CAAC;AAChD,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO;AAC1C,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC;AACjD,KAAK,CAAC;AACN,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAIM,qCAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AACrD,IAAIC,oCAAuB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AACrD,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACvB,GAAG;AACH;;;;"}
|
|
@@ -16,7 +16,7 @@ export declare class ContextMenuCommandBuilder {
|
|
|
16
16
|
* Whether the command is enabled by default when the app is added to a guild
|
|
17
17
|
*
|
|
18
18
|
* @deprecated This property is deprecated and will be removed in the future.
|
|
19
|
-
* You should use
|
|
19
|
+
* You should use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
|
20
20
|
*/
|
|
21
21
|
readonly default_permission: boolean | undefined;
|
|
22
22
|
/**
|
|
@@ -48,7 +48,7 @@ export declare class ContextMenuCommandBuilder {
|
|
|
48
48
|
* @param value - Whether or not to enable this command by default
|
|
49
49
|
*
|
|
50
50
|
* @see https://discord.com/developers/docs/interactions/application-commands#permissions
|
|
51
|
-
* @deprecated Use
|
|
51
|
+
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
|
|
52
52
|
*/
|
|
53
53
|
setDefaultPermission(value: boolean): this;
|
|
54
54
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContextMenuCommandBuilder.mjs","sources":["../../../src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts"],"sourcesContent":["import type {\n\tApplicationCommandType,\n\tLocaleString,\n\tLocalizationMap,\n\tPermissions,\n\tRESTPostAPIApplicationCommandsJSONBody,\n} from 'discord-api-types/v10';\nimport {\n\tvalidateRequiredParameters,\n\tvalidateName,\n\tvalidateType,\n\tvalidateDefaultPermission,\n\tvalidateDefaultMemberPermissions,\n\tvalidateDMPermission,\n} from './Assertions';\nimport { validateLocale, validateLocalizationMap } from '../slashCommands/Assertions';\n\nexport class ContextMenuCommandBuilder {\n\t/**\n\t * The name of this context menu command\n\t */\n\tpublic readonly name: string = undefined!;\n\n\t/**\n\t * The localized names for this command\n\t */\n\tpublic readonly name_localizations?: LocalizationMap;\n\n\t/**\n\t * The type of this context menu command\n\t */\n\tpublic readonly type: ContextMenuCommandType = undefined!;\n\n\t/**\n\t * Whether the command is enabled by default when the app is added to a guild\n\t *\n\t * @deprecated This property is deprecated and will be removed in the future.\n\t * You should use
|
|
1
|
+
{"version":3,"file":"ContextMenuCommandBuilder.mjs","sources":["../../../src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts"],"sourcesContent":["import type {\n\tApplicationCommandType,\n\tLocaleString,\n\tLocalizationMap,\n\tPermissions,\n\tRESTPostAPIApplicationCommandsJSONBody,\n} from 'discord-api-types/v10';\nimport {\n\tvalidateRequiredParameters,\n\tvalidateName,\n\tvalidateType,\n\tvalidateDefaultPermission,\n\tvalidateDefaultMemberPermissions,\n\tvalidateDMPermission,\n} from './Assertions';\nimport { validateLocale, validateLocalizationMap } from '../slashCommands/Assertions';\n\nexport class ContextMenuCommandBuilder {\n\t/**\n\t * The name of this context menu command\n\t */\n\tpublic readonly name: string = undefined!;\n\n\t/**\n\t * The localized names for this command\n\t */\n\tpublic readonly name_localizations?: LocalizationMap;\n\n\t/**\n\t * The type of this context menu command\n\t */\n\tpublic readonly type: ContextMenuCommandType = undefined!;\n\n\t/**\n\t * Whether the command is enabled by default when the app is added to a guild\n\t *\n\t * @deprecated This property is deprecated and will be removed in the future.\n\t * You should use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.\n\t */\n\tpublic readonly default_permission: boolean | undefined = undefined;\n\n\t/**\n\t * Set of permissions represented as a bit set for the command\n\t */\n\tpublic readonly default_member_permissions: Permissions | null | undefined = undefined;\n\n\t/**\n\t * Indicates whether the command is available in DMs with the application, only for globally-scoped commands.\n\t * By default, commands are visible.\n\t */\n\tpublic readonly dm_permission: boolean | undefined = undefined;\n\n\t/**\n\t * Sets the name\n\t *\n\t * @param name - The name\n\t */\n\tpublic setName(name: string) {\n\t\t// Assert the name matches the conditions\n\t\tvalidateName(name);\n\n\t\tReflect.set(this, 'name', name);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the type\n\t *\n\t * @param type - The type\n\t */\n\tpublic setType(type: ContextMenuCommandType) {\n\t\t// Assert the type is valid\n\t\tvalidateType(type);\n\n\t\tReflect.set(this, 'type', type);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether the command is enabled by default when the application is added to a guild.\n\t *\n\t * **Note**: If set to `false`, you will have to later `PUT` the permissions for this command.\n\t *\n\t * @param value - Whether or not to enable this command by default\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t * @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.\n\t */\n\tpublic setDefaultPermission(value: boolean) {\n\t\t// Assert the value matches the conditions\n\t\tvalidateDefaultPermission(value);\n\n\t\tReflect.set(this, 'default_permission', value);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the default permissions a member should have in order to run the command.\n\t *\n\t * **Note:** You can set this to `'0'` to disable the command by default.\n\t *\n\t * @param permissions - The permissions bit field to set\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t */\n\tpublic setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined) {\n\t\t// Assert the value and parse it\n\t\tconst permissionValue = validateDefaultMemberPermissions(permissions);\n\n\t\tReflect.set(this, 'default_member_permissions', permissionValue);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets if the command is available in DMs with the application, only for globally-scoped commands.\n\t * By default, commands are visible.\n\t *\n\t * @param enabled - If the command should be enabled in DMs\n\t *\n\t * @see https://discord.com/developers/docs/interactions/application-commands#permissions\n\t */\n\tpublic setDMPermission(enabled: boolean | null | undefined) {\n\t\t// Assert the value matches the conditions\n\t\tvalidateDMPermission(enabled);\n\n\t\tReflect.set(this, 'dm_permission', enabled);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets a name localization\n\t *\n\t * @param locale - The locale to set a description for\n\t * @param localizedName - The localized description for the given locale\n\t */\n\tpublic setNameLocalization(locale: LocaleString, localizedName: string | null) {\n\t\tif (!this.name_localizations) {\n\t\t\tReflect.set(this, 'name_localizations', {});\n\t\t}\n\n\t\tconst parsedLocale = validateLocale(locale);\n\n\t\tif (localizedName === null) {\n\t\t\tthis.name_localizations![parsedLocale] = null;\n\t\t\treturn this;\n\t\t}\n\n\t\tvalidateName(localizedName);\n\n\t\tthis.name_localizations![parsedLocale] = localizedName;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the name localizations\n\t *\n\t * @param localizedNames - The dictionary of localized descriptions to set\n\t */\n\tpublic setNameLocalizations(localizedNames: LocalizationMap | null) {\n\t\tif (localizedNames === null) {\n\t\t\tReflect.set(this, 'name_localizations', null);\n\t\t\treturn this;\n\t\t}\n\n\t\tReflect.set(this, 'name_localizations', {});\n\n\t\tObject.entries(localizedNames).forEach((args) =>\n\t\t\tthis.setNameLocalization(...(args as [LocaleString, string | null])),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Returns the final data that should be sent to Discord.\n\t *\n\t * **Note:** Calling this function will validate required properties based on their conditions.\n\t */\n\tpublic toJSON(): RESTPostAPIApplicationCommandsJSONBody {\n\t\tvalidateRequiredParameters(this.name, this.type);\n\n\t\tvalidateLocalizationMap(this.name_localizations);\n\n\t\treturn { ...this };\n\t}\n}\n\nexport type ContextMenuCommandType = ApplicationCommandType.User | ApplicationCommandType.Message;\n"],"names":[],"mappings":";;;AASO,MAAM,yBAAyB,CAAC;AACvC,EAAE,WAAW,GAAG;AAChB,IAAI,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AACvB,IAAI,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;AACvB,IAAI,IAAI,CAAC,kBAAkB,GAAG,KAAK,CAAC,CAAC;AACrC,IAAI,IAAI,CAAC,0BAA0B,GAAG,KAAK,CAAC,CAAC;AAC7C,IAAI,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,CAAC;AAChC,GAAG;AACH,EAAE,OAAO,CAAC,IAAI,EAAE;AAChB,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;AACvB,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;AACpC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,OAAO,CAAC,IAAI,EAAE;AAChB,IAAI,YAAY,CAAC,IAAI,CAAC,CAAC;AACvB,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,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CAAC;AAChB,GAAG;AACH,EAAE,oBAAoB,CAAC,cAAc,EAAE;AACvC,IAAI,IAAI,cAAc,KAAK,IAAI,EAAE;AACjC,MAAM,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAC;AACpD,MAAM,OAAO,IAAI,CAAC;AAClB,KAAK;AACL,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,oBAAoB,EAAE,EAAE,CAAC,CAAC;AAChD,IAAI,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC,OAAO;AAC1C,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,mBAAmB,CAAC,GAAG,IAAI,CAAC;AACjD,KAAK,CAAC;AACN,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,0BAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;AACrD,IAAI,uBAAuB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;AACrD,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACvB,GAAG;AACH;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.cjs","sources":["../../../src/interactions/modals/Modal.ts"],"sourcesContent":["import type {\n\tAPIActionRowComponent,\n\tAPIModalActionRowComponent,\n\tAPIModalInteractionResponseCallbackData,\n} from 'discord-api-types/v10';\nimport { titleValidator, validateRequiredParameters } from './Assertions';\nimport { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow';\nimport { customIdValidator } from '../../components/Assertions';\nimport { createComponentBuilder } from '../../components/Components';\nimport type { JSONEncodable } from '../../util/jsonEncodable';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {\n\tpublic readonly data: Partial<APIModalInteractionResponseCallbackData>;\n\tpublic readonly components: ActionRowBuilder<ModalActionRowComponentBuilder>[] = [];\n\n\tpublic constructor({ components, ...data }: Partial<APIModalInteractionResponseCallbackData> = {}) {\n\t\tthis.data = { ...data };\n\t\tthis.components = (components?.map((c) => createComponentBuilder(c)) ??\n\t\t\t[]) as ActionRowBuilder<ModalActionRowComponentBuilder>[];\n\t}\n\n\t/**\n\t * Sets the title of the modal\n\t *\n\t * @param title - The title of the modal\n\t */\n\tpublic setTitle(title: string) {\n\t\tthis.data.title = titleValidator.parse(title);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id of the modal\n\t *\n\t * @param customId - The custom id of this modal\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 * Adds components to this modal\n\t *\n\t * @param components - The components to add to this modal\n\t */\n\tpublic addComponents(\n\t\t...components: RestOrArray<\n\t\t\tActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>\n\t\t>\n\t) {\n\t\tthis.components.push(\n\t\t\t...normalizeArray(components).map((component) =>\n\t\t\t\tcomponent instanceof ActionRowBuilder\n\t\t\t\t\t? component\n\t\t\t\t\t: new ActionRowBuilder<ModalActionRowComponentBuilder>(component),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the components in this modal\n\t *\n\t * @param components - The components to set this modal to\n\t */\n\tpublic setComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>) {\n\t\tthis.components.splice(0, this.components.length, ...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIModalInteractionResponseCallbackData {\n\t\tvalidateRequiredParameters(this.data.custom_id, this.data.title, this.components);\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 APIModalInteractionResponseCallbackData;\n\t}\n}\n"],"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,MAAM,EAAE,GAAGD,6BAAc,CAAC,UAAU,CAAC,CAAC,CAAC;AACrF,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAIE,qCAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtF,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;;;;"}
|
|
1
|
+
{"version":3,"file":"Modal.cjs","sources":["../../../src/interactions/modals/Modal.ts"],"sourcesContent":["import type {\n\tAPIActionRowComponent,\n\tAPIModalActionRowComponent,\n\tAPIModalInteractionResponseCallbackData,\n} from 'discord-api-types/v10';\nimport { titleValidator, validateRequiredParameters } from './Assertions';\nimport { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow';\nimport { customIdValidator } from '../../components/Assertions';\nimport { createComponentBuilder } from '../../components/Components';\nimport type { JSONEncodable } from '../../util/jsonEncodable';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {\n\tpublic readonly data: Partial<APIModalInteractionResponseCallbackData>;\n\tpublic readonly components: ActionRowBuilder<ModalActionRowComponentBuilder>[] = [];\n\n\tpublic constructor({ components, ...data }: Partial<APIModalInteractionResponseCallbackData> = {}) {\n\t\tthis.data = { ...data };\n\t\tthis.components = (components?.map((c) => createComponentBuilder(c)) ??\n\t\t\t[]) as ActionRowBuilder<ModalActionRowComponentBuilder>[];\n\t}\n\n\t/**\n\t * Sets the title of the modal\n\t *\n\t * @param title - The title of the modal\n\t */\n\tpublic setTitle(title: string) {\n\t\tthis.data.title = titleValidator.parse(title);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id of the modal\n\t *\n\t * @param customId - The custom id of this modal\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 * Adds components to this modal\n\t *\n\t * @param components - The components to add to this modal\n\t */\n\tpublic addComponents(\n\t\t...components: RestOrArray<\n\t\t\tActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>\n\t\t>\n\t) {\n\t\tthis.components.push(\n\t\t\t...normalizeArray(components).map((component) =>\n\t\t\t\tcomponent instanceof ActionRowBuilder\n\t\t\t\t\t? component\n\t\t\t\t\t: new ActionRowBuilder<ModalActionRowComponentBuilder>(component),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the components in this modal\n\t *\n\t * @param components - The components to set this modal to\n\t */\n\tpublic setComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>) {\n\t\tthis.components.splice(0, this.components.length, ...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\n\tpublic toJSON(): APIModalInteractionResponseCallbackData {\n\t\tvalidateRequiredParameters(this.data.custom_id, this.data.title, this.components);\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 APIModalInteractionResponseCallbackData;\n\t}\n}\n"],"names":["createComponentBuilder","titleValidator","customIdValidator","normalizeArray","ActionRowBuilder","validateRequiredParameters"],"mappings":";;;;;;;;;;AAKO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE;AAC5C,IAAI,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;AACzB,IAAI,IAA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;AACtF,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;;;;"}
|
|
@@ -30,6 +30,9 @@ export declare class ModalBuilder implements JSONEncodable<APIModalInteractionRe
|
|
|
30
30
|
* @param components - The components to set this modal to
|
|
31
31
|
*/
|
|
32
32
|
setComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>): this;
|
|
33
|
+
/**
|
|
34
|
+
* {@inheritDoc ComponentBuilder.toJSON}
|
|
35
|
+
*/
|
|
33
36
|
toJSON(): APIModalInteractionResponseCallbackData;
|
|
34
37
|
}
|
|
35
38
|
//# sourceMappingURL=Modal.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.d.ts","sourceRoot":"","sources":["../../../src/interactions/modals/Modal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,qBAAqB,EACrB,0BAA0B,EAC1B,uCAAuC,EACvC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,gBAAgB,EAAE,KAAK,8BAA8B,EAAE,MAAM,4BAA4B,CAAC;AAGnG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7E,qBAAa,YAAa,YAAW,aAAa,CAAC,uCAAuC,CAAC;IAC1F,SAAgB,IAAI,EAAE,OAAO,CAAC,uCAAuC,CAAC,CAAC;IACvE,SAAgB,UAAU,EAAE,gBAAgB,CAAC,8BAA8B,CAAC,EAAE,CAAM;gBAEjE,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAE,OAAO,CAAC,uCAAuC,CAAM;IAMjG;;;;OAIG;IACI,QAAQ,CAAC,KAAK,EA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,8BAA8B,CAAC,CAAC;IAKjG;;OAEG;IACI,MAAM,IAAI,uCAAuC;CAQxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Modal.mjs","sources":["../../../src/interactions/modals/Modal.ts"],"sourcesContent":["import type {\n\tAPIActionRowComponent,\n\tAPIModalActionRowComponent,\n\tAPIModalInteractionResponseCallbackData,\n} from 'discord-api-types/v10';\nimport { titleValidator, validateRequiredParameters } from './Assertions';\nimport { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow';\nimport { customIdValidator } from '../../components/Assertions';\nimport { createComponentBuilder } from '../../components/Components';\nimport type { JSONEncodable } from '../../util/jsonEncodable';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {\n\tpublic readonly data: Partial<APIModalInteractionResponseCallbackData>;\n\tpublic readonly components: ActionRowBuilder<ModalActionRowComponentBuilder>[] = [];\n\n\tpublic constructor({ components, ...data }: Partial<APIModalInteractionResponseCallbackData> = {}) {\n\t\tthis.data = { ...data };\n\t\tthis.components = (components?.map((c) => createComponentBuilder(c)) ??\n\t\t\t[]) as ActionRowBuilder<ModalActionRowComponentBuilder>[];\n\t}\n\n\t/**\n\t * Sets the title of the modal\n\t *\n\t * @param title - The title of the modal\n\t */\n\tpublic setTitle(title: string) {\n\t\tthis.data.title = titleValidator.parse(title);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id of the modal\n\t *\n\t * @param customId - The custom id of this modal\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 * Adds components to this modal\n\t *\n\t * @param components - The components to add to this modal\n\t */\n\tpublic addComponents(\n\t\t...components: RestOrArray<\n\t\t\tActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>\n\t\t>\n\t) {\n\t\tthis.components.push(\n\t\t\t...normalizeArray(components).map((component) =>\n\t\t\t\tcomponent instanceof ActionRowBuilder\n\t\t\t\t\t? component\n\t\t\t\t\t: new ActionRowBuilder<ModalActionRowComponentBuilder>(component),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the components in this modal\n\t *\n\t * @param components - The components to set this modal to\n\t */\n\tpublic setComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>) {\n\t\tthis.components.splice(0, this.components.length, ...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIModalInteractionResponseCallbackData {\n\t\tvalidateRequiredParameters(this.data.custom_id, this.data.title, this.components);\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 APIModalInteractionResponseCallbackData;\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAKO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE;AAC5C,IAAI,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5B,IAAI,IAAI,CAAC,UAAU,GAAG,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9E,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,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,aAAa,CAAC,GAAG,UAAU,EAAE;AAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI;AACxB,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC,GAAG;AACvC,QAAQ,CAAC,SAAS,KAAK,SAAS,YAAY,gBAAgB,GAAG,SAAS,GAAG,IAAI,gBAAgB,CAAC,SAAS,CAAC;AAC1G,OAAO;AACP,KAAK,CAAC;AACN,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,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtF,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;;;;"}
|
|
1
|
+
{"version":3,"file":"Modal.mjs","sources":["../../../src/interactions/modals/Modal.ts"],"sourcesContent":["import type {\n\tAPIActionRowComponent,\n\tAPIModalActionRowComponent,\n\tAPIModalInteractionResponseCallbackData,\n} from 'discord-api-types/v10';\nimport { titleValidator, validateRequiredParameters } from './Assertions';\nimport { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow';\nimport { customIdValidator } from '../../components/Assertions';\nimport { createComponentBuilder } from '../../components/Components';\nimport type { JSONEncodable } from '../../util/jsonEncodable';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport class ModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {\n\tpublic readonly data: Partial<APIModalInteractionResponseCallbackData>;\n\tpublic readonly components: ActionRowBuilder<ModalActionRowComponentBuilder>[] = [];\n\n\tpublic constructor({ components, ...data }: Partial<APIModalInteractionResponseCallbackData> = {}) {\n\t\tthis.data = { ...data };\n\t\tthis.components = (components?.map((c) => createComponentBuilder(c)) ??\n\t\t\t[]) as ActionRowBuilder<ModalActionRowComponentBuilder>[];\n\t}\n\n\t/**\n\t * Sets the title of the modal\n\t *\n\t * @param title - The title of the modal\n\t */\n\tpublic setTitle(title: string) {\n\t\tthis.data.title = titleValidator.parse(title);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id of the modal\n\t *\n\t * @param customId - The custom id of this modal\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 * Adds components to this modal\n\t *\n\t * @param components - The components to add to this modal\n\t */\n\tpublic addComponents(\n\t\t...components: RestOrArray<\n\t\t\tActionRowBuilder<ModalActionRowComponentBuilder> | APIActionRowComponent<APIModalActionRowComponent>\n\t\t>\n\t) {\n\t\tthis.components.push(\n\t\t\t...normalizeArray(components).map((component) =>\n\t\t\t\tcomponent instanceof ActionRowBuilder\n\t\t\t\t\t? component\n\t\t\t\t\t: new ActionRowBuilder<ModalActionRowComponentBuilder>(component),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the components in this modal\n\t *\n\t * @param components - The components to set this modal to\n\t */\n\tpublic setComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>) {\n\t\tthis.components.splice(0, this.components.length, ...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\n\tpublic toJSON(): APIModalInteractionResponseCallbackData {\n\t\tvalidateRequiredParameters(this.data.custom_id, this.data.title, this.components);\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 APIModalInteractionResponseCallbackData;\n\t}\n}\n"],"names":[],"mappings":";;;;;;AAKO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,EAAE;AAC5C,IAAI,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5B,IAAI,IAAI,CAAC,UAAU,GAAG,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,KAAK,sBAAsB,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;AAC9E,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,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,aAAa,CAAC,GAAG,UAAU,EAAE;AAC/B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI;AACxB,MAAM,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC,GAAG;AACvC,QAAQ,CAAC,SAAS,KAAK,SAAS,YAAY,gBAAgB,GAAG,SAAS,GAAG,IAAI,gBAAgB,CAAC,SAAS,CAAC;AAC1G,OAAO;AACP,KAAK,CAAC;AACN,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,0BAA0B,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;AACtF,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;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integer.cjs","sources":["../../../../src/interactions/slashCommands/options/integer.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { APIApplicationCommandIntegerOption, ApplicationCommandOptionType } from 'discord-api-types/v10';\nimport { mix } from 'ts-mixer';\nimport { ApplicationCommandNumericOptionMinMaxValueMixin } from '../mixins/ApplicationCommandNumericOptionMinMaxValueMixin';\nimport { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';\nimport { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin';\n\nconst numberValidator = s.number.int;\n\n@mix(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)\nexport class SlashCommandIntegerOption\n\textends ApplicationCommandOptionBase\n\timplements ApplicationCommandNumericOptionMinMaxValueMixin\n{\n\tpublic readonly type = ApplicationCommandOptionType.Integer as const;\n\n\tpublic setMaxValue(max: number): this {\n\t\tnumberValidator.parse(max);\n\n\t\tReflect.set(this, 'max_value', max);\n\n\t\treturn this;\n\t}\n\n\tpublic setMinValue(min: number): this {\n\t\tnumberValidator.parse(min);\n\n\t\tReflect.set(this, 'min_value', min);\n\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIApplicationCommandIntegerOption {\n\t\tthis.runRequiredValidations();\n\n\t\tif (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {\n\t\t\tthrow new RangeError('Autocomplete and choices are mutually exclusive to each other.');\n\t\t}\n\n\t\treturn { ...this };\n\t}\n}\n\nexport interface SlashCommandIntegerOption\n\textends ApplicationCommandNumericOptionMinMaxValueMixin,\n\t\tApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {}\n"],"names":["s","SlashCommandIntegerOption","ApplicationCommandOptionBase","ApplicationCommandOptionType","mix","ApplicationCommandNumericOptionMinMaxValueMixin","ApplicationCommandOptionWithChoicesAndAutocompleteMixin"],"mappings":";;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,gBAAgB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AACvD,IAAI,eAAe,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,KAAK;AACzD,EAAE,IAAI,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,GAAG,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AACjF,EAAE,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;AAC5D,IAAI,IAAI,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC;AACjC,MAAM,MAAM,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MA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;AACFF,iCAAyB,GAAG,eAAe,CAAC;AAC5C,EAAEG,WAAG,CAACC,+FAA+C,EAAEC,+GAAuD,CAAC;AAC/G,CAAC,EAAEL,iCAAyB,CAAC;;"}
|
|
1
|
+
{"version":3,"file":"integer.cjs","sources":["../../../../src/interactions/slashCommands/options/integer.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { APIApplicationCommandIntegerOption, ApplicationCommandOptionType } from 'discord-api-types/v10';\nimport { mix } from 'ts-mixer';\nimport { ApplicationCommandNumericOptionMinMaxValueMixin } from '../mixins/ApplicationCommandNumericOptionMinMaxValueMixin';\nimport { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';\nimport { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin';\n\nconst numberValidator = s.number.int;\n\n@mix(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)\nexport class SlashCommandIntegerOption\n\textends ApplicationCommandOptionBase\n\timplements ApplicationCommandNumericOptionMinMaxValueMixin\n{\n\tpublic readonly type = ApplicationCommandOptionType.Integer as const;\n\n\t/**\n\t * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}\n\t */\n\tpublic setMaxValue(max: number): this {\n\t\tnumberValidator.parse(max);\n\n\t\tReflect.set(this, 'max_value', max);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}\n\t */\n\tpublic setMinValue(min: number): this {\n\t\tnumberValidator.parse(min);\n\n\t\tReflect.set(this, 'min_value', min);\n\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIApplicationCommandIntegerOption {\n\t\tthis.runRequiredValidations();\n\n\t\tif (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {\n\t\t\tthrow new RangeError('Autocomplete and choices are mutually exclusive to each other.');\n\t\t}\n\n\t\treturn { ...this };\n\t}\n}\n\nexport interface SlashCommandIntegerOption\n\textends ApplicationCommandNumericOptionMinMaxValueMixin,\n\t\tApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {}\n"],"names":["s","SlashCommandIntegerOption","ApplicationCommandOptionBase","ApplicationCommandOptionType","mix","ApplicationCommandNumericOptionMinMaxValueMixin","ApplicationCommandOptionWithChoicesAndAutocompleteMixin"],"mappings":";;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,gBAAgB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AACvD,IAAI,eAAe,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,KAAK;AACzD,EAAE,IAAI,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,GAAG,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AACjF,EAAE,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;AAC5D,IAAI,IAAI,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC;AACjC,MAAM,MAAM,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC;AACrF,EAAE,IAAI,IAAI,IAAI,MAAM;AACpB,IAAI,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AACnC,EAAE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAOF,MAAM,eAAe,GAAGA,YAAC,CAAC,MAAM,CAAC,GAAG,CAAC;AAC1BC,iCAAyB,GAAG,cAAcC,yDAA4B,CAAC;AAClF,EAAE,WAAW,GAAG;AAChB,IAAI,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;AACxB,IAAI,IAAI,CAAC,IAAI,GAAGC,gCAA4B,CAAC,OAAO,CAAC;AACrD,GAAG;AACH,EAAE,WAAW,CAAC,GAAG,EAAE;AACnB,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AACxC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,WAAW,CAAC,GAAG,EAAE;AACnB,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AACxC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;AAClC,IAAI,IAAI,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AACrF,MAAM,MAAM,IAAI,UAAU,CAAC,gEAAgE,CAAC,CAAC;AAC7F,KAAK;AACL,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACvB,GAAG;AACH,EAAE;AACFF,iCAAyB,GAAG,eAAe,CAAC;AAC5C,EAAEG,WAAG,CAACC,+FAA+C,EAAEC,+GAAuD,CAAC;AAC/G,CAAC,EAAEL,iCAAyB,CAAC;;"}
|
|
@@ -4,7 +4,13 @@ import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOption
|
|
|
4
4
|
import { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin';
|
|
5
5
|
export declare class SlashCommandIntegerOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
|
|
6
6
|
readonly type: ApplicationCommandOptionType.Integer;
|
|
7
|
+
/**
|
|
8
|
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
|
9
|
+
*/
|
|
7
10
|
setMaxValue(max: number): this;
|
|
11
|
+
/**
|
|
12
|
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
|
|
13
|
+
*/
|
|
8
14
|
setMinValue(min: number): this;
|
|
9
15
|
toJSON(): APIApplicationCommandIntegerOption;
|
|
10
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integer.d.ts","sourceRoot":"","sources":["../../../../src/interactions/slashCommands/options/integer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAEzG,OAAO,EAAE,+CAA+C,EAAE,MAAM,2DAA2D,CAAC;AAC5H,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,uDAAuD,EAAE,MAAM,mEAAmE,CAAC;AAI5I,qBACa,yBACZ,SAAQ,4BACR,YAAW,+CAA+C;IAE1D,SAAgB,IAAI,uCAAiD;
|
|
1
|
+
{"version":3,"file":"integer.d.ts","sourceRoot":"","sources":["../../../../src/interactions/slashCommands/options/integer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kCAAkC,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAEzG,OAAO,EAAE,+CAA+C,EAAE,MAAM,2DAA2D,CAAC;AAC5H,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,uDAAuD,EAAE,MAAM,mEAAmE,CAAC;AAI5I,qBACa,yBACZ,SAAQ,4BACR,YAAW,+CAA+C;IAE1D,SAAgB,IAAI,uCAAiD;IAErE;;OAEG;IACI,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQrC;;OAEG;IACI,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQ9B,MAAM,IAAI,kCAAkC;CASnD;AAED,MAAM,WAAW,yBAChB,SAAQ,+CAA+C,EACtD,uDAAuD,CAAC,MAAM,CAAC;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integer.mjs","sources":["../../../../src/interactions/slashCommands/options/integer.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { APIApplicationCommandIntegerOption, ApplicationCommandOptionType } from 'discord-api-types/v10';\nimport { mix } from 'ts-mixer';\nimport { ApplicationCommandNumericOptionMinMaxValueMixin } from '../mixins/ApplicationCommandNumericOptionMinMaxValueMixin';\nimport { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';\nimport { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin';\n\nconst numberValidator = s.number.int;\n\n@mix(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)\nexport class SlashCommandIntegerOption\n\textends ApplicationCommandOptionBase\n\timplements ApplicationCommandNumericOptionMinMaxValueMixin\n{\n\tpublic readonly type = ApplicationCommandOptionType.Integer as const;\n\n\tpublic setMaxValue(max: number): this {\n\t\tnumberValidator.parse(max);\n\n\t\tReflect.set(this, 'max_value', max);\n\n\t\treturn this;\n\t}\n\n\tpublic setMinValue(min: number): this {\n\t\tnumberValidator.parse(min);\n\n\t\tReflect.set(this, 'min_value', min);\n\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIApplicationCommandIntegerOption {\n\t\tthis.runRequiredValidations();\n\n\t\tif (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {\n\t\t\tthrow new RangeError('Autocomplete and choices are mutually exclusive to each other.');\n\t\t}\n\n\t\treturn { ...this };\n\t}\n}\n\nexport interface SlashCommandIntegerOption\n\textends ApplicationCommandNumericOptionMinMaxValueMixin,\n\t\tApplicationC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AE,WAAW,EAAE,GAAG,CAAC,CAAC;AACxC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,WAAW,CAAC,GAAG,EAAE;AACnB,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AACxC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;AAClC,IAAI,IAAI,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AACrF,MAAM,MAAM,IAAI,UAAU,CAAC,gEAAgE,CAAC,CAAC;AAC7F,KAAK;AACL,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACvB,GAAG;AACH,EAAE;AACF,yBAAyB,GAAG,eAAe,CAAC;AAC5C,EAAE,GAAG,CAAC,+CAA+C,EAAE,uDAAuD,CAAC;AAC/G,CAAC,EAAE,yBAAyB,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"integer.mjs","sources":["../../../../src/interactions/slashCommands/options/integer.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { APIApplicationCommandIntegerOption, ApplicationCommandOptionType } from 'discord-api-types/v10';\nimport { mix } from 'ts-mixer';\nimport { ApplicationCommandNumericOptionMinMaxValueMixin } from '../mixins/ApplicationCommandNumericOptionMinMaxValueMixin';\nimport { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';\nimport { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin';\n\nconst numberValidator = s.number.int;\n\n@mix(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)\nexport class SlashCommandIntegerOption\n\textends ApplicationCommandOptionBase\n\timplements ApplicationCommandNumericOptionMinMaxValueMixin\n{\n\tpublic readonly type = ApplicationCommandOptionType.Integer as const;\n\n\t/**\n\t * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}\n\t */\n\tpublic setMaxValue(max: number): this {\n\t\tnumberValidator.parse(max);\n\n\t\tReflect.set(this, 'max_value', max);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}\n\t */\n\tpublic setMinValue(min: number): this {\n\t\tnumberValidator.parse(min);\n\n\t\tReflect.set(this, 'min_value', min);\n\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIApplicationCommandIntegerOption {\n\t\tthis.runRequiredValidations();\n\n\t\tif (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {\n\t\t\tthrow new RangeError('Autocomplete and choices are mutually exclusive to each other.');\n\t\t}\n\n\t\treturn { ...this };\n\t}\n}\n\nexport interface SlashCommandIntegerOption\n\textends ApplicationCommandNumericOptionMinMaxValueMixin,\n\t\tApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {}\n"],"names":[],"mappings":";;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,gBAAgB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AACvD,IAAI,eAAe,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,KAAK;AACzD,EAAE,IAAI,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,GAAG,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AACjF,EAAE,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;AAC5D,IA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,MAAM,IAAI,UAAU,CAAC,gEAAgE,CAAC,CAAC;AAC7F,KAAK;AACL,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACvB,GAAG;AACH,EAAE;AACF,yBAAyB,GAAG,eAAe,CAAC;AAC5C,EAAE,GAAG,CAAC,+CAA+C,EAAE,uDAAuD,CAAC;AAC/G,CAAC,EAAE,yBAAyB,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.cjs","sources":["../../../../src/interactions/slashCommands/options/number.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { APIApplicationCommandNumberOption, ApplicationCommandOptionType } from 'discord-api-types/v10';\nimport { mix } from 'ts-mixer';\nimport { ApplicationCommandNumericOptionMinMaxValueMixin } from '../mixins/ApplicationCommandNumericOptionMinMaxValueMixin';\nimport { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';\nimport { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin';\n\nconst numberValidator = s.number;\n\n@mix(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)\nexport class SlashCommandNumberOption\n\textends ApplicationCommandOptionBase\n\timplements ApplicationCommandNumericOptionMinMaxValueMixin\n{\n\tpublic readonly type = ApplicationCommandOptionType.Number as const;\n\n\tpublic setMaxValue(max: number): this {\n\t\tnumberValidator.parse(max);\n\n\t\tReflect.set(this, 'max_value', max);\n\n\t\treturn this;\n\t}\n\n\tpublic setMinValue(min: number): this {\n\t\tnumberValidator.parse(min);\n\n\t\tReflect.set(this, 'min_value', min);\n\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIApplicationCommandNumberOption {\n\t\tthis.runRequiredValidations();\n\n\t\tif (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {\n\t\t\tthrow new RangeError('Autocomplete and choices are mutually exclusive to each other.');\n\t\t}\n\n\t\treturn { ...this };\n\t}\n}\n\nexport interface SlashCommandNumberOption\n\textends ApplicationCommandNumericOptionMinMaxValueMixin,\n\t\tApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {}\n"],"names":["s","SlashCommandNumberOption","ApplicationCommandOptionBase","ApplicationCommandOptionType","mix","ApplicationCommandNumericOptionMinMaxValueMixin","ApplicationCommandOptionWithChoicesAndAutocompleteMixin"],"mappings":";;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,gBAAgB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AACvD,IAAI,eAAe,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,KAAK;AACzD,EAAE,IAAI,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,GAAG,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AACjF,EAAE,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;AAC5D,IAAI,IAAI,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC;AACjC,MAAM,MAAM,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC;AACrF,EAAE,IAAI,IAAI,IAAI,MAAM;AACpB,IAAI,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AACnC,EAAE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAOF,MAAM,eAAe,GAAGA,YAAC,CAAC,MAAM,CAAC;AACtBC,gCAAwB,GAAG,cAAcC,yDAA4B,CAAC;AACjF,EAAE,WAAW,GAAG;AAChB,IAAI,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;AACxB,IAAI,IAAI,CAAC,IAAI,GAAGC,gCAA4B,CAAC,MAAM,CAAC;AACpD,GAAG;AACH,EAAE,WAAW,CAAC,GAAG,EAAE;AACnB,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AACxC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,WAAW,CAAC,GAAG,EAAE;AACnB,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AACxC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;AAClC,IAAI,IAAI,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AACrF,MAAM,MAAM,IAAI,UAAU,CAAC,gEAAgE,CAAC,CAAC;AAC7F,KAAK;AACL,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACvB,GAAG;AACH,EAAE;AACFF,gCAAwB,GAAG,eAAe,CAAC;AAC3C,EAAEG,WAAG,CAACC,+FAA+C,EAAEC,+GAAuD,CAAC;AAC/G,CAAC,EAAEL,gCAAwB,CAAC;;"}
|
|
1
|
+
{"version":3,"file":"number.cjs","sources":["../../../../src/interactions/slashCommands/options/number.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { APIApplicationCommandNumberOption, ApplicationCommandOptionType } from 'discord-api-types/v10';\nimport { mix } from 'ts-mixer';\nimport { ApplicationCommandNumericOptionMinMaxValueMixin } from '../mixins/ApplicationCommandNumericOptionMinMaxValueMixin';\nimport { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';\nimport { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin';\n\nconst numberValidator = s.number;\n\n@mix(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)\nexport class SlashCommandNumberOption\n\textends ApplicationCommandOptionBase\n\timplements ApplicationCommandNumericOptionMinMaxValueMixin\n{\n\tpublic readonly type = ApplicationCommandOptionType.Number as const;\n\n\t/**\n\t * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}\n\t */\n\tpublic setMaxValue(max: number): this {\n\t\tnumberValidator.parse(max);\n\n\t\tReflect.set(this, 'max_value', max);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}\n\t */\n\tpublic setMinValue(min: number): this {\n\t\tnumberValidator.parse(min);\n\n\t\tReflect.set(this, 'min_value', min);\n\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIApplicationCommandNumberOption {\n\t\tthis.runRequiredValidations();\n\n\t\tif (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {\n\t\t\tthrow new RangeError('Autocomplete and choices are mutually exclusive to each other.');\n\t\t}\n\n\t\treturn { ...this };\n\t}\n}\n\nexport interface SlashCommandNumberOption\n\textends ApplicationCommandNumericOptionMinMaxValueMixin,\n\t\tApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {}\n"],"names":["s","SlashCommandNumberOption","ApplicationCommandOptionBase","ApplicationCommandOptionType","mix","ApplicationCommandNumericOptionMinMaxValueMixin","ApplicationCommandOptionWithChoicesAndAutocompleteMixin"],"mappings":";;;;;;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,gBAAgB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AACvD,IAAI,eAAe,GAAG,CAAC,UA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I,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AACxC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;AAClC,IAAI,IAAI,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AACrF,MAAM,MAAM,IAAI,UAAU,CAAC,gEAAgE,CAAC,CAAC;AAC7F,KAAK;AACL,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACvB,GAAG;AACH,EAAE;AACFF,gCAAwB,GAAG,eAAe,CAAC;AAC3C,EAAEG,WAAG,CAACC,+FAA+C,EAAEC,+GAAuD,CAAC;AAC/G,CAAC,EAAEL,gCAAwB,CAAC;;"}
|
|
@@ -4,7 +4,13 @@ import { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOption
|
|
|
4
4
|
import { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin';
|
|
5
5
|
export declare class SlashCommandNumberOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
|
|
6
6
|
readonly type: ApplicationCommandOptionType.Number;
|
|
7
|
+
/**
|
|
8
|
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
|
|
9
|
+
*/
|
|
7
10
|
setMaxValue(max: number): this;
|
|
11
|
+
/**
|
|
12
|
+
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
|
|
13
|
+
*/
|
|
8
14
|
setMinValue(min: number): this;
|
|
9
15
|
toJSON(): APIApplicationCommandNumberOption;
|
|
10
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../../src/interactions/slashCommands/options/number.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAExG,OAAO,EAAE,+CAA+C,EAAE,MAAM,2DAA2D,CAAC;AAC5H,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,uDAAuD,EAAE,MAAM,mEAAmE,CAAC;AAI5I,qBACa,wBACZ,SAAQ,4BACR,YAAW,+CAA+C;IAE1D,SAAgB,IAAI,sCAAgD;
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../../../src/interactions/slashCommands/options/number.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,4BAA4B,EAAE,MAAM,uBAAuB,CAAC;AAExG,OAAO,EAAE,+CAA+C,EAAE,MAAM,2DAA2D,CAAC;AAC5H,OAAO,EAAE,4BAA4B,EAAE,MAAM,wCAAwC,CAAC;AACtF,OAAO,EAAE,uDAAuD,EAAE,MAAM,mEAAmE,CAAC;AAI5I,qBACa,wBACZ,SAAQ,4BACR,YAAW,+CAA+C;IAE1D,SAAgB,IAAI,sCAAgD;IAEpE;;OAEG;IACI,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQrC;;OAEG;IACI,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAQ9B,MAAM,IAAI,iCAAiC;CASlD;AAED,MAAM,WAAW,wBAChB,SAAQ,+CAA+C,EACtD,uDAAuD,CAAC,MAAM,CAAC;CAAG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.mjs","sources":["../../../../src/interactions/slashCommands/options/number.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { APIApplicationCommandNumberOption, ApplicationCommandOptionType } from 'discord-api-types/v10';\nimport { mix } from 'ts-mixer';\nimport { ApplicationCommandNumericOptionMinMaxValueMixin } from '../mixins/ApplicationCommandNumericOptionMinMaxValueMixin';\nimport { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';\nimport { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin';\n\nconst numberValidator = s.number;\n\n@mix(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)\nexport class SlashCommandNumberOption\n\textends ApplicationCommandOptionBase\n\timplements ApplicationCommandNumericOptionMinMaxValueMixin\n{\n\tpublic readonly type = ApplicationCommandOptionType.Number as const;\n\n\tpublic setMaxValue(max: number): this {\n\t\tnumberValidator.parse(max);\n\n\t\tReflect.set(this, 'max_value', max);\n\n\t\treturn this;\n\t}\n\n\tpublic setMinValue(min: number): this {\n\t\tnumberValidator.parse(min);\n\n\t\tReflect.set(this, 'min_value', min);\n\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIApplicationCommandNumberOption {\n\t\tthis.runRequiredValidations();\n\n\t\tif (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {\n\t\t\tthrow new RangeError('Autocomplete and choices are mutually exclusive to each other.');\n\t\t}\n\n\t\treturn { ...this };\n\t}\n}\n\nexport interface SlashCommandNumberOption\n\textends ApplicationCommandNumericOptionMinMaxValueMixin,\n\t\tApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {}\n"],"names":[],"mappings":";;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,gBAAgB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AACvD,IAAI,eAAe,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,KAAK;AACzD,EAAE,IAAI,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,GAAG,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AACjF,EAAE,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CA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,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AACrF,MAAM,MAAM,IAAI,UAAU,CAAC,gEAAgE,CAAC,CAAC;AAC7F,KAAK;AACL,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACvB,GAAG;AACH,EAAE;AACF,wBAAwB,GAAG,eAAe,CAAC;AAC3C,EAAE,GAAG,CAAC,+CAA+C,EAAE,uDAAuD,CAAC;AAC/G,CAAC,EAAE,wBAAwB,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"number.mjs","sources":["../../../../src/interactions/slashCommands/options/number.ts"],"sourcesContent":["import { s } from '@sapphire/shapeshift';\nimport { APIApplicationCommandNumberOption, ApplicationCommandOptionType } from 'discord-api-types/v10';\nimport { mix } from 'ts-mixer';\nimport { ApplicationCommandNumericOptionMinMaxValueMixin } from '../mixins/ApplicationCommandNumericOptionMinMaxValueMixin';\nimport { ApplicationCommandOptionBase } from '../mixins/ApplicationCommandOptionBase';\nimport { ApplicationCommandOptionWithChoicesAndAutocompleteMixin } from '../mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin';\n\nconst numberValidator = s.number;\n\n@mix(ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin)\nexport class SlashCommandNumberOption\n\textends ApplicationCommandOptionBase\n\timplements ApplicationCommandNumericOptionMinMaxValueMixin\n{\n\tpublic readonly type = ApplicationCommandOptionType.Number as const;\n\n\t/**\n\t * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}\n\t */\n\tpublic setMaxValue(max: number): this {\n\t\tnumberValidator.parse(max);\n\n\t\tReflect.set(this, 'max_value', max);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}\n\t */\n\tpublic setMinValue(min: number): this {\n\t\tnumberValidator.parse(min);\n\n\t\tReflect.set(this, 'min_value', min);\n\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): APIApplicationCommandNumberOption {\n\t\tthis.runRequiredValidations();\n\n\t\tif (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {\n\t\t\tthrow new RangeError('Autocomplete and choices are mutually exclusive to each other.');\n\t\t}\n\n\t\treturn { ...this };\n\t}\n}\n\nexport interface SlashCommandNumberOption\n\textends ApplicationCommandNumericOptionMinMaxValueMixin,\n\t\tApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {}\n"],"names":[],"mappings":";;;;;;;AAAA,IAAI,SAAS,GAAG,MAAM,CAAC,cAAc,CAAC;AACtC,IAAI,gBAAgB,GAAG,MAAM,CAAC,wBAAwB,CAAC;AACvD,IAAI,eAAe,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,KAAK;AACzD,EAAE,IAAI,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,IAAI,GAAG,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC;AACjF,EAAE,KAAK,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE;AAC5D,IAAI,IAAI,SAAS,GAAG,UAAU,CAAC,CAAC,CAAC;AACjC,MAAM,MAAM,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC;AACrF,EAAE,IAAI,IAAI,IAAI,MAAM;AACpB,IAAI,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AACnC,EAAE,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAOF,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC;AACvB,IAAC,wBAAwB,GAAG,cAAc,4BAA4B,CAAC;AACjF,EAAE,WAAW,GAAG;AAChB,IAAI,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;AACxB,IAAI,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAC,MAAM,CAAC;AACpD,GAAG;AACH,EAAE,WAAW,CAAC,GAAG,EAAE;AACnB,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AACxC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,WAAW,CAAC,GAAG,EAAE;AACnB,IAAI,eAAe,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC/B,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,CAAC;AACxC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;AAClC,IAAI,IAAI,IAAI,CAAC,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;AACrF,MAAM,MAAM,IAAI,UAAU,CAAC,gEAAgE,CAAC,CAAC;AAC7F,KAAK;AACL,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;AACvB,GAAG;AACH,EAAE;AACF,wBAAwB,GAAG,eAAe,CAAC;AAC3C,EAAE,GAAG,CAAC,+CAA+C,EAAE,uDAAuD,CAAC;AAC/G,CAAC,EAAE,wBAAwB,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embed.cjs","sources":["../../../src/messages/embed/Embed.ts"],"sourcesContent":["import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage } from 'discord-api-types/v10';\nimport {\n\tcolorPredicate,\n\tdescriptionPredicate,\n\tembedAuthorPredicate,\n\tembedFieldsArrayPredicate,\n\tembedFooterPredicate,\n\timageURLPredicate,\n\ttimestampPredicate,\n\ttitlePredicate,\n\turlPredicate,\n\tvalidateFieldLength,\n} from './Assertions';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport type RGBTuple = [red: number, green: number, blue: number];\n\nexport interface IconData {\n\t/**\n\t * The URL of the icon\n\t */\n\ticonURL?: string;\n\t/**\n\t * The proxy URL of the icon\n\t */\n\tproxyIconURL?: string;\n}\n\nexport type EmbedAuthorData = Omit<APIEmbedAuthor, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedAuthorOptions = Omit<EmbedAuthorData, 'proxyIconURL'>;\n\nexport type EmbedFooterData = Omit<APIEmbedFooter, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedFooterOptions = Omit<EmbedFooterData, 'proxyIconURL'>;\n\nexport interface EmbedImageData extends Omit<APIEmbedImage, 'proxy_url'> {\n\t/**\n\t * The proxy URL for the image\n\t */\n\tproxyURL?: string;\n}\n/**\n * Represents a embed in a message (image/video preview, rich embed, etc.)\n */\nexport class EmbedBuilder {\n\tpublic readonly data: APIEmbed;\n\n\tpublic constructor(data: APIEmbed = {}) {\n\t\tthis.data = { ...data };\n\t\tif (data.timestamp) this.data.timestamp = new Date(data.timestamp).toISOString();\n\t}\n\n\t/**\n\t * Appends fields to the embed\n\t *\n\t * @remarks\n\t * This method accepts either an array of fields or a variable number of field parameters.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * @example\n\t * Using an array\n\t * ```ts\n\t * const fields: APIEmbedField[] = ...;\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(fields);\n\t * ```\n\t *\n\t * @example\n\t * Using rest parameters (variadic)\n\t * ```ts\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(\n\t * \t\t{ name: 'Field 1', value: 'Value 1' },\n\t * \t\t{ name: 'Field 2', value: 'Value 2' },\n\t * \t);\n\t * ```\n\t *\n\t * @param fields The fields to add\n\t */\n\tpublic addFields(...fields: RestOrArray<APIEmbedField>): this {\n\t\tfields = normalizeArray(fields);\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\n\t\tif (this.data.fields) this.data.fields.push(...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes, replaces, or inserts fields in the embed.\n\t *\n\t * @remarks\n\t * This method behaves similarly\n\t * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice}.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * It's useful for modifying and adjusting order of the already-existing fields of an embed.\n\t *\n\t * @example\n\t * Remove the first field\n\t * ```ts\n\t * embed.spliceFields(0, 1);\n\t * ```\n\t *\n\t * @example\n\t * Remove the first n fields\n\t * ```ts\n\t * const n = 4\n\t * embed.spliceFields(0, n);\n\t * ```\n\t *\n\t * @example\n\t * Remove the last field\n\t * ```ts\n\t * embed.spliceFields(-1, 1);\n\t * ```\n\t *\n\t * @param index The index to start at\n\t * @param deleteCount The number of fields to remove\n\t * @param fields The replacing field objects\n\t */\n\tpublic spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this {\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length - deleteCount, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\t\tif (this.data.fields) this.data.fields.splice(index, deleteCount, ...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the embed's fields\n\t *\n\t * @remarks\n\t * This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,\n\t * it splices the entire array of fields, replacing them with the provided fields.\n\t *\n\t * You can set a maximum of 25 fields.\n\t *\n\t * @param fields The fields to set\n\t */\n\tpublic setFields(...fields: RestOrArray<APIEmbedField>) {\n\t\tthis.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the author of this embed\n\t *\n\t * @param options The options for the author\n\t */\n\n\tpublic setAuthor(options: EmbedAuthorOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.author = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedAuthorPredicate.parse(options);\n\n\t\tthis.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the color of this embed\n\t *\n\t * @param color The color of the embed\n\t */\n\tpublic setColor(color: number | RGBTuple | null): this {\n\t\t// Data assertions\n\t\tcolorPredicate.parse(color);\n\n\t\tif (Array.isArray(color)) {\n\t\t\tconst [red, green, blue] = color;\n\t\t\tthis.data.color = (red << 16) + (green << 8) + blue;\n\t\t\treturn this;\n\t\t}\n\t\tthis.data.color = color ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this embed\n\t *\n\t * @param description The description\n\t */\n\tpublic setDescription(description: string | null): this {\n\t\t// Data assertions\n\t\tdescriptionPredicate.parse(description);\n\n\t\tthis.data.description = description ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the footer of this embed\n\t *\n\t * @param options The options for the footer\n\t */\n\tpublic setFooter(options: EmbedFooterOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.footer = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedFooterPredicate.parse(options);\n\n\t\tthis.data.footer = { text: options.text, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the image of this embed\n\t *\n\t * @param url The URL of the image\n\t */\n\tpublic setImage(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.image = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the thumbnail of this embed\n\t *\n\t * @param url The URL of the thumbnail\n\t */\n\tpublic setThumbnail(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.thumbnail = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the timestamp of this embed\n\t *\n\t * @param timestamp The timestamp or date\n\t */\n\tpublic setTimestamp(timestamp: number | Date | null = Date.now()): this {\n\t\t// Data assertions\n\t\ttimestampPredicate.parse(timestamp);\n\n\t\tthis.data.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the title of this embed\n\t *\n\t * @param title The title\n\t */\n\tpublic setTitle(title: string | null): this {\n\t\t// Data assertions\n\t\ttitlePredicate.parse(title);\n\n\t\tthis.data.title = title ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL of this embed\n\t *\n\t * @param url The URL\n\t */\n\tpublic setURL(url: string | null): this {\n\t\t// Data assertions\n\t\turlPredicate.parse(url);\n\n\t\tthis.data.url = url ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Transforms the embed to a plain object\n\t */\n\tpublic toJSON(): APIEmbed {\n\t\treturn { ...this.data };\n\t}\n}\n"],"names":["normalizeArray","validateFieldLength","embedFieldsArrayPredicate","embedAuthorPredicate","colorPredicate","descriptionPredicate","embedFooterPredicate","imageURLPredicate","timestampPredicate","titlePredicate","urlPredicate"],"mappings":";;;;;;;AAaO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5B,IAAI,IAAI,IAAI,CAAC,SAAS;AACtB,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;AACnE,GAA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ChC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC;AACtC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,CAAC,GAAG,EAAE;AACd,IAAIC,uBAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5B,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC;AAClC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5B,GAAG;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"Embed.cjs","sources":["../../../src/messages/embed/Embed.ts"],"sourcesContent":["import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage } from 'discord-api-types/v10';\nimport {\n\tcolorPredicate,\n\tdescriptionPredicate,\n\tembedAuthorPredicate,\n\tembedFieldsArrayPredicate,\n\tembedFooterPredicate,\n\timageURLPredicate,\n\ttimestampPredicate,\n\ttitlePredicate,\n\turlPredicate,\n\tvalidateFieldLength,\n} from './Assertions';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport type RGBTuple = [red: number, green: number, blue: number];\n\nexport interface IconData {\n\t/**\n\t * The URL of the icon\n\t */\n\ticonURL?: string;\n\t/**\n\t * The proxy URL of the icon\n\t */\n\tproxyIconURL?: string;\n}\n\nexport type EmbedAuthorData = Omit<APIEmbedAuthor, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedAuthorOptions = Omit<EmbedAuthorData, 'proxyIconURL'>;\n\nexport type EmbedFooterData = Omit<APIEmbedFooter, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedFooterOptions = Omit<EmbedFooterData, 'proxyIconURL'>;\n\nexport interface EmbedImageData extends Omit<APIEmbedImage, 'proxy_url'> {\n\t/**\n\t * The proxy URL for the image\n\t */\n\tproxyURL?: string;\n}\n/**\n * Represents a embed in a message (image/video preview, rich embed, etc.)\n */\nexport class EmbedBuilder {\n\tpublic readonly data: APIEmbed;\n\n\tpublic constructor(data: APIEmbed = {}) {\n\t\tthis.data = { ...data };\n\t\tif (data.timestamp) this.data.timestamp = new Date(data.timestamp).toISOString();\n\t}\n\n\t/**\n\t * Appends fields to the embed\n\t *\n\t * @remarks\n\t * This method accepts either an array of fields or a variable number of field parameters.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * @example\n\t * Using an array\n\t * ```ts\n\t * const fields: APIEmbedField[] = ...;\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(fields);\n\t * ```\n\t *\n\t * @example\n\t * Using rest parameters (variadic)\n\t * ```ts\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(\n\t * \t\t{ name: 'Field 1', value: 'Value 1' },\n\t * \t\t{ name: 'Field 2', value: 'Value 2' },\n\t * \t);\n\t * ```\n\t *\n\t * @param fields - The fields to add\n\t */\n\tpublic addFields(...fields: RestOrArray<APIEmbedField>): this {\n\t\tfields = normalizeArray(fields);\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\n\t\tif (this.data.fields) this.data.fields.push(...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes, replaces, or inserts fields in the embed.\n\t *\n\t * @remarks\n\t * This method behaves similarly\n\t * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice}.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * It's useful for modifying and adjusting order of the already-existing fields of an embed.\n\t *\n\t * @example\n\t * Remove the first field\n\t * ```ts\n\t * embed.spliceFields(0, 1);\n\t * ```\n\t *\n\t * @example\n\t * Remove the first n fields\n\t * ```ts\n\t * const n = 4\n\t * embed.spliceFields(0, n);\n\t * ```\n\t *\n\t * @example\n\t * Remove the last field\n\t * ```ts\n\t * embed.spliceFields(-1, 1);\n\t * ```\n\t *\n\t * @param index - The index to start at\n\t * @param deleteCount - The number of fields to remove\n\t * @param fields - The replacing field objects\n\t */\n\tpublic spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this {\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length - deleteCount, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\t\tif (this.data.fields) this.data.fields.splice(index, deleteCount, ...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the embed's fields\n\t *\n\t * @remarks\n\t * This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,\n\t * it splices the entire array of fields, replacing them with the provided fields.\n\t *\n\t * You can set a maximum of 25 fields.\n\t *\n\t * @param fields - The fields to set\n\t */\n\tpublic setFields(...fields: RestOrArray<APIEmbedField>) {\n\t\tthis.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the author of this embed\n\t *\n\t * @param options - The options for the author\n\t */\n\n\tpublic setAuthor(options: EmbedAuthorOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.author = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedAuthorPredicate.parse(options);\n\n\t\tthis.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the color of this embed\n\t *\n\t * @param color - The color of the embed\n\t */\n\tpublic setColor(color: number | RGBTuple | null): this {\n\t\t// Data assertions\n\t\tcolorPredicate.parse(color);\n\n\t\tif (Array.isArray(color)) {\n\t\t\tconst [red, green, blue] = color;\n\t\t\tthis.data.color = (red << 16) + (green << 8) + blue;\n\t\t\treturn this;\n\t\t}\n\t\tthis.data.color = color ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this embed\n\t *\n\t * @param description - The description\n\t */\n\tpublic setDescription(description: string | null): this {\n\t\t// Data assertions\n\t\tdescriptionPredicate.parse(description);\n\n\t\tthis.data.description = description ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the footer of this embed\n\t *\n\t * @param options - The options for the footer\n\t */\n\tpublic setFooter(options: EmbedFooterOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.footer = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedFooterPredicate.parse(options);\n\n\t\tthis.data.footer = { text: options.text, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the image of this embed\n\t *\n\t * @param url - The URL of the image\n\t */\n\tpublic setImage(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.image = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the thumbnail of this embed\n\t *\n\t * @param url - The URL of the thumbnail\n\t */\n\tpublic setThumbnail(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.thumbnail = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the timestamp of this embed\n\t *\n\t * @param timestamp - The timestamp or date\n\t */\n\tpublic setTimestamp(timestamp: number | Date | null = Date.now()): this {\n\t\t// Data assertions\n\t\ttimestampPredicate.parse(timestamp);\n\n\t\tthis.data.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the title of this embed\n\t *\n\t * @param title - The title\n\t */\n\tpublic setTitle(title: string | null): this {\n\t\t// Data assertions\n\t\ttitlePredicate.parse(title);\n\n\t\tthis.data.title = title ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL of this embed\n\t *\n\t * @param url - The URL\n\t */\n\tpublic setURL(url: string | null): this {\n\t\t// Data assertions\n\t\turlPredicate.parse(url);\n\n\t\tthis.data.url = url ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Transforms the embed to a plain object\n\t */\n\tpublic toJSON(): APIEmbed {\n\t\treturn { ...this.data };\n\t}\n}\n"],"names":["normalizeArray","validateFieldLength","embedFieldsArrayPredicate","embedAuthorPredicate","colorPredicate","descriptionPredicate","embedFooterPredicate","imageURLPredicate","timestampPredicate","titlePredicate","urlPredicate"],"mappings":";;;;;;;AAaO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5B,IAAI,IAAI,IAAI,CAAC,SAAS;AACtB,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;AACnE,GAAG;AACH,EAAE,SAAS,CAAC,GAAG,MAAM,EAAE;AACvB,IAAI,MAAM,GAAGA,6BAAc,CAAC,MAAM,CAAC,CAAC;AACpC,IAAIC,8BAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACzD,IAAIC,oCAAyB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5C,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM;AACxB,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC;AACvC;AACA,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;AAChC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,MAAM,EAAE;AAC9C,IAAID,8BAAmB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,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,YAAY,CAAC,GAAG,EAAE;AACpB,IAAIA,4BAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACjC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,CAAC,CAAC;AACjD,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,YAAY,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE;AACvC,IAAIC,6BAAkB,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACxC,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,SAAS,GAAG,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,CAAC;AACjF,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAIC,yBAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAChC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC;AACtC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,CAAC,GAAG,EAAE;AACd,IAAIC,uBAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5B,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC;AAClC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5B,GAAG;AACH;;;;"}
|
|
@@ -52,7 +52,7 @@ export declare class EmbedBuilder {
|
|
|
52
52
|
* );
|
|
53
53
|
* ```
|
|
54
54
|
*
|
|
55
|
-
* @param fields The fields to add
|
|
55
|
+
* @param fields - The fields to add
|
|
56
56
|
*/
|
|
57
57
|
addFields(...fields: RestOrArray<APIEmbedField>): this;
|
|
58
58
|
/**
|
|
@@ -84,9 +84,9 @@ export declare class EmbedBuilder {
|
|
|
84
84
|
* embed.spliceFields(-1, 1);
|
|
85
85
|
* ```
|
|
86
86
|
*
|
|
87
|
-
* @param index The index to start at
|
|
88
|
-
* @param deleteCount The number of fields to remove
|
|
89
|
-
* @param fields The replacing field objects
|
|
87
|
+
* @param index - The index to start at
|
|
88
|
+
* @param deleteCount - The number of fields to remove
|
|
89
|
+
* @param fields - The replacing field objects
|
|
90
90
|
*/
|
|
91
91
|
spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this;
|
|
92
92
|
/**
|
|
@@ -98,61 +98,61 @@ export declare class EmbedBuilder {
|
|
|
98
98
|
*
|
|
99
99
|
* You can set a maximum of 25 fields.
|
|
100
100
|
*
|
|
101
|
-
* @param fields The fields to set
|
|
101
|
+
* @param fields - The fields to set
|
|
102
102
|
*/
|
|
103
103
|
setFields(...fields: RestOrArray<APIEmbedField>): this;
|
|
104
104
|
/**
|
|
105
105
|
* Sets the author of this embed
|
|
106
106
|
*
|
|
107
|
-
* @param options The options for the author
|
|
107
|
+
* @param options - The options for the author
|
|
108
108
|
*/
|
|
109
109
|
setAuthor(options: EmbedAuthorOptions | null): this;
|
|
110
110
|
/**
|
|
111
111
|
* Sets the color of this embed
|
|
112
112
|
*
|
|
113
|
-
* @param color The color of the embed
|
|
113
|
+
* @param color - The color of the embed
|
|
114
114
|
*/
|
|
115
115
|
setColor(color: number | RGBTuple | null): this;
|
|
116
116
|
/**
|
|
117
117
|
* Sets the description of this embed
|
|
118
118
|
*
|
|
119
|
-
* @param description The description
|
|
119
|
+
* @param description - The description
|
|
120
120
|
*/
|
|
121
121
|
setDescription(description: string | null): this;
|
|
122
122
|
/**
|
|
123
123
|
* Sets the footer of this embed
|
|
124
124
|
*
|
|
125
|
-
* @param options The options for the footer
|
|
125
|
+
* @param options - The options for the footer
|
|
126
126
|
*/
|
|
127
127
|
setFooter(options: EmbedFooterOptions | null): this;
|
|
128
128
|
/**
|
|
129
129
|
* Sets the image of this embed
|
|
130
130
|
*
|
|
131
|
-
* @param url The URL of the image
|
|
131
|
+
* @param url - The URL of the image
|
|
132
132
|
*/
|
|
133
133
|
setImage(url: string | null): this;
|
|
134
134
|
/**
|
|
135
135
|
* Sets the thumbnail of this embed
|
|
136
136
|
*
|
|
137
|
-
* @param url The URL of the thumbnail
|
|
137
|
+
* @param url - The URL of the thumbnail
|
|
138
138
|
*/
|
|
139
139
|
setThumbnail(url: string | null): this;
|
|
140
140
|
/**
|
|
141
141
|
* Sets the timestamp of this embed
|
|
142
142
|
*
|
|
143
|
-
* @param timestamp The timestamp or date
|
|
143
|
+
* @param timestamp - The timestamp or date
|
|
144
144
|
*/
|
|
145
145
|
setTimestamp(timestamp?: number | Date | null): this;
|
|
146
146
|
/**
|
|
147
147
|
* Sets the title of this embed
|
|
148
148
|
*
|
|
149
|
-
* @param title The title
|
|
149
|
+
* @param title - The title
|
|
150
150
|
*/
|
|
151
151
|
setTitle(title: string | null): this;
|
|
152
152
|
/**
|
|
153
153
|
* Sets the URL of this embed
|
|
154
154
|
*
|
|
155
|
-
* @param url The URL
|
|
155
|
+
* @param url - The URL
|
|
156
156
|
*/
|
|
157
157
|
setURL(url: string | null): this;
|
|
158
158
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Embed.mjs","sources":["../../../src/messages/embed/Embed.ts"],"sourcesContent":["import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage } from 'discord-api-types/v10';\nimport {\n\tcolorPredicate,\n\tdescriptionPredicate,\n\tembedAuthorPredicate,\n\tembedFieldsArrayPredicate,\n\tembedFooterPredicate,\n\timageURLPredicate,\n\ttimestampPredicate,\n\ttitlePredicate,\n\turlPredicate,\n\tvalidateFieldLength,\n} from './Assertions';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport type RGBTuple = [red: number, green: number, blue: number];\n\nexport interface IconData {\n\t/**\n\t * The URL of the icon\n\t */\n\ticonURL?: string;\n\t/**\n\t * The proxy URL of the icon\n\t */\n\tproxyIconURL?: string;\n}\n\nexport type EmbedAuthorData = Omit<APIEmbedAuthor, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedAuthorOptions = Omit<EmbedAuthorData, 'proxyIconURL'>;\n\nexport type EmbedFooterData = Omit<APIEmbedFooter, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedFooterOptions = Omit<EmbedFooterData, 'proxyIconURL'>;\n\nexport interface EmbedImageData extends Omit<APIEmbedImage, 'proxy_url'> {\n\t/**\n\t * The proxy URL for the image\n\t */\n\tproxyURL?: string;\n}\n/**\n * Represents a embed in a message (image/video preview, rich embed, etc.)\n */\nexport class EmbedBuilder {\n\tpublic readonly data: APIEmbed;\n\n\tpublic constructor(data: APIEmbed = {}) {\n\t\tthis.data = { ...data };\n\t\tif (data.timestamp) this.data.timestamp = new Date(data.timestamp).toISOString();\n\t}\n\n\t/**\n\t * Appends fields to the embed\n\t *\n\t * @remarks\n\t * This method accepts either an array of fields or a variable number of field parameters.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * @example\n\t * Using an array\n\t * ```ts\n\t * const fields: APIEmbedField[] = ...;\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(fields);\n\t * ```\n\t *\n\t * @example\n\t * Using rest parameters (variadic)\n\t * ```ts\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(\n\t * \t\t{ name: 'Field 1', value: 'Value 1' },\n\t * \t\t{ name: 'Field 2', value: 'Value 2' },\n\t * \t);\n\t * ```\n\t *\n\t * @param fields The fields to add\n\t */\n\tpublic addFields(...fields: RestOrArray<APIEmbedField>): this {\n\t\tfields = normalizeArray(fields);\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\n\t\tif (this.data.fields) this.data.fields.push(...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes, replaces, or inserts fields in the embed.\n\t *\n\t * @remarks\n\t * This method behaves similarly\n\t * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice}.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * It's useful for modifying and adjusting order of the already-existing fields of an embed.\n\t *\n\t * @example\n\t * Remove the first field\n\t * ```ts\n\t * embed.spliceFields(0, 1);\n\t * ```\n\t *\n\t * @example\n\t * Remove the first n fields\n\t * ```ts\n\t * const n = 4\n\t * embed.spliceFields(0, n);\n\t * ```\n\t *\n\t * @example\n\t * Remove the last field\n\t * ```ts\n\t * embed.spliceFields(-1, 1);\n\t * ```\n\t *\n\t * @param index The index to start at\n\t * @param deleteCount The number of fields to remove\n\t * @param fields The replacing field objects\n\t */\n\tpublic spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this {\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length - deleteCount, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\t\tif (this.data.fields) this.data.fields.splice(index, deleteCount, ...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the embed's fields\n\t *\n\t * @remarks\n\t * This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,\n\t * it splices the entire array of fields, replacing them with the provided fields.\n\t *\n\t * You can set a maximum of 25 fields.\n\t *\n\t * @param fields The fields to set\n\t */\n\tpublic setFields(...fields: RestOrArray<APIEmbedField>) {\n\t\tthis.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the author of this embed\n\t *\n\t * @param options The options for the author\n\t */\n\n\tpublic setAuthor(options: EmbedAuthorOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.author = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedAuthorPredicate.parse(options);\n\n\t\tthis.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the color of this embed\n\t *\n\t * @param color The color of the embed\n\t */\n\tpublic setColor(color: number | RGBTuple | null): this {\n\t\t// Data assertions\n\t\tcolorPredicate.parse(color);\n\n\t\tif (Array.isArray(color)) {\n\t\t\tconst [red, green, blue] = color;\n\t\t\tthis.data.color = (red << 16) + (green << 8) + blue;\n\t\t\treturn this;\n\t\t}\n\t\tthis.data.color = color ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this embed\n\t *\n\t * @param description The description\n\t */\n\tpublic setDescription(description: string | null): this {\n\t\t// Data assertions\n\t\tdescriptionPredicate.parse(description);\n\n\t\tthis.data.description = description ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the footer of this embed\n\t *\n\t * @param options The options for the footer\n\t */\n\tpublic setFooter(options: EmbedFooterOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.footer = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedFooterPredicate.parse(options);\n\n\t\tthis.data.footer = { text: options.text, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the image of this embed\n\t *\n\t * @param url The URL of the image\n\t */\n\tpublic setImage(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.image = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the thumbnail of this embed\n\t *\n\t * @param url The URL of the thumbnail\n\t */\n\tpublic setThumbnail(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.thumbnail = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the timestamp of this embed\n\t *\n\t * @param timestamp The timestamp or date\n\t */\n\tpublic setTimestamp(timestamp: number | Date | null = Date.now()): this {\n\t\t// Data assertions\n\t\ttimestampPredicate.parse(timestamp);\n\n\t\tthis.data.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the title of this embed\n\t *\n\t * @param title The title\n\t */\n\tpublic setTitle(title: string | null): this {\n\t\t// Data assertions\n\t\ttitlePredicate.parse(title);\n\n\t\tthis.data.title = title ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL of this embed\n\t *\n\t * @param url The URL\n\t */\n\tpublic setURL(url: string | null): this {\n\t\t// Data assertions\n\t\turlPredicate.parse(url);\n\n\t\tthis.data.url = url ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Transforms the embed to a plain object\n\t */\n\tpublic toJSON(): APIEmbed {\n\t\treturn { ...this.data };\n\t}\n}\n"],"names":[],"mappings":";;;AAaO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE;AACzB,IAAI,IAAI,CAAC,IAAI,GAAG,EAAE,GAAG,IAAI,EAAE,CAAC;AAC5B,IAAI,IAAI,IAAI,CAAC,SAAS;AACtB,MAAM,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,CAAC;AACnE,GAAG;AACH,EAAE,SAAS,CAAC,GAAG,MAAM,EAAE;AACvB,IAAI,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;AACpC,IAAI,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AACzD,IAAI,yBAAyB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;AAC5C,IAAI,IAAI,IAAI,CAAC,IAA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,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5B,GAAG;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"Embed.mjs","sources":["../../../src/messages/embed/Embed.ts"],"sourcesContent":["import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage } from 'discord-api-types/v10';\nimport {\n\tcolorPredicate,\n\tdescriptionPredicate,\n\tembedAuthorPredicate,\n\tembedFieldsArrayPredicate,\n\tembedFooterPredicate,\n\timageURLPredicate,\n\ttimestampPredicate,\n\ttitlePredicate,\n\turlPredicate,\n\tvalidateFieldLength,\n} from './Assertions';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray';\n\nexport type RGBTuple = [red: number, green: number, blue: number];\n\nexport interface IconData {\n\t/**\n\t * The URL of the icon\n\t */\n\ticonURL?: string;\n\t/**\n\t * The proxy URL of the icon\n\t */\n\tproxyIconURL?: string;\n}\n\nexport type EmbedAuthorData = Omit<APIEmbedAuthor, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedAuthorOptions = Omit<EmbedAuthorData, 'proxyIconURL'>;\n\nexport type EmbedFooterData = Omit<APIEmbedFooter, 'icon_url' | 'proxy_icon_url'> & IconData;\n\nexport type EmbedFooterOptions = Omit<EmbedFooterData, 'proxyIconURL'>;\n\nexport interface EmbedImageData extends Omit<APIEmbedImage, 'proxy_url'> {\n\t/**\n\t * The proxy URL for the image\n\t */\n\tproxyURL?: string;\n}\n/**\n * Represents a embed in a message (image/video preview, rich embed, etc.)\n */\nexport class EmbedBuilder {\n\tpublic readonly data: APIEmbed;\n\n\tpublic constructor(data: APIEmbed = {}) {\n\t\tthis.data = { ...data };\n\t\tif (data.timestamp) this.data.timestamp = new Date(data.timestamp).toISOString();\n\t}\n\n\t/**\n\t * Appends fields to the embed\n\t *\n\t * @remarks\n\t * This method accepts either an array of fields or a variable number of field parameters.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * @example\n\t * Using an array\n\t * ```ts\n\t * const fields: APIEmbedField[] = ...;\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(fields);\n\t * ```\n\t *\n\t * @example\n\t * Using rest parameters (variadic)\n\t * ```ts\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(\n\t * \t\t{ name: 'Field 1', value: 'Value 1' },\n\t * \t\t{ name: 'Field 2', value: 'Value 2' },\n\t * \t);\n\t * ```\n\t *\n\t * @param fields - The fields to add\n\t */\n\tpublic addFields(...fields: RestOrArray<APIEmbedField>): this {\n\t\tfields = normalizeArray(fields);\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\n\t\tif (this.data.fields) this.data.fields.push(...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes, replaces, or inserts fields in the embed.\n\t *\n\t * @remarks\n\t * This method behaves similarly\n\t * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice}.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * It's useful for modifying and adjusting order of the already-existing fields of an embed.\n\t *\n\t * @example\n\t * Remove the first field\n\t * ```ts\n\t * embed.spliceFields(0, 1);\n\t * ```\n\t *\n\t * @example\n\t * Remove the first n fields\n\t * ```ts\n\t * const n = 4\n\t * embed.spliceFields(0, n);\n\t * ```\n\t *\n\t * @example\n\t * Remove the last field\n\t * ```ts\n\t * embed.spliceFields(-1, 1);\n\t * ```\n\t *\n\t * @param index - The index to start at\n\t * @param deleteCount - The number of fields to remove\n\t * @param fields - The replacing field objects\n\t */\n\tpublic spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this {\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length - deleteCount, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\t\tif (this.data.fields) this.data.fields.splice(index, deleteCount, ...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the embed's fields\n\t *\n\t * @remarks\n\t * This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,\n\t * it splices the entire array of fields, replacing them with the provided fields.\n\t *\n\t * You can set a maximum of 25 fields.\n\t *\n\t * @param fields - The fields to set\n\t */\n\tpublic setFields(...fields: RestOrArray<APIEmbedField>) {\n\t\tthis.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the author of this embed\n\t *\n\t * @param options - The options for the author\n\t */\n\n\tpublic setAuthor(options: EmbedAuthorOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.author = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedAuthorPredicate.parse(options);\n\n\t\tthis.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the color of this embed\n\t *\n\t * @param color - The color of the embed\n\t */\n\tpublic setColor(color: number | RGBTuple | null): this {\n\t\t// Data assertions\n\t\tcolorPredicate.parse(color);\n\n\t\tif (Array.isArray(color)) {\n\t\t\tconst [red, green, blue] = color;\n\t\t\tthis.data.color = (red << 16) + (green << 8) + blue;\n\t\t\treturn this;\n\t\t}\n\t\tthis.data.color = color ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this embed\n\t *\n\t * @param description - The description\n\t */\n\tpublic setDescription(description: string | null): this {\n\t\t// Data assertions\n\t\tdescriptionPredicate.parse(description);\n\n\t\tthis.data.description = description ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the footer of this embed\n\t *\n\t * @param options - The options for the footer\n\t */\n\tpublic setFooter(options: EmbedFooterOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.footer = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedFooterPredicate.parse(options);\n\n\t\tthis.data.footer = { text: options.text, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the image of this embed\n\t *\n\t * @param url - The URL of the image\n\t */\n\tpublic setImage(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.image = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the thumbnail of this embed\n\t *\n\t * @param url - The URL of the thumbnail\n\t */\n\tpublic setThumbnail(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.thumbnail = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the timestamp of this embed\n\t *\n\t * @param timestamp - The timestamp or date\n\t */\n\tpublic setTimestamp(timestamp: number | Date | null = Date.now()): this {\n\t\t// Data assertions\n\t\ttimestampPredicate.parse(timestamp);\n\n\t\tthis.data.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the title of this embed\n\t *\n\t * @param title - The title\n\t */\n\tpublic setTitle(title: string | null): this {\n\t\t// Data assertions\n\t\ttitlePredicate.parse(title);\n\n\t\tthis.data.title = title ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL of this embed\n\t *\n\t * @param url - The URL\n\t */\n\tpublic setURL(url: string | null): this {\n\t\t// Data assertions\n\t\turlPredicate.parse(url);\n\n\t\tthis.data.url = url ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Transforms the embed to a plain object\n\t */\n\tpublic toJSON(): APIEmbed {\n\t\treturn { ...this.data };\n\t}\n}\n"],"names":[],"mappings":";;;AAaO,MAAM,YAAY,CAAC;AAC1B,EAAE,WAAW,CAAC,IAAI,GAAG,EAAE,EAAE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,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,CAAC;AACjF,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,QAAQ,CAAC,KAAK,EAAE;AAClB,IAAI,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;AAChC,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,KAAK,CAAC,CAAC;AACtC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,CAAC,GAAG,EAAE;AACd,IAAI,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC5B,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,CAAC;AAClC,IAAI,OAAO,IAAI,CAAC;AAChB,GAAG;AACH,EAAE,MAAM,GAAG;AACX,IAAI,OAAO,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;AAC5B,GAAG;AACH;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@discordjs/builders",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0-dev.1661213491-2ecb862.0",
|
|
4
4
|
"description": "A set of builders that you can use when creating your bot",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "vitest run",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"lint": "prettier --check . && TIMING=1 eslint src __tests__ --ext mjs,js,ts",
|
|
9
9
|
"format": "prettier --write . && TIMING=1 eslint src __tests__ --ext mjs,js,ts --fix",
|
|
10
10
|
"fmt": "yarn format",
|
|
11
|
-
"docs": "downlevel-dts
|
|
11
|
+
"docs": "downlevel-dts dist docs/dist --to=3.7 && docgen -i src/index.ts -c docs/index.json -o docs/docs.json --typescript && api-extractor run --local",
|
|
12
12
|
"prepack": "yarn lint && yarn test && yarn build",
|
|
13
13
|
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'",
|
|
14
14
|
"release": "cliff-jumper"
|
|
@@ -55,30 +55,31 @@
|
|
|
55
55
|
"homepage": "https://discord.js.org",
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@sapphire/shapeshift": "^3.5.1",
|
|
58
|
-
"discord-api-types": "^0.37.
|
|
58
|
+
"discord-api-types": "^0.37.4",
|
|
59
59
|
"fast-deep-equal": "^3.1.3",
|
|
60
60
|
"ts-mixer": "^6.0.1",
|
|
61
61
|
"tslib": "^2.4.0"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@discordjs/docgen": "^0.12.1",
|
|
65
|
-
"@favware/cliff-jumper": "^1.8.
|
|
66
|
-
"@microsoft/api-extractor": "^7.29.
|
|
67
|
-
"@types/node": "^16.11.
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
69
|
-
"@typescript-eslint/parser": "^5.
|
|
70
|
-
"@vitest/coverage-c8": "^0.22.
|
|
65
|
+
"@favware/cliff-jumper": "^1.8.7",
|
|
66
|
+
"@microsoft/api-extractor": "^7.29.3",
|
|
67
|
+
"@types/node": "^16.11.52",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^5.34.0",
|
|
69
|
+
"@typescript-eslint/parser": "^5.34.0",
|
|
70
|
+
"@vitest/coverage-c8": "^0.22.1",
|
|
71
71
|
"downlevel-dts": "^0.10.0",
|
|
72
72
|
"eslint": "^8.22.0",
|
|
73
73
|
"eslint-config-marine": "^9.4.1",
|
|
74
74
|
"eslint-config-prettier": "^8.5.0",
|
|
75
|
-
"eslint-import-resolver-typescript": "^3.
|
|
75
|
+
"eslint-import-resolver-typescript": "^3.5.0",
|
|
76
76
|
"eslint-plugin-import": "^2.26.0",
|
|
77
|
+
"eslint-plugin-tsdoc": "^0.2.16",
|
|
77
78
|
"prettier": "^2.7.1",
|
|
78
|
-
"rollup-plugin-typescript2": "0.
|
|
79
|
+
"rollup-plugin-typescript2": "^0.33.0",
|
|
79
80
|
"typescript": "^4.7.4",
|
|
80
|
-
"unbuild": "^0.8.
|
|
81
|
-
"vitest": "^0.22.
|
|
81
|
+
"unbuild": "^0.8.9",
|
|
82
|
+
"vitest": "^0.22.1"
|
|
82
83
|
},
|
|
83
84
|
"engines": {
|
|
84
85
|
"node": ">=16.9.0"
|