@discordjs/builders 0.8.1 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,8 +6,8 @@
6
6
  <br />
7
7
  <p>
8
8
  <a href="https://discord.gg/djs"><img src="https://img.shields.io/discord/222078108977594368?color=5865F2&logo=discord&logoColor=white" alt="Discord server" /></a>
9
- <a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/v/@discordjs/builders.svg?maxAge=3600" alt="NPM version" /></a>
10
- <a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/dt/@discordjs/builders.svg?maxAge=3600" alt="NPM downloads" /></a>
9
+ <a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/v/@discordjs/builders.svg?maxAge=3600" alt="npm version" /></a>
10
+ <a href="https://www.npmjs.com/package/@discordjs/builders"><img src="https://img.shields.io/npm/dt/@discordjs/builders.svg?maxAge=3600" alt="npm downloads" /></a>
11
11
  <a href="https://github.com/discordjs/builders/actions"><img src="https://github.com/discordjs/builders/workflows/Tests/badge.svg" alt="Build status" /></a>
12
12
  <a href="https://codecov.io/gh/discordjs/builders"><img src="https://codecov.io/gh/discordjs/builders/branch/main/graph/badge.svg" alt="Code coverage" /></a>
13
13
  </p>
@@ -38,7 +38,7 @@ Here are some examples for the builders and utilities you can find in this packa
38
38
  - [discord.js Discord server](https://discord.gg/djs)
39
39
  - [Discord API Discord server](https://discord.gg/discord-api)
40
40
  - [GitHub](https://github.com/discordjs/builders)
41
- - [NPM](https://www.npmjs.com/package/@discordjs/builders)
41
+ - [npm](https://www.npmjs.com/package/@discordjs/builders)
42
42
  - [Related libraries](https://discord.com/developers/docs/topics/community-resources#libraries)
43
43
 
44
44
  ## Contributing
package/dist/index.d.ts CHANGED
@@ -1,36 +1,53 @@
1
- import * as ow from 'ow';
2
- import * as discord_api_types_v9 from 'discord-api-types/v9';
3
- import { APIEmbedField, APIEmbed, APIEmbedThumbnail, APIEmbedImage, APIEmbedVideo, APIEmbedAuthor, APIEmbedProvider, APIEmbedFooter, ApplicationCommandOptionType, ChannelType, APIApplicationCommandChannelOptions, APIApplicationCommandOptionChoice, APIApplicationCommandSubCommandOptions, RESTPostAPIApplicationCommandsJSONBody, APIApplicationCommandOption, ApplicationCommandType } from 'discord-api-types/v9';
1
+ import { APIEmbedField, APIEmbed, APIEmbedThumbnail, APIEmbedImage, APIEmbedVideo, APIEmbedAuthor, APIEmbedProvider, APIEmbedFooter, ApplicationCommandOptionType, APIApplicationCommandBasicOption, APIApplicationCommandBooleanOption, ChannelType, APIApplicationCommandChannelOption, APIApplicationCommandOptionChoice, APIApplicationCommandIntegerOption, APIApplicationCommandMentionableOption, APIApplicationCommandNumberOption, APIApplicationCommandRoleOption, APIApplicationCommandStringOption, APIApplicationCommandUserOption, APIApplicationCommandSubcommandGroupOption, APIApplicationCommandSubcommandOption, RESTPostAPIApplicationCommandsJSONBody, APIApplicationCommandOption, ApplicationCommandType } from 'discord-api-types/v9';
2
+ import { z } from 'zod';
4
3
  import { Snowflake } from 'discord-api-types/globals';
5
4
  import { URL } from 'url';
6
5
 
7
- declare const fieldNamePredicate: ow.StringPredicate;
8
- declare const fieldValuePredicate: ow.StringPredicate;
9
- declare const fieldInlinePredicate: ow.BooleanPredicate & ow.BasePredicate<boolean | undefined>;
10
- declare const embedFieldPredicate: ow.ObjectPredicate<{
6
+ declare const fieldNamePredicate: z.ZodString;
7
+ declare const fieldValuePredicate: z.ZodString;
8
+ declare const fieldInlinePredicate: z.ZodOptional<z.ZodBoolean>;
9
+ declare const embedFieldPredicate: z.ZodObject<{
10
+ name: z.ZodString;
11
+ value: z.ZodString;
12
+ inline: z.ZodOptional<z.ZodBoolean>;
13
+ }, "strip", z.ZodTypeAny, {
14
+ inline?: boolean | undefined;
11
15
  name: string;
12
16
  value: string;
13
- inline: boolean | undefined;
14
- }>;
15
- declare const embedFieldsArrayPredicate: ow.ArrayPredicate<{
17
+ }, {
18
+ inline?: boolean | undefined;
16
19
  name: string;
17
20
  value: string;
18
- inline: boolean | undefined;
19
21
  }>;
22
+ declare const embedFieldsArrayPredicate: z.ZodArray<z.ZodObject<{
23
+ name: z.ZodString;
24
+ value: z.ZodString;
25
+ inline: z.ZodOptional<z.ZodBoolean>;
26
+ }, "strip", z.ZodTypeAny, {
27
+ inline?: boolean | undefined;
28
+ name: string;
29
+ value: string;
30
+ }, {
31
+ inline?: boolean | undefined;
32
+ name: string;
33
+ value: string;
34
+ }>, "many">;
35
+ declare const fieldLengthPredicate: z.ZodNumber;
20
36
  declare function validateFieldLength(fields: APIEmbedField[], amountAdding: number): void;
21
- declare const authorNamePredicate: ow.AnyPredicate<string | null>;
22
- declare const urlPredicate: ow.AnyPredicate<string | null | undefined>;
23
- declare const colorPredicate: ow.AnyPredicate<number | null>;
24
- declare const descriptionPredicate: ow.AnyPredicate<string | null>;
25
- declare const footerTextPredicate: ow.AnyPredicate<string | null>;
26
- declare const timestampPredicate: ow.AnyPredicate<number | Date | null>;
27
- declare const titlePredicate: ow.AnyPredicate<string | null>;
37
+ declare const authorNamePredicate: z.ZodNullable<z.ZodString>;
38
+ declare const urlPredicate: z.ZodNullable<z.ZodOptional<z.ZodString>>;
39
+ declare const colorPredicate: z.ZodNullable<z.ZodNumber>;
40
+ declare const descriptionPredicate: z.ZodNullable<z.ZodString>;
41
+ declare const footerTextPredicate: z.ZodNullable<z.ZodString>;
42
+ declare const timestampPredicate: z.ZodNullable<z.ZodUnion<[z.ZodNumber, z.ZodDate]>>;
43
+ declare const titlePredicate: z.ZodNullable<z.ZodString>;
28
44
 
29
45
  declare const Assertions$2_fieldNamePredicate: typeof fieldNamePredicate;
30
46
  declare const Assertions$2_fieldValuePredicate: typeof fieldValuePredicate;
31
47
  declare const Assertions$2_fieldInlinePredicate: typeof fieldInlinePredicate;
32
48
  declare const Assertions$2_embedFieldPredicate: typeof embedFieldPredicate;
33
49
  declare const Assertions$2_embedFieldsArrayPredicate: typeof embedFieldsArrayPredicate;
50
+ declare const Assertions$2_fieldLengthPredicate: typeof fieldLengthPredicate;
34
51
  declare const Assertions$2_validateFieldLength: typeof validateFieldLength;
35
52
  declare const Assertions$2_authorNamePredicate: typeof authorNamePredicate;
36
53
  declare const Assertions$2_urlPredicate: typeof urlPredicate;
@@ -46,6 +63,7 @@ declare namespace Assertions$2 {
46
63
  Assertions$2_fieldInlinePredicate as fieldInlinePredicate,
47
64
  Assertions$2_embedFieldPredicate as embedFieldPredicate,
48
65
  Assertions$2_embedFieldsArrayPredicate as embedFieldsArrayPredicate,
66
+ Assertions$2_fieldLengthPredicate as fieldLengthPredicate,
49
67
  Assertions$2_validateFieldLength as validateFieldLength,
50
68
  Assertions$2_authorNamePredicate as authorNamePredicate,
51
69
  Assertions$2_urlPredicate as urlPredicate,
@@ -430,109 +448,144 @@ declare enum Faces {
430
448
  Unflip = "\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)"
431
449
  }
432
450
 
433
- declare class SlashCommandBooleanOption extends SlashCommandOptionBase {
451
+ declare class SharedNameAndDescription {
452
+ readonly name: string;
453
+ readonly description: string;
454
+ /**
455
+ * Sets the name
456
+ *
457
+ * @param name The name
458
+ */
459
+ setName(name: string): this;
460
+ /**
461
+ * Sets the description
462
+ *
463
+ * @param description The description
464
+ */
465
+ setDescription(description: string): this;
466
+ }
467
+
468
+ declare abstract class ApplicationCommandOptionBase extends SharedNameAndDescription {
469
+ abstract readonly type: ApplicationCommandOptionType;
470
+ readonly required = false;
471
+ /**
472
+ * Marks the option as required
473
+ *
474
+ * @param required If this option should be required
475
+ */
476
+ setRequired(required: boolean): this;
477
+ abstract toJSON(): APIApplicationCommandBasicOption;
478
+ protected runRequiredValidations(): void;
479
+ }
480
+
481
+ declare class SlashCommandBooleanOption extends ApplicationCommandOptionBase {
434
482
  readonly type: ApplicationCommandOptionType.Boolean;
435
- constructor();
483
+ toJSON(): APIApplicationCommandBooleanOption;
436
484
  }
437
485
 
438
- declare abstract class ApplicationCommandOptionWithChannelTypesBase extends SlashCommandOptionBase implements ToAPIApplicationCommandOptions {
439
- channelTypes?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>[];
486
+ declare const allowedChannelTypes: readonly [ChannelType.GuildText, ChannelType.GuildVoice, ChannelType.GuildCategory, ChannelType.GuildNews, ChannelType.GuildStore, ChannelType.GuildNewsThread, ChannelType.GuildPublicThread, ChannelType.GuildPrivateThread, ChannelType.GuildStageVoice];
487
+ declare type ApplicationCommandOptionAllowedChannelTypes = typeof allowedChannelTypes[number];
488
+ declare class ApplicationCommandOptionChannelTypesMixin {
489
+ readonly channel_types?: ApplicationCommandOptionAllowedChannelTypes[];
440
490
  /**
441
491
  * Adds a channel type to this option
442
492
  *
443
493
  * @param channelType The type of channel to allow
444
494
  */
445
- addChannelType(channelType: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>): this;
495
+ addChannelType(channelType: ApplicationCommandOptionAllowedChannelTypes): this;
446
496
  /**
447
497
  * Adds channel types to this option
448
498
  *
449
499
  * @param channelTypes The channel types to add
450
500
  */
451
- addChannelTypes(channelTypes: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>[]): this;
452
- toJSON(): APIApplicationCommandChannelOptions;
501
+ addChannelTypes(channelTypes: ApplicationCommandOptionAllowedChannelTypes[]): this;
453
502
  }
454
503
 
455
- declare class SlashCommandChannelOption extends ApplicationCommandOptionWithChannelTypesBase {
504
+ declare class SlashCommandChannelOption extends ApplicationCommandOptionBase {
456
505
  readonly type: ApplicationCommandOptionType.Channel;
457
- constructor();
506
+ toJSON(): APIApplicationCommandChannelOption;
507
+ }
508
+ interface SlashCommandChannelOption extends ApplicationCommandOptionChannelTypesMixin {
509
+ }
510
+
511
+ declare abstract class ApplicationCommandNumericOptionMinMaxValueMixin {
512
+ protected readonly maxValue?: number;
513
+ protected readonly minValue?: number;
514
+ /**
515
+ * Sets the maximum number value of this option
516
+ * @param max The maximum value this option can be
517
+ */
518
+ abstract setMaxValue(max: number): this;
519
+ /**
520
+ * Sets the minimum number value of this option
521
+ * @param min The minimum value this option can be
522
+ */
523
+ abstract setMinValue(min: number): this;
458
524
  }
459
525
 
460
- declare abstract class ApplicationCommandOptionWithChoicesBase<T extends string | number> extends SlashCommandOptionBase implements ToAPIApplicationCommandOptions {
461
- choices?: APIApplicationCommandOptionChoice[];
526
+ declare class ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T extends string | number> {
527
+ readonly choices?: APIApplicationCommandOptionChoice<T>[];
528
+ readonly autocomplete?: boolean;
529
+ readonly type: ApplicationCommandOptionType;
462
530
  /**
463
531
  * Adds a choice for this option
464
532
  *
465
533
  * @param name The name of the choice
466
534
  * @param value The value of the choice
467
535
  */
468
- addChoice(name: string, value: T): this;
536
+ addChoice(name: string, value: T): Omit<this, 'setAutocomplete'>;
469
537
  /**
470
538
  * Adds multiple choices for this option
471
539
  *
472
540
  * @param choices The choices to add
473
541
  */
474
- addChoices(choices: [name: string, value: T][]): this;
475
- toJSON(): {
476
- choices: APIApplicationCommandOptionChoice[] | undefined;
477
- type: ApplicationCommandOptionType.String | ApplicationCommandOptionType.Integer | ApplicationCommandOptionType.Number;
478
- name: string;
479
- description: string;
480
- default?: boolean | undefined;
481
- required?: boolean | undefined;
482
- } | {
483
- choices: APIApplicationCommandOptionChoice[] | undefined;
484
- type: ApplicationCommandOptionType.Subcommand | ApplicationCommandOptionType.SubcommandGroup;
485
- options?: discord_api_types_v9.APIApplicationCommandOption[] | undefined;
486
- name: string;
487
- description: string;
488
- default?: boolean | undefined;
489
- required?: boolean | undefined;
490
- } | {
491
- choices: APIApplicationCommandOptionChoice[] | undefined;
492
- type: ApplicationCommandOptionType.Channel;
493
- channel_types?: (discord_api_types_v9.ChannelType.GuildText | discord_api_types_v9.ChannelType.GuildVoice | discord_api_types_v9.ChannelType.GuildCategory | discord_api_types_v9.ChannelType.GuildNews | discord_api_types_v9.ChannelType.GuildStore | discord_api_types_v9.ChannelType.GuildNewsThread | discord_api_types_v9.ChannelType.GuildPublicThread | discord_api_types_v9.ChannelType.GuildPrivateThread | discord_api_types_v9.ChannelType.GuildStageVoice)[] | undefined;
494
- name: string;
495
- description: string;
496
- default?: boolean | undefined;
497
- required?: boolean | undefined;
498
- } | {
499
- choices: APIApplicationCommandOptionChoice[] | undefined;
500
- type: ApplicationCommandOptionType.Boolean | ApplicationCommandOptionType.User | ApplicationCommandOptionType.Role | ApplicationCommandOptionType.Mentionable;
501
- name: string;
502
- description: string;
503
- default?: boolean | undefined;
504
- required?: boolean | undefined;
505
- };
542
+ addChoices(choices: [name: string, value: T][]): Omit<this, 'setAutocomplete'>;
543
+ setChoices<Input extends [name: string, value: T][]>(choices: Input): Input extends [] ? this & Pick<ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T>, 'setAutocomplete'> : Omit<this, 'setAutocomplete'>;
544
+ /**
545
+ * Marks the option as autocompletable
546
+ * @param autocomplete If this option should be autocompletable
547
+ */
548
+ setAutocomplete<U extends boolean>(autocomplete: U): U extends true ? Omit<this, 'addChoice' | 'addChoices'> : this & Pick<ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T>, 'addChoice' | 'addChoices'>;
506
549
  }
507
550
 
508
- declare class SlashCommandIntegerOption extends ApplicationCommandOptionWithChoicesBase<number> {
551
+ declare class SlashCommandIntegerOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
509
552
  readonly type: ApplicationCommandOptionType.Integer;
510
- constructor();
553
+ setMaxValue(max: number): this;
554
+ setMinValue(min: number): this;
555
+ toJSON(): APIApplicationCommandIntegerOption;
556
+ }
557
+ interface SlashCommandIntegerOption extends ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {
511
558
  }
512
559
 
513
- declare class SlashCommandMentionableOption extends SlashCommandOptionBase {
560
+ declare class SlashCommandMentionableOption extends ApplicationCommandOptionBase {
514
561
  readonly type: ApplicationCommandOptionType.Mentionable;
515
- constructor();
562
+ toJSON(): APIApplicationCommandMentionableOption;
516
563
  }
517
564
 
518
- declare class SlashCommandNumberOption extends ApplicationCommandOptionWithChoicesBase<number> {
565
+ declare class SlashCommandNumberOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
519
566
  readonly type: ApplicationCommandOptionType.Number;
520
- constructor();
567
+ setMaxValue(max: number): this;
568
+ setMinValue(min: number): this;
569
+ toJSON(): APIApplicationCommandNumberOption;
570
+ }
571
+ interface SlashCommandNumberOption extends ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {
521
572
  }
522
573
 
523
- declare class SlashCommandRoleOption extends SlashCommandOptionBase {
574
+ declare class SlashCommandRoleOption extends ApplicationCommandOptionBase {
524
575
  readonly type: ApplicationCommandOptionType.Role;
525
- constructor();
576
+ toJSON(): APIApplicationCommandRoleOption;
526
577
  }
527
578
 
528
- declare class SlashCommandStringOption extends ApplicationCommandOptionWithChoicesBase<string> {
579
+ declare class SlashCommandStringOption extends ApplicationCommandOptionBase {
529
580
  readonly type: ApplicationCommandOptionType.String;
530
- constructor();
581
+ toJSON(): APIApplicationCommandStringOption;
582
+ }
583
+ interface SlashCommandStringOption extends ApplicationCommandOptionWithChoicesAndAutocompleteMixin<string> {
531
584
  }
532
585
 
533
- declare class SlashCommandUserOption extends SlashCommandOptionBase {
586
+ declare class SlashCommandUserOption extends ApplicationCommandOptionBase {
534
587
  readonly type: ApplicationCommandOptionType.User;
535
- constructor();
588
+ toJSON(): APIApplicationCommandUserOption;
536
589
  }
537
590
 
538
591
  declare class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
@@ -572,39 +625,22 @@ declare class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
572
625
  *
573
626
  * @param input A function that returns an option builder, or an already built builder
574
627
  */
575
- addStringOption(input: SlashCommandStringOption | ((builder: SlashCommandStringOption) => SlashCommandStringOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
628
+ addStringOption(input: SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoice' | 'addChoices'> | ((builder: SlashCommandStringOption) => SlashCommandStringOption | Omit<SlashCommandStringOption, 'setAutocomplete'> | Omit<SlashCommandStringOption, 'addChoice' | 'addChoices'>)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
576
629
  /**
577
630
  * Adds an integer option
578
631
  *
579
632
  * @param input A function that returns an option builder, or an already built builder
580
633
  */
581
- addIntegerOption(input: SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
634
+ addIntegerOption(input: SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoice' | 'addChoices'> | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, 'setAutocomplete'> | Omit<SlashCommandIntegerOption, 'addChoice' | 'addChoices'>)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
582
635
  /**
583
636
  * Adds a number option
584
637
  *
585
638
  * @param input A function that returns an option builder, or an already built builder
586
639
  */
587
- addNumberOption(input: SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
640
+ addNumberOption(input: SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoice' | 'addChoices'> | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption | Omit<SlashCommandNumberOption, 'setAutocomplete'> | Omit<SlashCommandNumberOption, 'addChoice' | 'addChoices'>)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
588
641
  private _sharedAddOptionMethod;
589
642
  }
590
643
 
591
- declare class SharedNameAndDescription {
592
- readonly name: string;
593
- readonly description: string;
594
- /**
595
- * Sets the name
596
- *
597
- * @param name The name
598
- */
599
- setName(name: string): this;
600
- /**
601
- * Sets the description
602
- *
603
- * @param description The description
604
- */
605
- setDescription(description: string): this;
606
- }
607
-
608
644
  /**
609
645
  * Represents a folder for subcommands
610
646
  *
@@ -622,14 +658,14 @@ declare class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationComm
622
658
  /**
623
659
  * The subcommands part of this subcommand group
624
660
  */
625
- readonly options: ToAPIApplicationCommandOptions[];
661
+ readonly options: SlashCommandSubcommandBuilder[];
626
662
  /**
627
663
  * Adds a new subcommand to this group
628
664
  *
629
665
  * @param input A function that returns a subcommand builder, or an already built builder
630
666
  */
631
667
  addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): this;
632
- toJSON(): APIApplicationCommandSubCommandOptions;
668
+ toJSON(): APIApplicationCommandSubcommandGroupOption;
633
669
  }
634
670
  interface SlashCommandSubcommandGroupBuilder extends SharedNameAndDescription {
635
671
  }
@@ -650,8 +686,8 @@ declare class SlashCommandSubcommandBuilder implements ToAPIApplicationCommandOp
650
686
  /**
651
687
  * The options of this subcommand
652
688
  */
653
- readonly options: ToAPIApplicationCommandOptions[];
654
- toJSON(): APIApplicationCommandSubCommandOptions;
689
+ readonly options: ApplicationCommandOptionBase[];
690
+ toJSON(): APIApplicationCommandSubcommandOption;
655
691
  }
656
692
  interface SlashCommandSubcommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions<false> {
657
693
  }
@@ -714,28 +750,17 @@ interface ToAPIApplicationCommandOptions {
714
750
  toJSON(): APIApplicationCommandOption;
715
751
  }
716
752
 
717
- declare class SlashCommandOptionBase extends SharedNameAndDescription implements ToAPIApplicationCommandOptions {
718
- required: boolean;
719
- readonly type: ApplicationCommandOptionType;
720
- constructor(type: ApplicationCommandOptionType);
721
- /**
722
- * Marks the option as required
723
- *
724
- * @param required If this option should be required
725
- */
726
- setRequired(required: boolean): this;
727
- toJSON(): APIApplicationCommandOption;
728
- }
729
-
730
753
  declare function validateRequiredParameters$1(name: string, description: string, options: ToAPIApplicationCommandOptions[]): void;
731
754
  declare function validateName$1(name: unknown): asserts name is string;
732
755
  declare function validateDescription(description: unknown): asserts description is string;
733
756
  declare function validateDefaultPermission$1(value: unknown): asserts value is boolean;
757
+ declare function validateRequired(required: unknown): asserts required is boolean;
734
758
  declare function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[];
735
759
  declare function validateMaxChoicesLength(choices: APIApplicationCommandOptionChoice[]): void;
736
- declare function assertReturnOfBuilder<T extends SlashCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
760
+ declare function assertReturnOfBuilder<T extends ApplicationCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
737
761
 
738
762
  declare const Assertions$1_validateDescription: typeof validateDescription;
763
+ declare const Assertions$1_validateRequired: typeof validateRequired;
739
764
  declare const Assertions$1_validateMaxOptionsLength: typeof validateMaxOptionsLength;
740
765
  declare const Assertions$1_validateMaxChoicesLength: typeof validateMaxChoicesLength;
741
766
  declare const Assertions$1_assertReturnOfBuilder: typeof assertReturnOfBuilder;
@@ -745,6 +770,7 @@ declare namespace Assertions$1 {
745
770
  validateName$1 as validateName,
746
771
  Assertions$1_validateDescription as validateDescription,
747
772
  validateDefaultPermission$1 as validateDefaultPermission,
773
+ Assertions$1_validateRequired as validateRequired,
748
774
  Assertions$1_validateMaxOptionsLength as validateMaxOptionsLength,
749
775
  Assertions$1_validateMaxChoicesLength as validateMaxChoicesLength,
750
776
  Assertions$1_assertReturnOfBuilder as assertReturnOfBuilder,
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var Ee=Object.create;var T=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var Re=Object.getOwnPropertyNames;var Me=Object.getPrototypeOf,De=Object.prototype.hasOwnProperty;var _e=(t,e,n)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var $e=t=>T(t,"__esModule",{value:!0});var L=(t,e)=>{$e(t);for(var n in e)T(t,n,{get:e[n],enumerable:!0})},ke=(t,e,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Re(e))!De.call(t,o)&&o!=="default"&&T(t,o,{get:()=>e[o],enumerable:!(n=ve(e,o))||n.enumerable});return t},s=t=>ke($e(T(t!=null?Ee(Me(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),I=(t,e,n,o)=>{for(var p=o>1?void 0:o?ve(e,n):e,P=t.length-1,$;P>=0;P--)($=t[P])&&(p=(o?$(e,n,p):$(p))||p);return o&&p&&T(e,n,p),p};var i=(t,e,n)=>(_e(t,typeof e!="symbol"?e+"":e,n),n);L(exports,{ContextMenuCommandAssertions:()=>Te,ContextMenuCommandBuilder:()=>Le,Embed:()=>B,EmbedAssertions:()=>ie,Faces:()=>oe,SlashCommandAssertions:()=>ae,SlashCommandBooleanOption:()=>G,SlashCommandBuilder:()=>K,SlashCommandChannelOption:()=>F,SlashCommandIntegerOption:()=>J,SlashCommandMentionableOption:()=>q,SlashCommandNumberOption:()=>V,SlashCommandRoleOption:()=>W,SlashCommandStringOption:()=>j,SlashCommandSubcommandBuilder:()=>f,SlashCommandSubcommandGroupBuilder:()=>O,SlashCommandUserOption:()=>z,TimestampStyles:()=>nt,blockQuote:()=>je,bold:()=>Je,channelMention:()=>Ye,codeBlock:()=>Ue,formatEmoji:()=>et,hideLinkEmbed:()=>ze,hyperlink:()=>Ke,inlineCode:()=>Ge,italic:()=>Fe,memberNicknameMention:()=>Xe,quote:()=>We,roleMention:()=>Ze,spoiler:()=>Qe,strikethrough:()=>Ve,time:()=>tt,underscore:()=>qe,userMention:()=>He});var ie={};L(ie,{authorNamePredicate:()=>X,colorPredicate:()=>Y,descriptionPredicate:()=>Z,embedFieldPredicate:()=>Ie,embedFieldsArrayPredicate:()=>M,fieldInlinePredicate:()=>R,fieldNamePredicate:()=>v,fieldValuePredicate:()=>E,footerTextPredicate:()=>ee,timestampPredicate:()=>te,titlePredicate:()=>ne,urlPredicate:()=>b,validateFieldLength:()=>D});var r=s(require("ow")),v=r.default.string.minLength(1).maxLength(256),E=r.default.string.minLength(1).maxLength(1024),R=r.default.optional.boolean,Ie=r.default.object.exactShape({name:v,value:E,inline:R}),M=r.default.array.ofType(Ie);function D(t,e){(0,r.default)(t.length+e,"field amount",r.default.number.lessThanOrEqual(25))}var X=r.default.any(v,r.default.null),b=r.default.any(r.default.string.url,r.default.nullOrUndefined),Y=r.default.any(r.default.number.greaterThanOrEqual(0).lessThanOrEqual(16777215),r.default.null),Z=r.default.any(r.default.string.minLength(1).maxLength(4096),r.default.null),ee=r.default.any(r.default.string.minLength(1).maxLength(2048),r.default.null),te=r.default.any(r.default.number,r.default.date,r.default.null),ne=r.default.any(v,r.default.null);var m=s(require("ow"));var B=class{constructor(e={}){i(this,"fields");i(this,"title");i(this,"description");i(this,"url");i(this,"color");i(this,"timestamp");i(this,"thumbnail");i(this,"image");i(this,"video");i(this,"author");i(this,"provider");i(this,"footer");this.title=e.title,this.description=e.description,this.url=e.url,this.color=e.color,this.thumbnail=e.thumbnail,this.image=e.image,this.video=e.video,this.author=e.author,this.provider=e.provider,this.footer=e.footer,this.fields=e.fields??[],e.timestamp&&(this.timestamp=new Date(e.timestamp).toISOString())}get length(){return(this.title?.length??0)+(this.description?.length??0)+this.fields.reduce((e,n)=>e+n.name.length+n.value.length,0)+(this.footer?.text.length??0)+(this.author?.name.length??0)}addField(e){return this.addFields(e)}addFields(...e){return(0,m.default)(e,"fields",M),D(this.fields,e.length),this.fields.push(...B.normalizeFields(...e)),this}spliceFields(e,n,...o){return(0,m.default)(o,"fields",M),D(this.fields,o.length-n),this.fields.splice(e,n,...B.normalizeFields(...o)),this}setAuthor(e){if(e===null)return this.author=void 0,this;let{name:n,iconURL:o,url:p}=e;return(0,m.default)(n,"name",X),(0,m.default)(o,"iconURL",b),(0,m.default)(p,"url",b),this.author={name:n,url:p,icon_url:o},this}setColor(e){return(0,m.default)(e,"color",Y),this.color=e??void 0,this}setDescription(e){return(0,m.default)(e,"description",Z),this.description=e??void 0,this}setFooter(e){if(e===null)return this.footer=void 0,this;let{text:n,iconURL:o}=e;return(0,m.default)(n,"text",ee),(0,m.default)(o,"iconURL",b),this.footer={text:n,icon_url:o},this}setImage(e){return(0,m.default)(e,"url",b),this.image=e?{url:e}:void 0,this}setThumbnail(e){return(0,m.default)(e,"url",b),this.thumbnail=e?{url:e}:void 0,this}setTimestamp(e=Date.now()){return(0,m.default)(e,"timestamp",te),this.timestamp=e?new Date(e).toISOString():void 0,this}setTitle(e){return(0,m.default)(e,"title",ne),this.title=e??void 0,this}setURL(e){return(0,m.default)(e,"url",b),this.url=e??void 0,this}toJSON(){return{...this}}static normalizeFields(...e){return e.flat(1/0).map(n=>((0,m.default)(n.name,"field name",v),(0,m.default)(n.value,"field value",E),(0,m.default)(n.inline,"field inline",R),{name:n.name,value:n.value,inline:n.inline??void 0}))}};function Ue(t,e){return typeof e=="undefined"?`\`\`\`
1
+ var Ge=Object.create;var O=Object.defineProperty;var he=Object.getOwnPropertyDescriptor;var qe=Object.getOwnPropertyNames;var ze=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var je=(t,e,i)=>e in t?O(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var Ce=t=>O(t,"__esModule",{value:!0});var w=(t,e)=>{for(var i in e)O(t,i,{get:e[i],enumerable:!0})},fe=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of qe(e))!We.call(t,r)&&(i||r!=="default")&&O(t,r,{get:()=>e[r],enumerable:!(o=he(e,r))||o.enumerable});return t},Ze=(t,e)=>fe(Ce(O(t!=null?Ge(ze(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),Ke=(t=>(e,i)=>t&&t.get(e)||(i=fe(Ce({}),e,1),t&&t.set(e,i),i))(typeof WeakMap!="undefined"?new WeakMap:0),p=(t,e,i,o)=>{for(var r=o>1?void 0:o?he(e,i):e,A=t.length-1,R;A>=0;A--)(R=t[A])&&(r=(o?R(e,i,r):R(r))||r);return o&&r&&O(e,i,r),r};var n=(t,e,i)=>(je(t,typeof e!="symbol"?e+"":e,i),i);var yt={};w(yt,{ContextMenuCommandAssertions:()=>ue,ContextMenuCommandBuilder:()=>Je,Embed:()=>M,EmbedAssertions:()=>ie,Faces:()=>Ae,SlashCommandAssertions:()=>re,SlashCommandBooleanOption:()=>J,SlashCommandBuilder:()=>j,SlashCommandChannelOption:()=>y,SlashCommandIntegerOption:()=>P,SlashCommandMentionableOption:()=>q,SlashCommandNumberOption:()=>T,SlashCommandRoleOption:()=>z,SlashCommandStringOption:()=>I,SlashCommandSubcommandBuilder:()=>c,SlashCommandSubcommandGroupBuilder:()=>x,SlashCommandUserOption:()=>W,TimestampStyles:()=>ut,blockQuote:()=>nt,bold:()=>Ye,channelMention:()=>mt,codeBlock:()=>Qe,formatEmoji:()=>dt,hideLinkEmbed:()=>ot,hyperlink:()=>rt,inlineCode:()=>He,italic:()=>Xe,memberNicknameMention:()=>pt,quote:()=>it,roleMention:()=>lt,spoiler:()=>at,strikethrough:()=>tt,time:()=>ct,underscore:()=>et,userMention:()=>st});var ie={};w(ie,{authorNamePredicate:()=>Q,colorPredicate:()=>H,descriptionPredicate:()=>X,embedFieldPredicate:()=>be,embedFieldsArrayPredicate:()=>_,fieldInlinePredicate:()=>k,fieldLengthPredicate:()=>xe,fieldNamePredicate:()=>S,fieldValuePredicate:()=>E,footerTextPredicate:()=>Y,timestampPredicate:()=>ee,titlePredicate:()=>te,urlPredicate:()=>u,validateFieldLength:()=>L});var m=require("zod"),S=m.z.string().min(1).max(256),E=m.z.string().min(1).max(1024),k=m.z.boolean().optional(),be=m.z.object({name:S,value:E,inline:k}),_=be.array(),xe=m.z.number().lte(25);function L(t,e){xe.parse(t.length+e)}var Q=S.nullable(),u=m.z.string().url().nullish(),H=m.z.number().gte(0).lte(16777215).nullable(),X=m.z.string().min(1).max(4096).nullable(),Y=m.z.string().min(1).max(2048).nullable(),ee=m.z.union([m.z.number(),m.z.date()]).nullable(),te=S.nullable();var M=class{constructor(e={}){n(this,"fields");n(this,"title");n(this,"description");n(this,"url");n(this,"color");n(this,"timestamp");n(this,"thumbnail");n(this,"image");n(this,"video");n(this,"author");n(this,"provider");n(this,"footer");this.title=e.title,this.description=e.description,this.url=e.url,this.color=e.color,this.thumbnail=e.thumbnail,this.image=e.image,this.video=e.video,this.author=e.author,this.provider=e.provider,this.footer=e.footer,this.fields=e.fields??[],e.timestamp&&(this.timestamp=new Date(e.timestamp).toISOString())}get length(){return(this.title?.length??0)+(this.description?.length??0)+this.fields.reduce((e,i)=>e+i.name.length+i.value.length,0)+(this.footer?.text.length??0)+(this.author?.name.length??0)}addField(e){return this.addFields(e)}addFields(...e){return _.parse(e),L(this.fields,e.length),this.fields.push(...M.normalizeFields(...e)),this}spliceFields(e,i,...o){return _.parse(o),L(this.fields,o.length-i),this.fields.splice(e,i,...M.normalizeFields(...o)),this}setAuthor(e){if(e===null)return this.author=void 0,this;let{name:i,iconURL:o,url:r}=e;return Q.parse(i),u.parse(o),u.parse(r),this.author={name:i,url:r,icon_url:o},this}setColor(e){return H.parse(e),this.color=e??void 0,this}setDescription(e){return X.parse(e),this.description=e??void 0,this}setFooter(e){if(e===null)return this.footer=void 0,this;let{text:i,iconURL:o}=e;return Y.parse(i),u.parse(o),this.footer={text:i,icon_url:o},this}setImage(e){return u.parse(e),this.image=e?{url:e}:void 0,this}setThumbnail(e){return u.parse(e),this.thumbnail=e?{url:e}:void 0,this}setTimestamp(e=Date.now()){return ee.parse(e),this.timestamp=e?new Date(e).toISOString():void 0,this}setTitle(e){return te.parse(e),this.title=e??void 0,this}setURL(e){return u.parse(e),this.url=e??void 0,this}toJSON(){return{...this}}static normalizeFields(...e){return e.flat(1/0).map(i=>(S.parse(i.name),E.parse(i.value),k.parse(i.inline),{name:i.name,value:i.value,inline:i.inline??void 0}))}};function Qe(t,e){return typeof e=="undefined"?`\`\`\`
2
2
  ${t}\`\`\``:`\`\`\`${t}
3
- ${e}\`\`\``}function Ge(t){return`\`${t}\``}function Fe(t){return`_${t}_`}function Je(t){return`**${t}**`}function qe(t){return`__${t}__`}function Ve(t){return`~~${t}~~`}function We(t){return`> ${t}`}function je(t){return`>>> ${t}`}function ze(t){return`<${t}>`}function Ke(t,e,n){return n?`[${t}](${e} "${n}")`:`[${t}](${e})`}function Qe(t){return`||${t}||`}function He(t){return`<@${t}>`}function Xe(t){return`<@!${t}>`}function Ye(t){return`<#${t}>`}function Ze(t){return`<@&${t}>`}function et(t,e=!1){return`<${e?"a":""}:_:${t}>`}function tt(t,e){return typeof t!="number"&&(t=Math.floor((t?.getTime()??Date.now())/1e3)),typeof e=="string"?`<t:${t}:${e}>`:`<t:${t}>`}var nt={ShortTime:"t",LongTime:"T",ShortDate:"d",LongDate:"D",ShortDateTime:"f",LongDateTime:"F",RelativeTime:"R"},oe;(function(o){o.Shrug="\xAF\\_(\u30C4)\\_/\xAF",o.Tableflip="(\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35 \u253B\u2501\u253B",o.Unflip="\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)"})(oe||(oe={}));var ae={};L(ae,{assertReturnOfBuilder:()=>y,validateDefaultPermission:()=>re,validateDescription:()=>U,validateMaxChoicesLength:()=>se,validateMaxOptionsLength:()=>C,validateName:()=>k,validateRequiredParameters:()=>x});var _=s(require("@sindresorhus/is")),h=s(require("ow"));function x(t,e,n){k(t),U(e),C(n)}var it=h.default.string.lowercase.minLength(1).maxLength(32).addValidator({message:(t,e)=>`Expected ${e} to match "^[\\p{L}\\p{N}_-]+$", got ${t} instead`,validator:t=>/^[\p{L}\p{N}_-]+$/u.test(t)});function k(t){(0,h.default)(t,"name",it)}var ot=h.default.string.minLength(1).maxLength(100);function U(t){(0,h.default)(t,"description",ot)}var rt=h.default.boolean;function re(t){(0,h.default)(t,"default_permission",rt)}var Be=h.default.array.maxLength(25);function C(t){(0,h.default)(t,"options",Be)}function se(t){(0,h.default)(t,"choices",Be)}function y(t,e){let n=e.name;if(_.default.nullOrUndefined(t))throw new TypeError(`Expected to receive a ${n} builder, got ${t===null?"null":"undefined"} instead.`);if(_.default.primitive(t))throw new TypeError(`Expected to receive a ${n} builder, got a primitive (${typeof t}) instead.`);if(!(t instanceof e)){let o=t,p=_.default.function_(t)?t.name:o.constructor.name,P=Reflect.get(o,Symbol.toStringTag),$=P?`${p} [${P}]`:p;throw new TypeError(`Expected to receive a ${n} builder, got ${$} instead.`)}}var we=s(require("ts-mixer"));var me=s(require("discord-api-types/v9"));var N=s(require("ow"));var S=class{constructor(){i(this,"name");i(this,"description")}setName(e){return k(e),Reflect.set(this,"name",e),this}setDescription(e){return U(e),Reflect.set(this,"description",e),this}};var d=class extends S{constructor(e){super();i(this,"required",!1);i(this,"type");this.type=e}setRequired(e){return(0,N.default)(e,"required",N.default.boolean),this.required=e,this}toJSON(){return x(this.name,this.description,[]),(0,N.default)(this.required,"required",N.default.boolean),{type:this.type,name:this.name,description:this.description,required:this.required}}};var G=class extends d{constructor(){super(me.ApplicationCommandOptionType.Boolean);i(this,"type",me.ApplicationCommandOptionType.Boolean)}};var le=s(require("discord-api-types/v9"));var l=s(require("discord-api-types/v9")),pe=s(require("ow"));var st=[l.ChannelType.GuildCategory,l.ChannelType.GuildNews,l.ChannelType.GuildNewsThread,l.ChannelType.GuildStore,l.ChannelType.GuildStageVoice,l.ChannelType.GuildText,l.ChannelType.GuildVoice,l.ChannelType.GuildPublicThread,l.ChannelType.GuildPrivateThread],at=pe.default.number.oneOf(st),de=class extends d{constructor(){super(...arguments);i(this,"channelTypes")}addChannelType(e){return this.channelTypes??=[],(0,pe.default)(e,"channel type",at),this.channelTypes.push(e),this}addChannelTypes(e){return e.forEach(n=>this.addChannelType(n)),this}toJSON(){return{...super.toJSON(),type:l.ApplicationCommandOptionType.Channel,channel_types:this.channelTypes}}};var F=class extends de{constructor(){super(le.ApplicationCommandOptionType.Channel);i(this,"type",le.ApplicationCommandOptionType.Channel)}};var he=s(require("discord-api-types/v9"));var c=s(require("discord-api-types/v9")),u=s(require("ow"));var ce=u.default.string.minLength(1).maxLength(100),Ne=u.default.number.finite,mt=u.default.array.ofType(u.default.array.exactShape([ce,u.default.any(u.default.string,Ne)])),g=class extends d{constructor(){super(...arguments);i(this,"choices")}addChoice(e,n){return this.choices??=[],se(this.choices),(0,u.default)(e,`${ue[this.type]} choice name`,ce),this.type===c.ApplicationCommandOptionType.String?(0,u.default)(n,"string choice value",ce):(0,u.default)(n,`${ue[this.type]} choice value`,Ne),this.choices.push({name:e,value:n}),this}addChoices(e){(0,u.default)(e,`${ue[this.type]} choices`,mt);for(let[n,o]of e)this.addChoice(n,o);return this}toJSON(){return{...super.toJSON(),choices:this.choices}}},ue={[c.ApplicationCommandOptionType.Subcommand]:"subcommand",[c.ApplicationCommandOptionType.SubcommandGroup]:"subcommand group",[c.ApplicationCommandOptionType.String]:"string",[c.ApplicationCommandOptionType.Integer]:"integer",[c.ApplicationCommandOptionType.Boolean]:"boolean",[c.ApplicationCommandOptionType.User]:"user",[c.ApplicationCommandOptionType.Channel]:"channel",[c.ApplicationCommandOptionType.Role]:"role",[c.ApplicationCommandOptionType.Mentionable]:"mentionable",[c.ApplicationCommandOptionType.Number]:"number"};var J=class extends g{constructor(){super(he.ApplicationCommandOptionType.Integer);i(this,"type",he.ApplicationCommandOptionType.Integer)}};var Ce=s(require("discord-api-types/v9"));var q=class extends d{constructor(){super(Ce.ApplicationCommandOptionType.Mentionable);i(this,"type",Ce.ApplicationCommandOptionType.Mentionable)}};var fe=s(require("discord-api-types/v9"));var V=class extends g{constructor(){super(fe.ApplicationCommandOptionType.Number);i(this,"type",fe.ApplicationCommandOptionType.Number)}};var be=s(require("discord-api-types/v9"));var W=class extends d{constructor(){super(be.ApplicationCommandOptionType.Role);i(this,"type",be.ApplicationCommandOptionType.Role)}};var xe=s(require("discord-api-types/v9"));var j=class extends g{constructor(){super(xe.ApplicationCommandOptionType.String);i(this,"type",xe.ApplicationCommandOptionType.String)}};var ye=s(require("discord-api-types/v9"));var z=class extends d{constructor(){super(ye.ApplicationCommandOptionType.User);i(this,"type",ye.ApplicationCommandOptionType.User)}};var w=class{constructor(){i(this,"options")}addBooleanOption(e){return this._sharedAddOptionMethod(e,G)}addUserOption(e){return this._sharedAddOptionMethod(e,z)}addChannelOption(e){return this._sharedAddOptionMethod(e,F)}addRoleOption(e){return this._sharedAddOptionMethod(e,W)}addMentionableOption(e){return this._sharedAddOptionMethod(e,q)}addStringOption(e){return this._sharedAddOptionMethod(e,j)}addIntegerOption(e){return this._sharedAddOptionMethod(e,J)}addNumberOption(e){return this._sharedAddOptionMethod(e,V)}_sharedAddOptionMethod(e,n){let{options:o}=this;C(o);let p=typeof e=="function"?e(new n):e;return y(p,n),o.push(p),this}};var Se=s(require("discord-api-types/v9")),ge=s(require("ts-mixer"));var O=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}addSubcommand(e){let{options:n}=this;C(n);let o=typeof e=="function"?e(new f):e;return y(o,f),n.push(o),this}toJSON(){return x(this.name,this.description,this.options),{type:Se.ApplicationCommandOptionType.SubcommandGroup,name:this.name,description:this.description,options:this.options.map(e=>e.toJSON())}}};O=I([(0,ge.mix)(S)],O);var f=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[])}toJSON(){return x(this.name,this.description,this.options),{type:Se.ApplicationCommandOptionType.Subcommand,name:this.name,description:this.description,options:this.options.map(e=>e.toJSON())}}};f=I([(0,ge.mix)(S,w)],f);var K=class{constructor(){i(this,"name");i(this,"description");i(this,"options",[]);i(this,"defaultPermission")}toJSON(){return x(this.name,this.description,this.options),{name:this.name,description:this.description,options:this.options.map(e=>e.toJSON()),default_permission:this.defaultPermission}}setDefaultPermission(e){return re(e),Reflect.set(this,"defaultPermission",e),this}addSubcommandGroup(e){let{options:n}=this;C(n);let o=typeof e=="function"?e(new O):e;return y(o,O),n.push(o),this}addSubcommand(e){let{options:n}=this;C(n);let o=typeof e=="function"?e(new f):e;return y(o,f),n.push(o),this}};K=I([(0,we.mix)(w,S)],K);var Te={};L(Te,{validateDefaultPermission:()=>Pe,validateName:()=>Q,validateRequiredParameters:()=>Ae,validateType:()=>H});var A=s(require("ow")),Oe=s(require("discord-api-types/v9"));function Ae(t,e){Q(t),H(e)}var pt=A.default.string.minLength(1).maxLength(32).matches(/^( *[\p{L}\p{N}_-]+ *)+$/u);function Q(t){(0,A.default)(t,"name",pt)}var dt=A.default.number.oneOf([Oe.ApplicationCommandType.User,Oe.ApplicationCommandType.Message]);function H(t){(0,A.default)(t,"type",dt)}var lt=A.default.boolean;function Pe(t){(0,A.default)(t,"default_permission",lt)}var Le=class{constructor(){i(this,"name");i(this,"type");i(this,"defaultPermission")}setName(e){return Q(e),Reflect.set(this,"name",e),this}setType(e){return H(e),Reflect.set(this,"type",e),this}setDefaultPermission(e){return Pe(e),Reflect.set(this,"defaultPermission",e),this}toJSON(){return Ae(this.name,this.type),{name:this.name,type:this.type,default_permission:this.defaultPermission}}};0&&(module.exports={ContextMenuCommandAssertions,ContextMenuCommandBuilder,Embed,EmbedAssertions,Faces,SlashCommandAssertions,SlashCommandBooleanOption,SlashCommandBuilder,SlashCommandChannelOption,SlashCommandIntegerOption,SlashCommandMentionableOption,SlashCommandNumberOption,SlashCommandRoleOption,SlashCommandStringOption,SlashCommandSubcommandBuilder,SlashCommandSubcommandGroupBuilder,SlashCommandUserOption,TimestampStyles,blockQuote,bold,channelMention,codeBlock,formatEmoji,hideLinkEmbed,hyperlink,inlineCode,italic,memberNicknameMention,quote,roleMention,spoiler,strikethrough,time,underscore,userMention});
4
- //# sourceMappingURL=index.js.map
3
+ ${e}\`\`\``}function He(t){return`\`${t}\``}function Xe(t){return`_${t}_`}function Ye(t){return`**${t}**`}function et(t){return`__${t}__`}function tt(t){return`~~${t}~~`}function it(t){return`> ${t}`}function nt(t){return`>>> ${t}`}function ot(t){return`<${t}>`}function rt(t,e,i){return i?`[${t}](${e} "${i}")`:`[${t}](${e})`}function at(t){return`||${t}||`}function st(t){return`<@${t}>`}function pt(t){return`<@!${t}>`}function mt(t){return`<#${t}>`}function lt(t){return`<@&${t}>`}function dt(t,e=!1){return`<${e?"a":""}:_:${t}>`}function ct(t,e){return typeof t!="number"&&(t=Math.floor((t?.getTime()??Date.now())/1e3)),typeof e=="string"?`<t:${t}:${e}>`:`<t:${t}>`}var ut={ShortTime:"t",LongTime:"T",ShortDate:"d",LongDate:"D",ShortDateTime:"f",LongDateTime:"F",RelativeTime:"R"},Ae=(o=>(o.Shrug="\xAF\\_(\u30C4)\\_/\xAF",o.Tableflip="(\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35 \u253B\u2501\u253B",o.Unflip="\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)",o))(Ae||{});var re={};w(re,{assertReturnOfBuilder:()=>C,validateDefaultPermission:()=>ne,validateDescription:()=>D,validateMaxChoicesLength:()=>oe,validateMaxOptionsLength:()=>d,validateName:()=>U,validateRequired:()=>F,validateRequiredParameters:()=>h});var V=Ze(require("@sindresorhus/is")),v=require("zod");function h(t,e,i){U(t),D(e),d(i)}var ht=v.z.string().min(1).max(32).regex(/^[\P{Lu}\p{N}_-]+$/u);function U(t){ht.parse(t)}var Ct=v.z.string().min(1).max(100);function D(t){Ct.parse(t)}var Oe=v.z.boolean();function ne(t){Oe.parse(t)}function F(t){Oe.parse(t)}var Se=v.z.unknown().array().max(25);function d(t){Se.parse(t)}function oe(t){Se.parse(t)}function C(t,e){let i=e.name;if(V.default.nullOrUndefined(t))throw new TypeError(`Expected to receive a ${i} builder, got ${t===null?"null":"undefined"} instead.`);if(V.default.primitive(t))throw new TypeError(`Expected to receive a ${i} builder, got a primitive (${typeof t}) instead.`);if(!(t instanceof e)){let o=t,r=V.default.function_(t)?t.name:o.constructor.name,A=Reflect.get(o,Symbol.toStringTag),R=A?`${r} [${A}]`:r;throw new TypeError(`Expected to receive a ${i} builder, got ${R} instead.`)}}var Fe=require("ts-mixer");var ye=require("discord-api-types/v9");var f=class{constructor(){n(this,"name");n(this,"description")}setName(e){return U(e),Reflect.set(this,"name",e),this}setDescription(e){return D(e),Reflect.set(this,"description",e),this}};var s=class extends f{constructor(){super(...arguments);n(this,"required",!1)}setRequired(e){return F(e),Reflect.set(this,"required",e),this}runRequiredValidations(){h(this.name,this.description,[]),F(this.required)}};var J=class extends s{constructor(){super(...arguments);n(this,"type",ye.ApplicationCommandOptionType.Boolean)}toJSON(){return this.runRequiredValidations(),{...this}}};var ge=require("discord-api-types/v9"),Pe=require("ts-mixer");var l=require("discord-api-types/v9"),ae=require("zod"),ft=[l.ChannelType.GuildText,l.ChannelType.GuildVoice,l.ChannelType.GuildCategory,l.ChannelType.GuildNews,l.ChannelType.GuildStore,l.ChannelType.GuildNewsThread,l.ChannelType.GuildPublicThread,l.ChannelType.GuildPrivateThread,l.ChannelType.GuildStageVoice],bt=ae.z.union(ft.map(t=>ae.z.literal(t))),se=class{constructor(){n(this,"channel_types")}addChannelType(e){return this.channel_types===void 0&&Reflect.set(this,"channel_types",[]),bt.parse(e),this.channel_types.push(e),this}addChannelTypes(e){return e.forEach(i=>this.addChannelType(i)),this}};var y=class extends s{constructor(){super(...arguments);n(this,"type",ge.ApplicationCommandOptionType.Channel)}toJSON(){return this.runRequiredValidations(),{...this}}};y=p([(0,Pe.mix)(se)],y);var Re=require("discord-api-types/v9"),Me=require("ts-mixer"),ve=require("zod");var N=class{constructor(){n(this,"maxValue");n(this,"minValue")}};var Te=require("discord-api-types/v9"),g=require("zod");var G=g.z.string().min(1).max(100),Ie=g.z.number().gt(-1/0).lt(1/0),$e=g.z.tuple([G,g.z.union([G,Ie])]).array(),xt=g.z.boolean(),b=class{constructor(){n(this,"choices");n(this,"autocomplete");n(this,"type")}addChoice(e,i){if(this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return this.choices===void 0&&Reflect.set(this,"choices",[]),oe(this.choices),G.parse(e),this.type===Te.ApplicationCommandOptionType.String?G.parse(i):Ie.parse(i),this.choices.push({name:e,value:i}),this}addChoices(e){if(this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");$e.parse(e);for(let[i,o]of e)this.addChoice(i,o);return this}setChoices(e){if(e.length>0&&this.autocomplete)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");$e.parse(e),Reflect.set(this,"choices",[]);for(let[i,o]of e)this.addChoice(i,o);return this}setAutocomplete(e){if(xt.parse(e),e&&Array.isArray(this.choices)&&this.choices.length>0)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return Reflect.set(this,"autocomplete",e),this}};var Ne=ve.z.number().int().nonnegative(),P=class extends s{constructor(){super(...arguments);n(this,"type",Re.ApplicationCommandOptionType.Integer)}setMaxValue(e){return Ne.parse(e),Reflect.set(this,"maxValue",e),this}setMinValue(e){return Ne.parse(e),Reflect.set(this,"minValue",e),this}toJSON(){if(this.runRequiredValidations(),this.autocomplete&&Array.isArray(this.choices)&&this.choices.length>0)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return{...this}}};P=p([(0,Me.mix)(N,b)],P);var Be=require("discord-api-types/v9");var q=class extends s{constructor(){super(...arguments);n(this,"type",Be.ApplicationCommandOptionType.Mentionable)}toJSON(){return this.runRequiredValidations(),{...this}}};var we=require("discord-api-types/v9"),Ee=require("ts-mixer"),ke=require("zod");var _e=ke.z.number().nonnegative(),T=class extends s{constructor(){super(...arguments);n(this,"type",we.ApplicationCommandOptionType.Number)}setMaxValue(e){return _e.parse(e),Reflect.set(this,"maxValue",e),this}setMinValue(e){return _e.parse(e),Reflect.set(this,"minValue",e),this}toJSON(){if(this.runRequiredValidations(),this.autocomplete&&Array.isArray(this.choices)&&this.choices.length>0)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return{...this}}};T=p([(0,Ee.mix)(N,b)],T);var Le=require("discord-api-types/v9");var z=class extends s{constructor(){super(...arguments);n(this,"type",Le.ApplicationCommandOptionType.Role)}toJSON(){return this.runRequiredValidations(),{...this}}};var Ve=require("discord-api-types/v9"),Ue=require("ts-mixer");var I=class extends s{constructor(){super(...arguments);n(this,"type",Ve.ApplicationCommandOptionType.String)}toJSON(){if(this.runRequiredValidations(),this.autocomplete&&Array.isArray(this.choices)&&this.choices.length>0)throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");return{...this}}};I=p([(0,Ue.mix)(b)],I);var De=require("discord-api-types/v9");var W=class extends s{constructor(){super(...arguments);n(this,"type",De.ApplicationCommandOptionType.User)}toJSON(){return this.runRequiredValidations(),{...this}}};var B=class{constructor(){n(this,"options")}addBooleanOption(e){return this._sharedAddOptionMethod(e,J)}addUserOption(e){return this._sharedAddOptionMethod(e,W)}addChannelOption(e){return this._sharedAddOptionMethod(e,y)}addRoleOption(e){return this._sharedAddOptionMethod(e,z)}addMentionableOption(e){return this._sharedAddOptionMethod(e,q)}addStringOption(e){return this._sharedAddOptionMethod(e,I)}addIntegerOption(e){return this._sharedAddOptionMethod(e,P)}addNumberOption(e){return this._sharedAddOptionMethod(e,T)}_sharedAddOptionMethod(e,i){let{options:o}=this;d(o);let r=typeof e=="function"?e(new i):e;return C(r,i),o.push(r),this}};var pe=require("discord-api-types/v9"),me=require("ts-mixer");var x=class{constructor(){n(this,"name");n(this,"description");n(this,"options",[])}addSubcommand(e){let{options:i}=this;d(i);let o=typeof e=="function"?e(new c):e;return C(o,c),i.push(o),this}toJSON(){return h(this.name,this.description,this.options),{type:pe.ApplicationCommandOptionType.SubcommandGroup,name:this.name,description:this.description,options:this.options.map(e=>e.toJSON())}}};x=p([(0,me.mix)(f)],x);var c=class{constructor(){n(this,"name");n(this,"description");n(this,"options",[])}toJSON(){return h(this.name,this.description,this.options),{type:pe.ApplicationCommandOptionType.Subcommand,name:this.name,description:this.description,options:this.options.map(e=>e.toJSON())}}};c=p([(0,me.mix)(f,B)],c);var j=class{constructor(){n(this,"name");n(this,"description");n(this,"options",[]);n(this,"defaultPermission")}toJSON(){return h(this.name,this.description,this.options),{name:this.name,description:this.description,options:this.options.map(e=>e.toJSON()),default_permission:this.defaultPermission}}setDefaultPermission(e){return ne(e),Reflect.set(this,"defaultPermission",e),this}addSubcommandGroup(e){let{options:i}=this;d(i);let o=typeof e=="function"?e(new x):e;return C(o,x),i.push(o),this}addSubcommand(e){let{options:i}=this;d(i);let o=typeof e=="function"?e(new c):e;return C(o,c),i.push(o),this}};j=p([(0,Fe.mix)(B,f)],j);var ue={};w(ue,{validateDefaultPermission:()=>ce,validateName:()=>Z,validateRequiredParameters:()=>de,validateType:()=>K});var $=require("zod"),le=require("discord-api-types/v9");function de(t,e){Z(t),K(e)}var At=$.z.string().min(1).max(32).regex(/^( *[\p{L}\p{N}_-]+ *)+$/u);function Z(t){At.parse(t)}var Ot=$.z.union([$.z.literal(le.ApplicationCommandType.User),$.z.literal(le.ApplicationCommandType.Message)]);function K(t){Ot.parse(t)}var St=$.z.boolean();function ce(t){St.parse(t)}var Je=class{constructor(){n(this,"name");n(this,"type");n(this,"defaultPermission")}setName(e){return Z(e),Reflect.set(this,"name",e),this}setType(e){return K(e),Reflect.set(this,"type",e),this}setDefaultPermission(e){return ce(e),Reflect.set(this,"defaultPermission",e),this}toJSON(){return de(this.name,this.type),{name:this.name,type:this.type,default_permission:this.defaultPermission}}};module.exports=Ke(yt);0&&(module.exports={ContextMenuCommandAssertions,ContextMenuCommandBuilder,Embed,EmbedAssertions,Faces,SlashCommandAssertions,SlashCommandBooleanOption,SlashCommandBuilder,SlashCommandChannelOption,SlashCommandIntegerOption,SlashCommandMentionableOption,SlashCommandNumberOption,SlashCommandRoleOption,SlashCommandStringOption,SlashCommandSubcommandBuilder,SlashCommandSubcommandGroupBuilder,SlashCommandUserOption,TimestampStyles,blockQuote,bold,channelMention,codeBlock,formatEmoji,hideLinkEmbed,hyperlink,inlineCode,italic,memberNicknameMention,quote,roleMention,spoiler,strikethrough,time,underscore,userMention});
4
+ //# sourceMappingURL=index.js.map