@discordjs/builders 0.6.0 → 0.8.2

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 (81) hide show
  1. package/LICENSE +1 -0
  2. package/README.md +28 -8
  3. package/dist/index.d.ts +818 -15
  4. package/dist/index.js +4 -19
  5. package/dist/index.js.map +7 -1
  6. package/dist/index.mjs +4 -36
  7. package/dist/index.mjs.map +7 -0
  8. package/package.json +63 -51
  9. package/dist/index.d.ts.map +0 -1
  10. package/dist/interactions/slashCommands/Assertions.d.ts +0 -12
  11. package/dist/interactions/slashCommands/Assertions.d.ts.map +0 -1
  12. package/dist/interactions/slashCommands/Assertions.js +0 -63
  13. package/dist/interactions/slashCommands/Assertions.js.map +0 -1
  14. package/dist/interactions/slashCommands/SlashCommandBuilder.d.ts +0 -63
  15. package/dist/interactions/slashCommands/SlashCommandBuilder.d.ts.map +0 -1
  16. package/dist/interactions/slashCommands/SlashCommandBuilder.js +0 -113
  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 -71
  29. package/dist/interactions/slashCommands/mixins/CommandOptionWithChoices.js.map +0 -1
  30. package/dist/interactions/slashCommands/mixins/CommandOptions.d.ts +0 -54
  31. package/dist/interactions/slashCommands/mixins/CommandOptions.d.ts.map +0 -1
  32. package/dist/interactions/slashCommands/mixins/CommandOptions.js +0 -91
  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/number.d.ts +0 -7
  55. package/dist/interactions/slashCommands/options/number.d.ts.map +0 -1
  56. package/dist/interactions/slashCommands/options/number.js +0 -18
  57. package/dist/interactions/slashCommands/options/number.js.map +0 -1
  58. package/dist/interactions/slashCommands/options/role.d.ts +0 -7
  59. package/dist/interactions/slashCommands/options/role.d.ts.map +0 -1
  60. package/dist/interactions/slashCommands/options/role.js +0 -18
  61. package/dist/interactions/slashCommands/options/role.js.map +0 -1
  62. package/dist/interactions/slashCommands/options/string.d.ts +0 -7
  63. package/dist/interactions/slashCommands/options/string.d.ts.map +0 -1
  64. package/dist/interactions/slashCommands/options/string.js +0 -18
  65. package/dist/interactions/slashCommands/options/string.js.map +0 -1
  66. package/dist/interactions/slashCommands/options/user.d.ts +0 -7
  67. package/dist/interactions/slashCommands/options/user.d.ts.map +0 -1
  68. package/dist/interactions/slashCommands/options/user.js +0 -18
  69. package/dist/interactions/slashCommands/options/user.js.map +0 -1
  70. package/dist/messages/embed/Assertions.d.ts +0 -23
  71. package/dist/messages/embed/Assertions.d.ts.map +0 -1
  72. package/dist/messages/embed/Assertions.js +0 -26
  73. package/dist/messages/embed/Assertions.js.map +0 -1
  74. package/dist/messages/embed/Embed.d.ts +0 -140
  75. package/dist/messages/embed/Embed.d.ts.map +0 -1
  76. package/dist/messages/embed/Embed.js +0 -300
  77. package/dist/messages/embed/Embed.js.map +0 -1
  78. package/dist/messages/formatters.d.ts +0 -198
  79. package/dist/messages/formatters.d.ts.map +0 -1
  80. package/dist/messages/formatters.js +0 -181
  81. package/dist/messages/formatters.js.map +0 -1
