@discordjs/builders 0.4.0 → 0.8.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.
Files changed (69) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +28 -8
  3. package/dist/index.d.ts +818 -12
  4. package/dist/index.js +4 -16
  5. package/dist/index.js.map +7 -1
  6. package/dist/index.mjs +4 -32
  7. package/dist/index.mjs.map +7 -0
  8. package/package.json +65 -53
  9. package/dist/index.d.ts.map +0 -1
  10. package/dist/interactions/slashCommands/Assertions.d.ts +0 -11
  11. package/dist/interactions/slashCommands/Assertions.d.ts.map +0 -1
  12. package/dist/interactions/slashCommands/Assertions.js +0 -58
  13. package/dist/interactions/slashCommands/Assertions.js.map +0 -1
  14. package/dist/interactions/slashCommands/SlashCommandBuilder.d.ts +0 -50
  15. package/dist/interactions/slashCommands/SlashCommandBuilder.d.ts.map +0 -1
  16. package/dist/interactions/slashCommands/SlashCommandBuilder.js +0 -96
  17. package/dist/interactions/slashCommands/SlashCommandBuilder.js.map +0 -1
  18. package/dist/interactions/slashCommands/SlashCommandSubcommands.d.ts +0 -64
  19. package/dist/interactions/slashCommands/SlashCommandSubcommands.d.ts.map +0 -1
  20. package/dist/interactions/slashCommands/SlashCommandSubcommands.js +0 -123
  21. package/dist/interactions/slashCommands/SlashCommandSubcommands.js.map +0 -1
  22. package/dist/interactions/slashCommands/mixins/CommandOptionBase.d.ts +0 -20
  23. package/dist/interactions/slashCommands/mixins/CommandOptionBase.d.ts.map +0 -1
  24. package/dist/interactions/slashCommands/mixins/CommandOptionBase.js +0 -48
  25. package/dist/interactions/slashCommands/mixins/CommandOptionBase.js.map +0 -1
  26. package/dist/interactions/slashCommands/mixins/CommandOptionWithChoices.d.ts +0 -25
  27. package/dist/interactions/slashCommands/mixins/CommandOptionWithChoices.d.ts.map +0 -1
  28. package/dist/interactions/slashCommands/mixins/CommandOptionWithChoices.js +0 -59
  29. package/dist/interactions/slashCommands/mixins/CommandOptionWithChoices.js.map +0 -1
  30. package/dist/interactions/slashCommands/mixins/CommandOptions.d.ts +0 -48
  31. package/dist/interactions/slashCommands/mixins/CommandOptions.d.ts.map +0 -1
  32. package/dist/interactions/slashCommands/mixins/CommandOptions.js +0 -83
  33. package/dist/interactions/slashCommands/mixins/CommandOptions.js.map +0 -1
  34. package/dist/interactions/slashCommands/mixins/NameAndDescription.d.ts +0 -15
  35. package/dist/interactions/slashCommands/mixins/NameAndDescription.d.ts.map +0 -1
  36. package/dist/interactions/slashCommands/mixins/NameAndDescription.js +0 -42
  37. package/dist/interactions/slashCommands/mixins/NameAndDescription.js.map +0 -1
  38. package/dist/interactions/slashCommands/options/boolean.d.ts +0 -7
  39. package/dist/interactions/slashCommands/options/boolean.d.ts.map +0 -1
  40. package/dist/interactions/slashCommands/options/boolean.js +0 -18
  41. package/dist/interactions/slashCommands/options/boolean.js.map +0 -1
  42. package/dist/interactions/slashCommands/options/channel.d.ts +0 -7
  43. package/dist/interactions/slashCommands/options/channel.d.ts.map +0 -1
  44. package/dist/interactions/slashCommands/options/channel.js +0 -18
  45. package/dist/interactions/slashCommands/options/channel.js.map +0 -1
  46. package/dist/interactions/slashCommands/options/integer.d.ts +0 -7
  47. package/dist/interactions/slashCommands/options/integer.d.ts.map +0 -1
  48. package/dist/interactions/slashCommands/options/integer.js +0 -18
  49. package/dist/interactions/slashCommands/options/integer.js.map +0 -1
  50. package/dist/interactions/slashCommands/options/mentionable.d.ts +0 -7
  51. package/dist/interactions/slashCommands/options/mentionable.d.ts.map +0 -1
  52. package/dist/interactions/slashCommands/options/mentionable.js +0 -18
  53. package/dist/interactions/slashCommands/options/mentionable.js.map +0 -1
  54. package/dist/interactions/slashCommands/options/role.d.ts +0 -7
  55. package/dist/interactions/slashCommands/options/role.d.ts.map +0 -1
  56. package/dist/interactions/slashCommands/options/role.js +0 -18
  57. package/dist/interactions/slashCommands/options/role.js.map +0 -1
  58. package/dist/interactions/slashCommands/options/string.d.ts +0 -7
  59. package/dist/interactions/slashCommands/options/string.d.ts.map +0 -1
  60. package/dist/interactions/slashCommands/options/string.js +0 -18
  61. package/dist/interactions/slashCommands/options/string.js.map +0 -1
  62. package/dist/interactions/slashCommands/options/user.d.ts +0 -7
  63. package/dist/interactions/slashCommands/options/user.d.ts.map +0 -1
  64. package/dist/interactions/slashCommands/options/user.js +0 -18
  65. package/dist/interactions/slashCommands/options/user.js.map +0 -1
  66. package/dist/messages/formatters.d.ts +0 -207
  67. package/dist/messages/formatters.d.ts.map +0 -1
  68. package/dist/messages/formatters.js +0 -184
  69. package/dist/messages/formatters.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"Assertions.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/Assertions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,6BAA6B,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAEnH,wBAAgB,0BAA0B,CACzC,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,8BAA8B,EAAE,QAUzC;AAUD,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,IAAI,MAAM,CAElE;AAID,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,OAAO,GAAG,OAAO,CAAC,WAAW,IAAI,MAAM,CAEvF;AAID,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,8BAA8B,EAAE,CAE9G;AAED,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,iCAAiC,EAAE,QAEpF;AAED,wBAAgB,qBAAqB,CACpC,CAAC,SAAS,sBAAsB,GAAG,6BAA6B,GAAG,kCAAkC,EACpG,KAAK,EAAE,OAAO,EAAE,kBAAkB,EAAE,UAAU,CAAC,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,CAuBrE"}
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertReturnOfBuilder = exports.validateMaxChoicesLength = exports.validateMaxOptionsLength = exports.validateDescription = exports.validateName = exports.validateRequiredParameters = void 0;
4
- const tslib_1 = require("tslib");
5
- const is_1 = tslib_1.__importDefault(require("@sindresorhus/is"));
6
- const ow_1 = tslib_1.__importDefault(require("ow"));
7
- function validateRequiredParameters(name, description, options) {
8
- // Assert name matches all conditions
9
- validateName(name);
10
- // Assert description conditions
11
- validateDescription(description);
12
- // Assert options conditions
13
- validateMaxOptionsLength(options);
14
- }
15
- exports.validateRequiredParameters = validateRequiredParameters;
16
- const namePredicate = ow_1.default.string.lowercase
17
- .minLength(1)
18
- .maxLength(32)
19
- .addValidator({
20
- message: (value, label) => `Expected ${label} to match "^[\\p{L}\\p{N}_-]+$", got ${value} instead`,
21
- validator: (value) => /^[\p{L}\p{N}_-]+$/u.test(value),
22
- });
23
- function validateName(name) {
24
- ow_1.default(name, 'name', namePredicate);
25
- }
26
- exports.validateName = validateName;
27
- const descriptionPredicate = ow_1.default.string.minLength(1).maxLength(100);
28
- function validateDescription(description) {
29
- ow_1.default(description, 'description', descriptionPredicate);
30
- }
31
- exports.validateDescription = validateDescription;
32
- const maxArrayLengthPredicate = ow_1.default.array.maxLength(25);
33
- function validateMaxOptionsLength(options) {
34
- ow_1.default(options, 'options', maxArrayLengthPredicate);
35
- }
36
- exports.validateMaxOptionsLength = validateMaxOptionsLength;
37
- function validateMaxChoicesLength(choices) {
38
- ow_1.default(choices, 'choices', maxArrayLengthPredicate);
39
- }
40
- exports.validateMaxChoicesLength = validateMaxChoicesLength;
41
- function assertReturnOfBuilder(input, ExpectedInstanceOf) {
42
- const instanceName = ExpectedInstanceOf.name;
43
- if (is_1.default.nullOrUndefined(input)) {
44
- throw new TypeError(`Expected to receive a ${instanceName} builder, got ${input === null ? 'null' : 'undefined'} instead.`);
45
- }
46
- if (is_1.default.primitive(input)) {
47
- throw new TypeError(`Expected to receive a ${instanceName} builder, got a primitive (${typeof input}) instead.`);
48
- }
49
- if (!(input instanceof ExpectedInstanceOf)) {
50
- const casted = input;
51
- const constructorName = is_1.default.function_(input) ? input.name : casted.constructor.name;
52
- const stringTag = Reflect.get(casted, Symbol.toStringTag);
53
- const fullResultName = stringTag ? `${constructorName} [${stringTag}]` : constructorName;
54
- throw new TypeError(`Expected to receive a ${instanceName} builder, got ${fullResultName} instead.`);
55
- }
56
- }
57
- exports.assertReturnOfBuilder = assertReturnOfBuilder;
58
- //# sourceMappingURL=Assertions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Assertions.js","sourceRoot":"/","sources":["interactions/slashCommands/Assertions.ts"],"names":[],"mappings":";;;;AAAA,kEAAkC;AAElC,oDAAoB;AAKpB,SAAgB,0BAA0B,CACzC,IAAY,EACZ,WAAmB,EACnB,OAAyC;IAEzC,qCAAqC;IACrC,YAAY,CAAC,IAAI,CAAC,CAAC;IAEnB,gCAAgC;IAChC,mBAAmB,CAAC,WAAW,CAAC,CAAC;IAEjC,4BAA4B;IAC5B,wBAAwB,CAAC,OAAO,CAAC,CAAC;AACnC,CAAC;AAbD,gEAaC;AAED,MAAM,aAAa,GAAG,YAAE,CAAC,MAAM,CAAC,SAAS;KACvC,SAAS,CAAC,CAAC,CAAC;KACZ,SAAS,CAAC,EAAE,CAAC;KACb,YAAY,CAAC;IACb,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,YAAY,KAAM,wCAAwC,KAAK,UAAU;IACpG,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,KAAK,CAAC;CACtD,CAAC,CAAC;AAEJ,SAAgB,YAAY,CAAC,IAAa;IACzC,YAAE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CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC;QACnF,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,WAAW,CAAuB,CAAC;QAEhF,MAAM,cAAc,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,eAAe,KAAK,SAAS,GAAG,CAAC,CAAC,CAAC,eAAe,CAAC;QAEzF,MAAM,IAAI,SAAS,CAAC,yBAAyB,YAAY,iBAAiB,cAAc,WAAW,CAAC,CAAC;KACrG;AACF,CAAC;AAzBD,sDAyBC","sourcesContent":["import is from '@sindresorhus/is';\nimport type { APIApplicationCommandOptionChoice } from 'discord-api-types/v9';\nimport ow from 'ow';\nimport type { SlashCommandOptionBase } from './mixins/CommandOptionBase';\nimport type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';\nimport type { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';\n\nexport function validateRequiredParameters(\n\tname: string,\n\tdescription: string,\n\toptions: ToAPIApplicationCommandOptions[],\n) {\n\t// Assert name matches all conditions\n\tvalidateName(name);\n\n\t// Assert description conditions\n\tvalidateDescription(description);\n\n\t// Assert options conditions\n\tvalidateMaxOptionsLength(options);\n}\n\nconst namePredicate = ow.string.lowercase\n\t.minLength(1)\n\t.maxLength(32)\n\t.addValidator({\n\t\tmessage: (value, label) => `Expected ${label!} to match \"^[\\\\p{L}\\\\p{N}_-]+$\", got ${value} instead`,\n\t\tvalidator: (value) => /^[\\p{L}\\p{N}_-]+$/u.test(value),\n\t});\n\nexport function validateName(name: unknown): asserts name is string {\n\tow(name, 'name', namePredicate);\n}\n\nconst descriptionPredicate = ow.string.minLength(1).maxLength(100);\n\nexport function validateDescription(description: unknown): asserts description is string {\n\tow(description, 'description', descriptionPredicate);\n}\n\nconst maxArrayLengthPredicate = ow.array.maxLength(25);\n\nexport function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[] {\n\tow(options, 'options', maxArrayLengthPredicate);\n}\n\nexport function validateMaxChoicesLength(choices: APIApplicationCommandOptionChoice[]) {\n\tow(choices, 'choices', maxArrayLengthPredicate);\n}\n\nexport function assertReturnOfBuilder<\n\tT extends SlashCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder,\n>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T {\n\tconst instanceName = ExpectedInstanceOf.name;\n\n\tif (is.nullOrUndefined(input)) {\n\t\tthrow new TypeError(\n\t\t\t`Expected to receive a ${instanceName} builder, got ${input === null ? 'null' : 'undefined'} instead.`,\n\t\t);\n\t}\n\n\tif (is.primitive(input)) {\n\t\tthrow new TypeError(`Expected to receive a ${instanceName} builder, got a primitive (${typeof input}) instead.`);\n\t}\n\n\tif (!(input instanceof ExpectedInstanceOf)) {\n\t\tconst casted = input as Record<PropertyKey, unknown>;\n\n\t\tconst constructorName = is.function_(input) ? input.name : casted.constructor.name;\n\t\tconst stringTag = Reflect.get(casted, Symbol.toStringTag) as string | undefined;\n\n\t\tconst fullResultName = stringTag ? `${constructorName} [${stringTag}]` : constructorName;\n\n\t\tthrow new TypeError(`Expected to receive a ${instanceName} builder, got ${fullResultName} instead.`);\n\t}\n}\n"]}
@@ -1,50 +0,0 @@
1
- import type { APIApplicationCommandOption } from 'discord-api-types/v9';
2
- import { SharedNameAndDescription } from './mixins/NameAndDescription';
3
- import { SharedSlashCommandOptions } from './mixins/CommandOptions';
4
- import { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';
5
- export declare class SlashCommandBuilder {
6
- /**
7
- * The name of this slash command
8
- */
9
- readonly name: string;
10
- /**
11
- * The description of this slash command
12
- */
13
- readonly description: string;
14
- /**
15
- * The options of this slash command
16
- */
17
- readonly options: ToAPIApplicationCommandOptions[];
18
- /**
19
- * Returns the final data that should be sent to Discord.
20
- *
21
- * **Note:** Calling this function will validate required properties based on their conditions.
22
- */
23
- toJSON(): {
24
- name: string;
25
- description: string;
26
- options: APIApplicationCommandOption[];
27
- };
28
- /**
29
- * Adds a new subcommand group to this command
30
- * @param input A function that returns a subcommand group builder, or an already built builder
31
- */
32
- addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandGroupsOnlyBuilder;
33
- /**
34
- * Adds a new subcommand to this command
35
- * @param input A function that returns a subcommand builder, or an already built builder
36
- */
37
- addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
38
- }
39
- export interface SlashCommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {
40
- }
41
- export interface SlashCommandSubcommandsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'toJSON' | 'addSubcommand'> {
42
- }
43
- export interface SlashCommandSubcommandGroupsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'toJSON' | 'addSubcommandGroup'> {
44
- }
45
- export interface SlashCommandOptionsOnlyBuilder extends SharedNameAndDescription, SharedSlashCommandOptions, Pick<SlashCommandBuilder, 'toJSON'> {
46
- }
47
- export interface ToAPIApplicationCommandOptions {
48
- toJSON(): APIApplicationCommandOption;
49
- }
50
- //# sourceMappingURL=SlashCommandBuilder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SlashCommandBuilder.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/SlashCommandBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAGxE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,kCAAkC,EAAE,MAAM,2BAA2B,CAAC;AAE9G,qBACa,mBAAmB;IAC/B;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAc;IAE1C;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAc;IAEjD;;OAEG;IACH,SAAgB,OAAO,EAAE,8BAA8B,EAAE,CAAM;IAE/D;;;;OAIG;IACI,MAAM;;;;;IASb;;;OAGG;IACI,kBAAkB,CACxB,KAAK,EACF,kCAAkC,GAClC,CAAC,CAAC,eAAe,EAAE,kCAAkC,KAAK,kCAAkC,CAAC,GAC9F,uCAAuC;IAqB1C;;;OAGG;IACI,aAAa,CACnB,KAAK,EACF,6BAA6B,GAC7B,CAAC,CAAC,eAAe,EAAE,6BAA6B,KAAK,6BAA6B,CAAC,GACpF,kCAAkC;CAqBrC;AAED,MAAM,WAAW,mBAAoB,SAAQ,wBAAwB,EAAE,yBAAyB;CAAG;AAEnG,MAAM,WAAW,kCAChB,SAAQ,wBAAwB,EAC/B,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,eAAe,CAAC;CAAG;AAE1D,MAAM,WAAW,uCAChB,SAAQ,wBAAwB,EAC/B,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,oBAAoB,CAAC;CAAG;AAE/D,MAAM,WAAW,8BAChB,SAAQ,wBAAwB,EAC/B,yBAAyB,EACzB,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAC;CAAG;AAExC,MAAM,WAAW,8BAA8B;IAC9C,MAAM,IAAI,2BAA2B,CAAC;CACtC"}
@@ -1,96 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlashCommandBuilder = void 0;
4
- const tslib_1 = require("tslib");
5
- const ts_mixer_1 = require("ts-mixer");
6
- const Assertions_1 = require("./Assertions");
7
- const NameAndDescription_1 = require("./mixins/NameAndDescription");
8
- const CommandOptions_1 = require("./mixins/CommandOptions");
9
- const SlashCommandSubcommands_1 = require("./SlashCommandSubcommands");
10
- let SlashCommandBuilder = class SlashCommandBuilder {
11
- constructor() {
12
- /**
13
- * The name of this slash command
14
- */
15
- Object.defineProperty(this, "name", {
16
- enumerable: true,
17
- configurable: true,
18
- writable: true,
19
- value: undefined
20
- });
21
- /**
22
- * The description of this slash command
23
- */
24
- Object.defineProperty(this, "description", {
25
- enumerable: true,
26
- configurable: true,
27
- writable: true,
28
- value: undefined
29
- });
30
- /**
31
- * The options of this slash command
32
- */
33
- Object.defineProperty(this, "options", {
34
- enumerable: true,
35
- configurable: true,
36
- writable: true,
37
- value: []
38
- });
39
- }
40
- /**
41
- * Returns the final data that should be sent to Discord.
42
- *
43
- * **Note:** Calling this function will validate required properties based on their conditions.
44
- */
45
- toJSON() {
46
- Assertions_1.validateRequiredParameters(this.name, this.description, this.options);
47
- return {
48
- name: this.name,
49
- description: this.description,
50
- options: this.options.map((option) => option.toJSON()),
51
- };
52
- }
53
- /**
54
- * Adds a new subcommand group to this command
55
- * @param input A function that returns a subcommand group builder, or an already built builder
56
- */
57
- addSubcommandGroup(input) {
58
- const { options } = this;
59
- // First, assert options conditions - we cannot have more than 25 options
60
- Assertions_1.validateMaxOptionsLength(options);
61
- // Make sure there is no subcommand at the root level - if there is, throw
62
- const hasSubcommands = options.some((item) => item instanceof SlashCommandSubcommands_1.SlashCommandSubcommandBuilder);
63
- if (hasSubcommands)
64
- throw new RangeError(`You cannot mix subcommands and subcommand groups at the root level.`);
65
- // Get the final result
66
- const result = typeof input === 'function' ? input(new SlashCommandSubcommands_1.SlashCommandSubcommandGroupBuilder()) : input;
67
- Assertions_1.assertReturnOfBuilder(result, SlashCommandSubcommands_1.SlashCommandSubcommandGroupBuilder);
68
- // Push it
69
- options.push(result);
70
- return this;
71
- }
72
- /**
73
- * Adds a new subcommand to this command
74
- * @param input A function that returns a subcommand builder, or an already built builder
75
- */
76
- addSubcommand(input) {
77
- const { options } = this;
78
- // First, assert options conditions - we cannot have more than 25 options
79
- Assertions_1.validateMaxOptionsLength(options);
80
- // Make sure there is no subcommand at the root level - if there is, throw
81
- const hasSubcommandGroups = options.some((item) => item instanceof SlashCommandSubcommands_1.SlashCommandSubcommandGroupBuilder);
82
- if (hasSubcommandGroups)
83
- throw new RangeError(`You cannot mix subcommands and subcommand groups at the root level.`);
84
- // Get the final result
85
- const result = typeof input === 'function' ? input(new SlashCommandSubcommands_1.SlashCommandSubcommandBuilder()) : input;
86
- Assertions_1.assertReturnOfBuilder(result, SlashCommandSubcommands_1.SlashCommandSubcommandBuilder);
87
- // Push it
88
- options.push(result);
89
- return this;
90
- }
91
- };
92
- SlashCommandBuilder = tslib_1.__decorate([
93
- ts_mixer_1.mix(CommandOptions_1.SharedSlashCommandOptions, NameAndDescription_1.SharedNameAndDescription)
94
- ], SlashCommandBuilder);
95
- exports.SlashCommandBuilder = SlashCommandBuilder;
96
- //# sourceMappingURL=SlashCommandBuilder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SlashCommandBuilder.js","sourceRoot":"/","sources":["interactions/slashCommands/SlashCommandBuilder.ts"],"names":[],"mappings":";;;;AACA,uCAA+B;AAC/B,6CAA2G;AAC3G,oEAAuE;AACvE,4DAAoE;AACpE,uEAA8G;AAG9G,IAAa,mBAAmB,GAAhC,MAAa,mBAAmB;IAAhC;QACC;;WAEG;QACH;;;;mBAA+B,SAAU;WAAC;QAE1C;;WAEG;QACH;;;;mBAAsC,SAAU;WAAC;QAEjD;;WAEG;QACH;;;;mBAA4D,EAAE;WAAC;IA0EhE,CAAC;IAxEA;;;;OAIG;IACI,MAAM;QACZ,uCAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACtE,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC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AAU;QACV,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAErB,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAA;AAxFY,mBAAmB;IAD/B,cAAG,CAAC,0CAAyB,EAAE,6CAAwB,CAAC;GAC5C,mBAAmB,CAwF/B;AAxFY,kDAAmB","sourcesContent":["import type { APIApplicationCommandOption } from 'discord-api-types/v9';\nimport { mix } from 'ts-mixer';\nimport { assertReturnOfBuilder, validateMaxOptionsLength, validateRequiredParameters } from './Assertions';\nimport { SharedNameAndDescription } from './mixins/NameAndDescription';\nimport { SharedSlashCommandOptions } from './mixins/CommandOptions';\nimport { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';\n\n@mix(SharedSlashCommandOptions, SharedNameAndDescription)\nexport class SlashCommandBuilder {\n\t/**\n\t * The name of this slash command\n\t */\n\tpublic readonly name: string = undefined!;\n\n\t/**\n\t * The description of this slash command\n\t */\n\tpublic readonly description: string = undefined!;\n\n\t/**\n\t * The options of this slash command\n\t */\n\tpublic readonly options: ToAPIApplicationCommandOptions[] = [];\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() {\n\t\tvalidateRequiredParameters(this.name, this.description, this.options);\n\t\treturn {\n\t\t\tname: this.name,\n\t\t\tdescription: this.description,\n\t\t\toptions: this.options.map((option) => option.toJSON()),\n\t\t};\n\t}\n\n\t/**\n\t * Adds a new subcommand group to this command\n\t * @param input A function that returns a subcommand group builder, or an already built builder\n\t */\n\tpublic addSubcommandGroup(\n\t\tinput:\n\t\t\t| SlashCommandSubcommandGroupBuilder\n\t\t\t| ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder),\n\t): SlashCommandSubcommandGroupsOnlyBuilder {\n\t\tconst { options } = this;\n\n\t\t// First, assert options conditions - we cannot have more than 25 options\n\t\tvalidateMaxOptionsLength(options);\n\n\t\t// Make sure there is no subcommand at the root level - if there is, throw\n\t\tconst hasSubcommands = options.some((item) => item instanceof SlashCommandSubcommandBuilder);\n\t\tif (hasSubcommands) throw new RangeError(`You cannot mix subcommands and subcommand groups at the root level.`);\n\n\t\t// Get the final result\n\t\tconst result = typeof input === 'function' ? input(new SlashCommandSubcommandGroupBuilder()) : input;\n\n\t\tassertReturnOfBuilder(result, SlashCommandSubcommandGroupBuilder);\n\n\t\t// Push it\n\t\toptions.push(result);\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds a new subcommand to this command\n\t * @param input A function that returns a subcommand builder, or an already built builder\n\t */\n\tpublic addSubcommand(\n\t\tinput:\n\t\t\t| SlashCommandSubcommandBuilder\n\t\t\t| ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder),\n\t): SlashCommandSubcommandsOnlyBuilder {\n\t\tconst { options } = this;\n\n\t\t// First, assert options conditions - we cannot have more than 25 options\n\t\tvalidateMaxOptionsLength(options);\n\n\t\t// Make sure there is no subcommand at the root level - if there is, throw\n\t\tconst hasSubcommandGroups = options.some((item) => item instanceof SlashCommandSubcommandGroupBuilder);\n\t\tif (hasSubcommandGroups)\n\t\t\tthrow new RangeError(`You cannot mix subcommands and subcommand groups at the root level.`);\n\n\t\t// Get the final result\n\t\tconst result = typeof input === 'function' ? input(new SlashCommandSubcommandBuilder()) : input;\n\n\t\tassertReturnOfBuilder(result, SlashCommandSubcommandBuilder);\n\n\t\t// Push it\n\t\toptions.push(result);\n\n\t\treturn this;\n\t}\n}\n\nexport interface SlashCommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {}\n\nexport interface SlashCommandSubcommandsOnlyBuilder\n\textends SharedNameAndDescription,\n\t\tPick<SlashCommandBuilder, 'toJSON' | 'addSubcommand'> {}\n\nexport interface SlashCommandSubcommandGroupsOnlyBuilder\n\textends SharedNameAndDescription,\n\t\tPick<SlashCommandBuilder, 'toJSON' | 'addSubcommandGroup'> {}\n\nexport interface SlashCommandOptionsOnlyBuilder\n\textends SharedNameAndDescription,\n\t\tSharedSlashCommandOptions,\n\t\tPick<SlashCommandBuilder, 'toJSON'> {}\n\nexport interface ToAPIApplicationCommandOptions {\n\ttoJSON(): APIApplicationCommandOption;\n}\n"]}
@@ -1,64 +0,0 @@
1
- import { ApplicationCommandOptionType } from 'discord-api-types/v9';
2
- import { SharedSlashCommandOptions } from './mixins/CommandOptions';
3
- import { SharedNameAndDescription } from './mixins/NameAndDescription';
4
- import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';
5
- /**
6
- * Represents a folder for subcommands
7
- *
8
- * For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups
9
- */
10
- export declare class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationCommandOptions {
11
- /**
12
- * The name of this subcommand group
13
- */
14
- readonly name: string;
15
- /**
16
- * The description of this subcommand group
17
- */
18
- readonly description: string;
19
- /**
20
- * The subcommands part of this subcommand group
21
- */
22
- readonly options: ToAPIApplicationCommandOptions[];
23
- /**
24
- * Adds a new subcommand to this group
25
- * @param input A function that returns a subcommand builder, or an already built builder
26
- */
27
- addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): this;
28
- toJSON(): {
29
- type: ApplicationCommandOptionType;
30
- name: string;
31
- description: string;
32
- options: import("discord-api-types/v9").APIApplicationCommandOption[];
33
- };
34
- }
35
- export interface SlashCommandSubcommandGroupBuilder extends SharedNameAndDescription {
36
- }
37
- /**
38
- * Represents a subcommand
39
- *
40
- * For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups
41
- */
42
- export declare class SlashCommandSubcommandBuilder implements ToAPIApplicationCommandOptions {
43
- /**
44
- * The name of this subcommand
45
- */
46
- readonly name: string;
47
- /**
48
- * The description of this subcommand
49
- */
50
- readonly description: string;
51
- /**
52
- * The options of this subcommand
53
- */
54
- readonly options: ToAPIApplicationCommandOptions[];
55
- toJSON(): {
56
- type: ApplicationCommandOptionType;
57
- name: string;
58
- description: string;
59
- options: import("discord-api-types/v9").APIApplicationCommandOption[];
60
- };
61
- }
62
- export interface SlashCommandSubcommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions<false> {
63
- }
64
- //# sourceMappingURL=SlashCommandSubcommands.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SlashCommandSubcommands.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/SlashCommandSubcommands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGpE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,uBAAuB,CAAC;AAE5E;;;;GAIG;AACH,qBACa,kCAAmC,YAAW,8BAA8B;IACxF;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAc;IAE1C;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAc;IAEjD;;OAEG;IACH,SAAgB,OAAO,EAAE,8BAA8B,EAAE,CAAM;IAE/D;;;OAGG;IACI,aAAa,CACnB,KAAK,EACF,6BAA6B,GAC7B,CAAC,CAAC,eAAe,EAAE,6BAA6B,KAAK,6BAA6B,CAAC;IAkBhF,MAAM;;;;;;CASb;AAED,MAAM,WAAW,kCAAmC,SAAQ,wBAAwB;CAAG;AAEvF;;;;GAIG;AACH,qBACa,6BAA8B,YAAW,8BAA8B;IACnF;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAc;IAE1C;;OAEG;IACH,SAAgB,WAAW,EAAE,MAAM,CAAc;IAEjD;;OAEG;IACH,SAAgB,OAAO,EAAE,8BAA8B,EAAE,CAAM;IAExD,MAAM;;;;;;CASb;AAED,MAAM,WAAW,6BAA8B,SAAQ,wBAAwB,EAAE,yBAAyB,CAAC,KAAK,CAAC;CAAG"}
@@ -1,123 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlashCommandSubcommandBuilder = exports.SlashCommandSubcommandGroupBuilder = void 0;
4
- const tslib_1 = require("tslib");
5
- require("discord-api-types/v9");
6
- const ts_mixer_1 = require("ts-mixer");
7
- const Assertions_1 = require("./Assertions");
8
- const CommandOptions_1 = require("./mixins/CommandOptions");
9
- const NameAndDescription_1 = require("./mixins/NameAndDescription");
10
- /**
11
- * Represents a folder for subcommands
12
- *
13
- * For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups
14
- */
15
- let SlashCommandSubcommandGroupBuilder = class SlashCommandSubcommandGroupBuilder {
16
- constructor() {
17
- /**
18
- * The name of this subcommand group
19
- */
20
- Object.defineProperty(this, "name", {
21
- enumerable: true,
22
- configurable: true,
23
- writable: true,
24
- value: undefined
25
- });
26
- /**
27
- * The description of this subcommand group
28
- */
29
- Object.defineProperty(this, "description", {
30
- enumerable: true,
31
- configurable: true,
32
- writable: true,
33
- value: undefined
34
- });
35
- /**
36
- * The subcommands part of this subcommand group
37
- */
38
- Object.defineProperty(this, "options", {
39
- enumerable: true,
40
- configurable: true,
41
- writable: true,
42
- value: []
43
- });
44
- }
45
- /**
46
- * Adds a new subcommand to this group
47
- * @param input A function that returns a subcommand builder, or an already built builder
48
- */
49
- addSubcommand(input) {
50
- const { options } = this;
51
- // First, assert options conditions - we cannot have more than 25 options
52
- Assertions_1.validateMaxOptionsLength(options);
53
- // Get the final result
54
- const result = typeof input === 'function' ? input(new SlashCommandSubcommandBuilder()) : input;
55
- Assertions_1.assertReturnOfBuilder(result, SlashCommandSubcommandBuilder);
56
- // Push it
57
- options.push(result);
58
- return this;
59
- }
60
- toJSON() {
61
- Assertions_1.validateRequiredParameters(this.name, this.description, this.options);
62
- return {
63
- type: 2 /* SubcommandGroup */,
64
- name: this.name,
65
- description: this.description,
66
- options: this.options.map((option) => option.toJSON()),
67
- };
68
- }
69
- };
70
- SlashCommandSubcommandGroupBuilder = tslib_1.__decorate([
71
- ts_mixer_1.mix(NameAndDescription_1.SharedNameAndDescription)
72
- ], SlashCommandSubcommandGroupBuilder);
73
- exports.SlashCommandSubcommandGroupBuilder = SlashCommandSubcommandGroupBuilder;
74
- /**
75
- * Represents a subcommand
76
- *
77
- * For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups
78
- */
79
- let SlashCommandSubcommandBuilder = class SlashCommandSubcommandBuilder {
80
- constructor() {
81
- /**
82
- * The name of this subcommand
83
- */
84
- Object.defineProperty(this, "name", {
85
- enumerable: true,
86
- configurable: true,
87
- writable: true,
88
- value: undefined
89
- });
90
- /**
91
- * The description of this subcommand
92
- */
93
- Object.defineProperty(this, "description", {
94
- enumerable: true,
95
- configurable: true,
96
- writable: true,
97
- value: undefined
98
- });
99
- /**
100
- * The options of this subcommand
101
- */
102
- Object.defineProperty(this, "options", {
103
- enumerable: true,
104
- configurable: true,
105
- writable: true,
106
- value: []
107
- });
108
- }
109
- toJSON() {
110
- Assertions_1.validateRequiredParameters(this.name, this.description, this.options);
111
- return {
112
- type: 1 /* Subcommand */,
113
- name: this.name,
114
- description: this.description,
115
- options: this.options.map((option) => option.toJSON()),
116
- };
117
- }
118
- };
119
- SlashCommandSubcommandBuilder = tslib_1.__decorate([
120
- ts_mixer_1.mix(NameAndDescription_1.SharedNameAndDescription, CommandOptions_1.SharedSlashCommandOptions)
121
- ], SlashCommandSubcommandBuilder);
122
- exports.SlashCommandSubcommandBuilder = SlashCommandSubcommandBuilder;
123
- //# sourceMappingURL=SlashCommandSubcommands.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SlashCommandSubcommands.js","sourceRoot":"/","sources":["interactions/slashCommands/SlashCommandSubcommands.ts"],"names":[],"mappings":";;;;AAAA,gCAAoE;AACpE,uCAA+B;AAC/B,6CAA2G;AAC3G,4DAAoE;AACpE,oEAAuE;A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AsC,SAAU;WAAC;QAEjD;;WAEG;QACH;;;;mBAA4D,EAAE;WAAC;IAWhE,CAAC;IATO,MAAM;QACZ,uCAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACtE,OAAO;YACN,IAAI,oBAAyC;YAC7C,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;SACtD,CAAC;IACH,CAAC;CACD,CAAA;AAzBY,6BAA6B;IADzC,cAAG,CAAC,6CAAwB,EAAE,0CAAyB,CAAC;GAC5C,6BAA6B,CAyBzC;AAzBY,sEAA6B","sourcesContent":["import { ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport { mix } from 'ts-mixer';\nimport { assertReturnOfBuilder, validateMaxOptionsLength, validateRequiredParameters } from './Assertions';\nimport { SharedSlashCommandOptions } from './mixins/CommandOptions';\nimport { SharedNameAndDescription } from './mixins/NameAndDescription';\nimport type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';\n\n/**\n * Represents a folder for subcommands\n *\n * For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups\n */\n@mix(SharedNameAndDescription)\nexport class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationCommandOptions {\n\t/**\n\t * The name of this subcommand group\n\t */\n\tpublic readonly name: string = undefined!;\n\n\t/**\n\t * The description of this subcommand group\n\t */\n\tpublic readonly description: string = undefined!;\n\n\t/**\n\t * The subcommands part of this subcommand group\n\t */\n\tpublic readonly options: ToAPIApplicationCommandOptions[] = [];\n\n\t/**\n\t * Adds a new subcommand to this group\n\t * @param input A function that returns a subcommand builder, or an already built builder\n\t */\n\tpublic addSubcommand(\n\t\tinput:\n\t\t\t| SlashCommandSubcommandBuilder\n\t\t\t| ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder),\n\t) {\n\t\tconst { options } = this;\n\n\t\t// First, assert options conditions - we cannot have more than 25 options\n\t\tvalidateMaxOptionsLength(options);\n\n\t\t// Get the final result\n\t\tconst result = typeof input === 'function' ? input(new SlashCommandSubcommandBuilder()) : input;\n\n\t\tassertReturnOfBuilder(result, SlashCommandSubcommandBuilder);\n\n\t\t// Push it\n\t\toptions.push(result);\n\n\t\treturn this;\n\t}\n\n\tpublic toJSON() {\n\t\tvalidateRequiredParameters(this.name, this.description, this.options);\n\t\treturn {\n\t\t\ttype: ApplicationCommandOptionType.SubcommandGroup,\n\t\t\tname: this.name,\n\t\t\tdescription: this.description,\n\t\t\toptions: this.options.map((option) => option.toJSON()),\n\t\t};\n\t}\n}\n\nexport interface SlashCommandSubcommandGroupBuilder extends SharedNameAndDescription {}\n\n/**\n * Represents a subcommand\n *\n * For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups\n */\n@mix(SharedNameAndDescription, SharedSlashCommandOptions)\nexport class SlashCommandSubcommandBuilder implements ToAPIApplicationCommandOptions {\n\t/**\n\t * The name of this subcommand\n\t */\n\tpublic readonly name: string = undefined!;\n\n\t/**\n\t * The description of this subcommand\n\t */\n\tpublic readonly description: string = undefined!;\n\n\t/**\n\t * The options of this subcommand\n\t */\n\tpublic readonly options: ToAPIApplicationCommandOptions[] = [];\n\n\tpublic toJSON() {\n\t\tvalidateRequiredParameters(this.name, this.description, this.options);\n\t\treturn {\n\t\t\ttype: ApplicationCommandOptionType.Subcommand,\n\t\t\tname: this.name,\n\t\t\tdescription: this.description,\n\t\t\toptions: this.options.map((option) => option.toJSON()),\n\t\t};\n\t}\n}\n\nexport interface SlashCommandSubcommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions<false> {}\n"]}
@@ -1,20 +0,0 @@
1
- import type { ApplicationCommandOptionType } from 'discord-api-types/v9';
2
- import type { ToAPIApplicationCommandOptions } from '../SlashCommandBuilder';
3
- import { SharedNameAndDescription } from './NameAndDescription';
4
- export declare class SlashCommandOptionBase extends SharedNameAndDescription implements ToAPIApplicationCommandOptions {
5
- required: boolean;
6
- readonly type: ApplicationCommandOptionType;
7
- constructor(type: ApplicationCommandOptionType);
8
- /**
9
- * Marks the option as required
10
- * @param required If this option should be required
11
- */
12
- setRequired(required: boolean): this;
13
- toJSON(): {
14
- type: ApplicationCommandOptionType;
15
- name: string;
16
- description: string;
17
- required: boolean;
18
- };
19
- }
20
- //# sourceMappingURL=CommandOptionBase.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CommandOptionBase.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/mixins/CommandOptionBase.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGzE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAEhE,qBAAa,sBAAuB,SAAQ,wBAAyB,YAAW,8BAA8B;IACtG,QAAQ,UAAS;IACxB,SAAgB,IAAI,EAAE,4BAA4B,CAAC;gBAEhC,IAAI,EAAE,4BAA4B;IAKrD;;;OAGG;IACI,WAAW,CAAC,QAAQ,EAAE,OAAO;IAS7B,MAAM;;;;;;CAab"}
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SlashCommandOptionBase = void 0;
4
- const tslib_1 = require("tslib");
5
- const ow_1 = tslib_1.__importDefault(require("ow"));
6
- const Assertions_1 = require("../Assertions");
7
- const NameAndDescription_1 = require("./NameAndDescription");
8
- class SlashCommandOptionBase extends NameAndDescription_1.SharedNameAndDescription {
9
- constructor(type) {
10
- super();
11
- Object.defineProperty(this, "required", {
12
- enumerable: true,
13
- configurable: true,
14
- writable: true,
15
- value: false
16
- });
17
- Object.defineProperty(this, "type", {
18
- enumerable: true,
19
- configurable: true,
20
- writable: true,
21
- value: void 0
22
- });
23
- this.type = type;
24
- }
25
- /**
26
- * Marks the option as required
27
- * @param required If this option should be required
28
- */
29
- setRequired(required) {
30
- // Assert that you actually passed a boolean
31
- ow_1.default(required, 'required', ow_1.default.boolean);
32
- this.required = required;
33
- return this;
34
- }
35
- toJSON() {
36
- Assertions_1.validateRequiredParameters(this.name, this.description, []);
37
- // Assert that you actually passed a boolean
38
- ow_1.default(this.required, 'required', ow_1.default.boolean);
39
- return {
40
- type: this.type,
41
- name: this.name,
42
- description: this.description,
43
- required: this.required,
44
- };
45
- }
46
- }
47
- exports.SlashCommandOptionBase = SlashCommandOptionBase;
48
- //# sourceMappingURL=CommandOptionBase.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CommandOptionBase.js","sourceRoot":"/","sources":["interactions/slashCommands/mixins/CommandOptionBase.ts"],"names":[],"mappings":";;;;AACA,oDAAoB;AACpB,8CAA2D;AAE3D,6DAAgE;AAEhE,MAAa,sBAAuB,SAAQ,6CAAwB;IAInE,YAAmB,IAAkC;QACpD,KAAK,EAAE,CAAC;QAJT;;;;mBAAkB,KAAK;WAAC;QACxB;;;;;WAAmD;QAIlD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IAClB,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,QAAiB;QACnC,4CAA4C;QAC5C,YAAE,CAAC,QAAQ,EAAE,UAAU,EAAE,YAAE,CAAC,OAAO,CAAC,CAAC;QAErC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,MAAM;QACZ,uCAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAE5D,4CAA4C;QAC5C,YAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,YAAE,CAAC,OAAO,CAAC,CAAC;QAE1C,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC;IACH,CAAC;CACD;AAnCD,wDAmCC","sourcesContent":["import type { ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport ow from 'ow';\nimport { validateRequiredParameters } from '../Assertions';\nimport type { ToAPIApplicationCommandOptions } from '../SlashCommandBuilder';\nimport { SharedNameAndDescription } from './NameAndDescription';\n\nexport class SlashCommandOptionBase extends SharedNameAndDescription implements ToAPIApplicationCommandOptions {\n\tpublic required = false;\n\tpublic readonly type: ApplicationCommandOptionType;\n\n\tpublic constructor(type: ApplicationCommandOptionType) {\n\t\tsuper();\n\t\tthis.type = type;\n\t}\n\n\t/**\n\t * Marks the option as required\n\t * @param required If this option should be required\n\t */\n\tpublic setRequired(required: boolean) {\n\t\t// Assert that you actually passed a boolean\n\t\tow(required, 'required', ow.boolean);\n\n\t\tthis.required = required;\n\n\t\treturn this;\n\t}\n\n\tpublic toJSON() {\n\t\tvalidateRequiredParameters(this.name, this.description, []);\n\n\t\t// Assert that you actually passed a boolean\n\t\tow(this.required, 'required', ow.boolean);\n\n\t\treturn {\n\t\t\ttype: this.type,\n\t\t\tname: this.name,\n\t\t\tdescription: this.description,\n\t\t\trequired: this.required,\n\t\t};\n\t}\n}\n"]}
@@ -1,25 +0,0 @@
1
- import { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from 'discord-api-types/v9';
2
- import type { ToAPIApplicationCommandOptions } from '../SlashCommandBuilder';
3
- import { SlashCommandOptionBase } from './CommandOptionBase';
4
- export declare abstract class ApplicationCommandOptionWithChoicesBase<T extends string | number> extends SlashCommandOptionBase implements ToAPIApplicationCommandOptions {
5
- choices?: APIApplicationCommandOptionChoice[];
6
- /**
7
- * Adds a choice for this option
8
- * @param name The name of the choice
9
- * @param value The value of the choice
10
- */
11
- addChoice(name: string, value: T): this;
12
- /**
13
- * Adds multiple choices for this option
14
- * @param choices The choices to add
15
- */
16
- addChoices(choices: [name: string, value: T][]): this;
17
- toJSON(): {
18
- choices: APIApplicationCommandOptionChoice[] | undefined;
19
- type: ApplicationCommandOptionType;
20
- name: string;
21
- description: string;
22
- required: boolean;
23
- };
24
- }
25
- //# sourceMappingURL=CommandOptionWithChoices.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CommandOptionWithChoices.d.ts","sourceRoot":"/","sources":["interactions/slashCommands/mixins/CommandOptionWithChoices.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAGvG,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAU7D,8BAAsB,uCAAuC,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,CACtF,SAAQ,sBACR,YAAW,8BAA8B;IAElC,OAAO,CAAC,EAAE,iCAAiC,EAAE,CAAC;IAErD;;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAqBvC;;;OAGG;IACI,UAAU,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE;IAWrC,MAAM;;;;;;;CAMtB"}
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApplicationCommandOptionWithChoicesBase = void 0;
4
- const tslib_1 = require("tslib");
5
- require("discord-api-types/v9");
6
- const ow_1 = tslib_1.__importDefault(require("ow"));
7
- const Assertions_1 = require("../Assertions");
8
- const CommandOptionBase_1 = require("./CommandOptionBase");
9
- const stringPredicate = ow_1.default.string.minLength(1).maxLength(100);
10
- const integerPredicate = ow_1.default.number.finite;
11
- // TODO: See resolution for sindresorhus/ow#217 in relation to this cast
12
- const choicesPredicate = ow_1.default.array.ofType(ow_1.default.array.exactShape([stringPredicate, ow_1.default.any(ow_1.default.string, integerPredicate)]));
13
- class ApplicationCommandOptionWithChoicesBase extends CommandOptionBase_1.SlashCommandOptionBase {
14
- constructor() {
15
- super(...arguments);
16
- Object.defineProperty(this, "choices", {
17
- enumerable: true,
18
- configurable: true,
19
- writable: true,
20
- value: void 0
21
- });
22
- }
23
- /**
24
- * Adds a choice for this option
25
- * @param name The name of the choice
26
- * @param value The value of the choice
27
- */
28
- addChoice(name, value) {
29
- this.choices ?? (this.choices = []);
30
- Assertions_1.validateMaxChoicesLength(this.choices);
31
- // Validate name
32
- ow_1.default(name, `${this.type === 3 /* String */ ? 'string' : 'integer'} choice name`, stringPredicate);
33
- // Validate the value
34
- if (this.type === 3 /* String */)
35
- ow_1.default(value, 'string choice value', stringPredicate);
36
- else
37
- ow_1.default(value, 'integer choice value', integerPredicate);
38
- this.choices.push({ name, value });
39
- return this;
40
- }
41
- /**
42
- * Adds multiple choices for this option
43
- * @param choices The choices to add
44
- */
45
- addChoices(choices) {
46
- ow_1.default(choices, `${this.type === 3 /* String */ ? 'string' : 'integer'} choices`, choicesPredicate);
47
- for (const [label, value] of choices)
48
- this.addChoice(label, value);
49
- return this;
50
- }
51
- toJSON() {
52
- return {
53
- ...super.toJSON(),
54
- choices: this.choices,
55
- };
56
- }
57
- }
58
- exports.ApplicationCommandOptionWithChoicesBase = ApplicationCommandOptionWithChoicesBase;
59
- //# sourceMappingURL=CommandOptionWithChoices.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CommandOptionWithChoices.js","sourceRoot":"/","sources":["interactions/slashCommands/mixins/CommandOptionWithChoices.ts"],"names":[],"mappings":";;;;AAAA,gCAAuG;AACvG,oDAAmC;AACnC,8CAAyD;AAEzD,2DAA6D;AAE7D,MAAM,eAAe,GAAG,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC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CAAC,IAAI,OAAO;YAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QACnE,OAAO,IAAI,CAAC;IACb,CAAC;IAEe,MAAM;QACrB,OAAO;YACN,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC;IACH,CAAC;CACD;AArDD,0FAqDC","sourcesContent":["import { APIApplicationCommandOptionChoice, ApplicationCommandOptionType } from 'discord-api-types/v9';\nimport ow, { Predicate } from 'ow';\nimport { validateMaxChoicesLength } from '../Assertions';\nimport type { ToAPIApplicationCommandOptions } from '../SlashCommandBuilder';\nimport { SlashCommandOptionBase } from './CommandOptionBase';\n\nconst stringPredicate = ow.string.minLength(1).maxLength(100);\nconst integerPredicate = ow.number.finite;\n\n// TODO: See resolution for sindresorhus/ow#217 in relation to this cast\nconst choicesPredicate = ow.array.ofType<[string, string | number]>(\n\tow.array.exactShape([stringPredicate, ow.any(ow.string, integerPredicate) as unknown as Predicate<string | number>]),\n);\n\nexport abstract class ApplicationCommandOptionWithChoicesBase<T extends string | number>\n\textends SlashCommandOptionBase\n\timplements ToAPIApplicationCommandOptions\n{\n\tpublic choices?: APIApplicationCommandOptionChoice[];\n\n\t/**\n\t * Adds a choice for this option\n\t * @param name The name of the choice\n\t * @param value The value of the choice\n\t */\n\tpublic addChoice(name: string, value: T) {\n\t\tthis.choices ??= [];\n\n\t\tvalidateMaxChoicesLength(this.choices);\n\n\t\t// Validate name\n\t\tow(\n\t\t\tname,\n\t\t\t`${this.type === ApplicationCommandOptionType.String ? 'string' : 'integer'} choice name`,\n\t\t\tstringPredicate,\n\t\t);\n\n\t\t// Validate the value\n\t\tif (this.type === ApplicationCommandOptionType.String) ow(value, 'string choice value', stringPredicate);\n\t\telse ow(value, 'integer choice value', integerPredicate);\n\n\t\tthis.choices.push({ name, value });\n\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds multiple choices for this option\n\t * @param choices The choices to add\n\t */\n\tpublic addChoices(choices: [name: string, value: T][]) {\n\t\tow(\n\t\t\tchoices,\n\t\t\t`${this.type === ApplicationCommandOptionType.String ? 'string' : 'integer'} choices`,\n\t\t\tchoicesPredicate,\n\t\t);\n\n\t\tfor (const [label, value] of choices) this.addChoice(label, value);\n\t\treturn this;\n\t}\n\n\tpublic override toJSON() {\n\t\treturn {\n\t\t\t...super.toJSON(),\n\t\t\tchoices: this.choices,\n\t\t};\n\t}\n}\n"]}