@@ -1,12 +0,0 @@
1
- import type { APIApplicationCommandOptionChoice } from 'discord-api-types/v9';
2
- import type { SlashCommandOptionBase } from './mixins/CommandOptionBase';
3
- import type { ToAPIApplicationCommandOptions } from './SlashCommandBuilder';
4
- import type { SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder } from './SlashCommandSubcommands';
5
- export declare function validateRequiredParameters(name: string, description: string, options: ToAPIApplicationCommandOptions[]): void;
6
- export declare function validateName(name: unknown): asserts name is string;
7
- export declare function validateDescription(description: unknown): asserts description is string;
8
- export declare function validateDefaultPermission(value: unknown): asserts value is boolean;
9
- export declare function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[];
10
- export declare function validateMaxChoicesLength(choices: APIApplicationCommandOptionChoice[]): void;
11
- export declare function assertReturnOfBuilder<T extends SlashCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
12
- //# sourceMappingURL=Assertions.d.ts.map
@@ -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,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAElF;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,63 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertReturnOfBuilder = exports.validateMaxChoicesLength = exports.validateMaxOptionsLength = exports.validateDefaultPermission = 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 defaultPermissionPredicate = ow_1.default.boolean;
33
- function validateDefaultPermission(value) {
34
- ow_1.default(value, 'default_permission', defaultPermissionPredicate);
35
- }
36
- exports.validateDefaultPermission = validateDefaultPermission;
37
- const maxArrayLengthPredicate = ow_1.default.array.maxLength(25);
38
- function validateMaxOptionsLength(options) {
39
- ow_1.default(options, 'options', maxArrayLengthPredicate);
40
- }
41
- exports.validateMaxOptionsLength = validateMaxOptionsLength;
42
- function validateMaxChoicesLength(choices) {
43
- ow_1.default(choices, 'choices', maxArrayLengthPredicate);
44
- }
45
- exports.validateMaxChoicesLength = validateMaxChoicesLength;
46
- function assertReturnOfBuilder(input, ExpectedInstanceOf) {
47
- const instanceName = ExpectedInstanceOf.name;
48
- if (is_1.default.nullOrUndefined(input)) {
49
- throw new TypeError(`Expected to receive a ${instanceName} builder, got ${input === null ? 'null' : 'undefined'} instead.`);
50
- }
51
- if (is_1.default.primitive(input)) {
52
- throw new TypeError(`Expected to receive a ${instanceName} builder, got a primitive (${typeof input}) instead.`);
53
- }
54
- if (!(input instanceof ExpectedInstanceOf)) {
55
- const casted = input;
56
- const constructorName = is_1.default.function_(input) ? input.name : casted.constructor.name;
57
- const stringTag = Reflect.get(casted, Symbol.toStringTag);
58
- const fullResultName = stringTag ? `${constructorName} [${stringTag}]` : constructorName;
59
- throw new TypeError(`Expected to receive a ${instanceName} builder, got ${fullResultName} instead.`);
60
- }
61
- }
62
- exports.assertReturnOfBuilder = assertReturnOfBuilder;
63
- //# sourceMappingURL=Assertions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Assertions.js","sourceRoot":"/","sources":["interactions/slashCommands/Assertions.ts"],"names":[],"mappings":"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","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 defaultPermissionPredicate = ow.boolean;\n\nexport function validateDefaultPermission(value: unknown): asserts value is boolean {\n\tow(value, 'default_permission', defaultPermissionPredicate);\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,63 +0,0 @@
1
- import type { APIApplicationCommandOption } from 'discord-api-types/v9';
2
- import { SharedSlashCommandOptions } from './mixins/CommandOptions';
3
- import { SharedNameAndDescription } from './mixins/NameAndDescription';
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
- * Whether the command is enabled by default when the app is added to a guild
20
- * @default true
21
- */
22
- readonly defaultPermission: boolean | undefined;
23
- /**
24
- * Returns the final data that should be sent to Discord.
25
- *
26
- * **Note:** Calling this function will validate required properties based on their conditions.
27
- */
28
- toJSON(): {
29
- name: string;
30
- description: string;
31
- options: APIApplicationCommandOption[];
32
- default_permission: boolean | undefined;
33
- };
34
- /**
35
- * Sets whether the command is enabled by default when the application is added to a guild.
36
- *
37
- * **Note**: If set to `false`, you will have to later have to `PUT` the permissions for this command.
38
- * @param value Whether or not to enable this command by default
39
- *
40
- * @see https://discord.com/developers/docs/interactions/slash-commands#permissions
41
- */
42
- setDefaultPermission(value: boolean): this;
43
- /**
44
- * Adds a new subcommand group to this command
45
- * @param input A function that returns a subcommand group builder, or an already built builder
46
- */
47
- addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
48
- /**
49
- * Adds a new subcommand to this command
50
- * @param input A function that returns a subcommand builder, or an already built builder
51
- */
52
- addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
53
- }
54
- export interface SlashCommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {
55
- }
56
- export interface SlashCommandSubcommandsOnlyBuilder extends SharedNameAndDescription, Pick<SlashCommandBuilder, 'toJSON' | 'addSubcommand' | 'addSubcommandGroup'> {
57
- }
58
- export interface SlashCommandOptionsOnlyBuilder extends SharedNameAndDescription, SharedSlashCommandOptions, Pick<SlashCommandBuilder, 'toJSON'> {
59
- }
60
- export interface ToAPIApplicationCommandOptions {
61
- toJSON(): APIApplicationCommandOption;
62
- }
63
- //# 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;AAQxE,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,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;;;OAGG;IACH,SAAgB,iBAAiB,EAAE,OAAO,GAAG,SAAS,CAAa;IAEnE;;;;OAIG;IACI,MAAM;;;;;;IAUb;;;;;;;OAOG;IACI,oBAAoB,CAAC,KAAK,EAAE,OAAO;IAS1C;;;OAGG;IACI,kBAAkB,CACxB,KAAK,EACF,kCAAkC,GAClC,CAAC,CAAC,eAAe,EAAE,kCAAkC,KAAK,kCAAkC,CAAC,GAC9F,kCAAkC;IAiBrC;;;OAGG;IACI,aAAa,CACnB,KAAK,EACF,6BAA6B,GAC7B,CAAC,CAAC,eAAe,EAAE,6BAA6B,KAAK,6BAA6B,CAAC,GACpF,kCAAkC;CAgBrC;AAED,MAAM,WAAW,mBAAoB,SAAQ,wBAAwB,EAAE,yBAAyB;CAAG;AAEnG,MAAM,WAAW,kCAChB,SAAQ,wBAAwB,EAC/B,IAAI,CAAC,mBAAmB,EAAE,QAAQ,GAAG,eAAe,GAAG,oBAAoB,CAAC;CAAG;AAEjF,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,113 +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 CommandOptions_1 = require("./mixins/CommandOptions");
8
- const NameAndDescription_1 = require("./mixins/NameAndDescription");
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
- * Whether the command is enabled by default when the app is added to a guild
41
- * @default true
42
- */
43
- Object.defineProperty(this, "defaultPermission", {
44
- enumerable: true,
45
- configurable: true,
46
- writable: true,
47
- value: undefined
48
- });
49
- }
50
- /**
51
- * Returns the final data that should be sent to Discord.
52
- *
53
- * **Note:** Calling this function will validate required properties based on their conditions.
54
- */
55
- toJSON() {
56
- Assertions_1.validateRequiredParameters(this.name, this.description, this.options);
57
- return {
58
- name: this.name,
59
- description: this.description,
60
- options: this.options.map((option) => option.toJSON()),
61
- default_permission: this.defaultPermission,
62
- };
63
- }
64
- /**
65
- * Sets whether the command is enabled by default when the application is added to a guild.
66
- *
67
- * **Note**: If set to `false`, you will have to later have to `PUT` the permissions for this command.
68
- * @param value Whether or not to enable this command by default
69
- *
70
- * @see https://discord.com/developers/docs/interactions/slash-commands#permissions
71
- */
72
- setDefaultPermission(value) {
73
- // Assert the value matches the conditions
74
- Assertions_1.validateDefaultPermission(value);
75
- Reflect.set(this, 'defaultPermission', value);
76
- return this;
77
- }
78
- /**
79
- * Adds a new subcommand group to this command
80
- * @param input A function that returns a subcommand group builder, or an already built builder
81
- */
82
- addSubcommandGroup(input) {
83
- const { options } = this;
84
- // First, assert options conditions - we cannot have more than 25 options
85
- Assertions_1.validateMaxOptionsLength(options);
86
- // Get the final result
87
- const result = typeof input === 'function' ? input(new SlashCommandSubcommands_1.SlashCommandSubcommandGroupBuilder()) : input;
88
- Assertions_1.assertReturnOfBuilder(result, SlashCommandSubcommands_1.SlashCommandSubcommandGroupBuilder);
89
- // Push it
90
- options.push(result);
91
- return this;
92
- }
93
- /**
94
- * Adds a new subcommand to this command
95
- * @param input A function that returns a subcommand builder, or an already built builder
96
- */
97
- addSubcommand(input) {
98
- const { options } = this;
99
- // First, assert options conditions - we cannot have more than 25 options
100
- Assertions_1.validateMaxOptionsLength(options);
101
- // Get the final result
102
- const result = typeof input === 'function' ? input(new SlashCommandSubcommands_1.SlashCommandSubcommandBuilder()) : input;
103
- Assertions_1.assertReturnOfBuilder(result, SlashCommandSubcommands_1.SlashCommandSubcommandBuilder);
104
- // Push it
105
- options.push(result);
106
- return this;
107
- }
108
- };
109
- SlashCommandBuilder = tslib_1.__decorate([
110
- ts_mixer_1.mix(CommandOptions_1.SharedSlashCommandOptions, NameAndDescription_1.SharedNameAndDescription)
111
- ], SlashCommandBuilder);
112
- exports.SlashCommandBuilder = SlashCommandBuilder;
113
- //# 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,6CAKsB;AACtB,4DAAoE;AACpE,oEAAuE;AACvE,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;QAE/D;;;WAGG;QACH;;;;mBAAyD,SAAS;WAAC;IAmFpE,CAAC;IAjFA;;;;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,MAAM,EAAE,CAAC;YACtD,kBAAkB,EAAE,IAAI,CAAC,iBAAiB;SAC1C,CAAC;IACH,CAAC;IAED;;;;;;;OAOG;IACI,oBAAoB,CAAC,KAAc;QACzC,0CAA0C;QAC1C,sCAAyB,CAAC,KAAK,CAAC,CAAC;QAEjC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,mBAAmB,EAAE,KAAK,CAAC,CAAC;QAE9C,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,kBAAkB,CACxB,KAEgG;QAEhG,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEzB,yEAAyE;QACzE,qCAAwB,CAAC,OAAO,CAAC,CAAC;QAElC,uBAAuB;QACvB,MAAM,MAAM,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,4DAAkC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAErG,kCAAqB,CAAC,MAAM,EAAE,4DAAkC,CAAC,CAAC;QAElE,UAAU;QACV,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAErB,OAAO,IAAI,CAAC;IACb,CAAC;IAED;;;OAGG;IACI,aAAa,CACnB,KAEsF;QAEtF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEzB,yEAAyE;QACzE,qCAAwB,CAAC,OAAO,CAAC,CAAC;QAElC,uBAAuB;QACvB,MAAM,MAAM,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,uDAA6B,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAEhG,kCAAqB,CAAC,MAAM,EAAE,uDAA6B,CAAC,CAAC;QAE7D,UAAU;QACV,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAErB,OAAO,IAAI,CAAC;IACb,CAAC;CACD,CAAA;AAvGY,mBAAmB;IAD/B,cAAG,CAAC,0CAAyB,EAAE,6CAAwB,CAAC;GAC5C,mBAAmB,CAuG/B;AAvGY,kDAAmB","sourcesContent":["import type { APIApplicationCommandOption } from 'discord-api-types/v9';\nimport { mix } from 'ts-mixer';\nimport {\n\tassertReturnOfBuilder,\n\tvalidateDefaultPermission,\n\tvalidateMaxOptionsLength,\n\tvalidateRequiredParameters,\n} from './Assertions';\nimport { SharedSlashCommandOptions } from './mixins/CommandOptions';\nimport { SharedNameAndDescription } from './mixins/NameAndDescription';\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 * Whether the command is enabled by default when the app is added to a guild\n\t * @default true\n\t */\n\tpublic readonly defaultPermission: boolean | undefined = undefined;\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\tdefault_permission: this.defaultPermission,\n\t\t};\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 have to `PUT` the permissions for this command.\n\t * @param value Whether or not to enable this command by default\n\t *\n\t * @see https://discord.com/developers/docs/interactions/slash-commands#permissions\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, 'defaultPermission', value);\n\n\t\treturn this;\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): 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// 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// 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' | '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;AAGvE;;;;GAIG;AAEH,IAAa,kCAAkC,GAA/C,MAAa,kCAAkC;IAA/C;QACC;;WAEG;QACH;;;;mBAA+B,SAAU;WAAC;QAE1C;;WAEG;QACH;;;;mBAAsC,SAAU;WAAC;QAEjD;;WAEG;QACH;;;;mBAA4D,EAAE;WAAC;IAoChE,CAAC;IAlCA;;;OAGG;IACI,aAAa,CACnB,KAEsF;QAEtF,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;QAEzB,yEAAyE;QACzE,qCAAwB,CAAC,OAAO,CAAC,CAAC;QAElC,uBAAuB;QACvB,MAAM,MAAM,GAAG,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,6BAA6B,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAEhG,kCAAqB,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC;QAE7D,UAAU;QACV,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAErB,OAAO,IAAI,CAAC;IACb,CAAC;IAEM,MAAM;QACZ,uCAA0B,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACtE,OAAO;YACN,IAAI,yBAA8C;YAClD,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;AAlDY,kCAAkC;IAD9C,cAAG,CAAC,6CAAwB,CAAC;GACjB,kCAAkC,CAkD9C;AAlDY,gFAAkC;AAsD/C;;;;GAIG;AAEH,IAAa,6BAA6B,GAA1C,MAAa,6BAA6B;IAA1C;QACC;;WAEG;QACH;;;;mBAA+B,SAAU;WAAC;QAE1C;;WAEG;QACH;;;;mBAAsC,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;IAiBvC;;;OAGG;IACI,UAAU,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,EAAE;IAOrC,MAAM;;;;;;;CAMtB"}