@discordjs/builders 0.8.2 → 0.12.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/dist/index.d.ts CHANGED
@@ -1,59 +1,77 @@
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, APIMessageComponentEmoji, APISelectMenuOption, ButtonStyle, ComponentType, APIMessageComponent, APIActionRowComponent, APIButtonComponent, APISelectMenuComponent, 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>;
28
-
29
- declare const Assertions$2_fieldNamePredicate: typeof fieldNamePredicate;
30
- declare const Assertions$2_fieldValuePredicate: typeof fieldValuePredicate;
31
- declare const Assertions$2_fieldInlinePredicate: typeof fieldInlinePredicate;
32
- declare const Assertions$2_embedFieldPredicate: typeof embedFieldPredicate;
33
- declare const Assertions$2_embedFieldsArrayPredicate: typeof embedFieldsArrayPredicate;
34
- declare const Assertions$2_validateFieldLength: typeof validateFieldLength;
35
- declare const Assertions$2_authorNamePredicate: typeof authorNamePredicate;
36
- declare const Assertions$2_urlPredicate: typeof urlPredicate;
37
- declare const Assertions$2_colorPredicate: typeof colorPredicate;
38
- declare const Assertions$2_descriptionPredicate: typeof descriptionPredicate;
39
- declare const Assertions$2_footerTextPredicate: typeof footerTextPredicate;
40
- declare const Assertions$2_timestampPredicate: typeof timestampPredicate;
41
- declare const Assertions$2_titlePredicate: typeof titlePredicate;
42
- declare namespace Assertions$2 {
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>;
44
+
45
+ declare const Assertions$3_fieldNamePredicate: typeof fieldNamePredicate;
46
+ declare const Assertions$3_fieldValuePredicate: typeof fieldValuePredicate;
47
+ declare const Assertions$3_fieldInlinePredicate: typeof fieldInlinePredicate;
48
+ declare const Assertions$3_embedFieldPredicate: typeof embedFieldPredicate;
49
+ declare const Assertions$3_embedFieldsArrayPredicate: typeof embedFieldsArrayPredicate;
50
+ declare const Assertions$3_fieldLengthPredicate: typeof fieldLengthPredicate;
51
+ declare const Assertions$3_validateFieldLength: typeof validateFieldLength;
52
+ declare const Assertions$3_authorNamePredicate: typeof authorNamePredicate;
53
+ declare const Assertions$3_urlPredicate: typeof urlPredicate;
54
+ declare const Assertions$3_colorPredicate: typeof colorPredicate;
55
+ declare const Assertions$3_descriptionPredicate: typeof descriptionPredicate;
56
+ declare const Assertions$3_footerTextPredicate: typeof footerTextPredicate;
57
+ declare const Assertions$3_timestampPredicate: typeof timestampPredicate;
58
+ declare const Assertions$3_titlePredicate: typeof titlePredicate;
59
+ declare namespace Assertions$3 {
43
60
  export {
44
- Assertions$2_fieldNamePredicate as fieldNamePredicate,
45
- Assertions$2_fieldValuePredicate as fieldValuePredicate,
46
- Assertions$2_fieldInlinePredicate as fieldInlinePredicate,
47
- Assertions$2_embedFieldPredicate as embedFieldPredicate,
48
- Assertions$2_embedFieldsArrayPredicate as embedFieldsArrayPredicate,
49
- Assertions$2_validateFieldLength as validateFieldLength,
50
- Assertions$2_authorNamePredicate as authorNamePredicate,
51
- Assertions$2_urlPredicate as urlPredicate,
52
- Assertions$2_colorPredicate as colorPredicate,
53
- Assertions$2_descriptionPredicate as descriptionPredicate,
54
- Assertions$2_footerTextPredicate as footerTextPredicate,
55
- Assertions$2_timestampPredicate as timestampPredicate,
56
- Assertions$2_titlePredicate as titlePredicate,
61
+ Assertions$3_fieldNamePredicate as fieldNamePredicate,
62
+ Assertions$3_fieldValuePredicate as fieldValuePredicate,
63
+ Assertions$3_fieldInlinePredicate as fieldInlinePredicate,
64
+ Assertions$3_embedFieldPredicate as embedFieldPredicate,
65
+ Assertions$3_embedFieldsArrayPredicate as embedFieldsArrayPredicate,
66
+ Assertions$3_fieldLengthPredicate as fieldLengthPredicate,
67
+ Assertions$3_validateFieldLength as validateFieldLength,
68
+ Assertions$3_authorNamePredicate as authorNamePredicate,
69
+ Assertions$3_urlPredicate as urlPredicate,
70
+ Assertions$3_colorPredicate as colorPredicate,
71
+ Assertions$3_descriptionPredicate as descriptionPredicate,
72
+ Assertions$3_footerTextPredicate as footerTextPredicate,
73
+ Assertions$3_timestampPredicate as timestampPredicate,
74
+ Assertions$3_titlePredicate as titlePredicate,
57
75
  };
58
76
  }
59
77
 
@@ -430,109 +448,384 @@ declare enum Faces {
430
448
  Unflip = "\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)"
431
449
  }
432
450
 
433
- declare class SlashCommandBooleanOption extends SlashCommandOptionBase {
451
+ /**
452
+ * Represents an option within a select menu component
453
+ */
454
+ declare class SelectMenuOption {
455
+ readonly label: string;
456
+ readonly value: string;
457
+ readonly description?: string;
458
+ readonly emoji?: APIMessageComponentEmoji;
459
+ readonly default?: boolean;
460
+ constructor(data?: APISelectMenuOption);
461
+ /**
462
+ * Sets the label of this option
463
+ * @param label The label to show on this option
464
+ */
465
+ setLabel(label: string): this;
466
+ /**
467
+ * Sets the value of this option
468
+ * @param value The value of this option
469
+ */
470
+ setValue(value: string): this;
471
+ /**
472
+ * Sets the description of this option.
473
+ * @param description The description of this option
474
+ */
475
+ setDescription(description: string): this;
476
+ /**
477
+ * Sets whether this option is selected by default
478
+ * @param isDefault Whether or not this option is selected by default
479
+ */
480
+ setDefault(isDefault: boolean): this;
481
+ /**
482
+ * Sets the emoji to display on this button
483
+ * @param emoji The emoji to display on this button
484
+ */
485
+ setEmoji(emoji: APIMessageComponentEmoji): this;
486
+ toJSON(): APISelectMenuOption;
487
+ }
488
+
489
+ declare const customIdValidator: z.ZodString;
490
+ declare const emojiValidator: z.ZodObject<{
491
+ id: z.ZodOptional<z.ZodString>;
492
+ name: z.ZodOptional<z.ZodString>;
493
+ animated: z.ZodOptional<z.ZodBoolean>;
494
+ }, "strict", z.ZodTypeAny, {
495
+ name?: string | undefined;
496
+ id?: string | undefined;
497
+ animated?: boolean | undefined;
498
+ }, {
499
+ name?: string | undefined;
500
+ id?: string | undefined;
501
+ animated?: boolean | undefined;
502
+ }>;
503
+ declare const disabledValidator: z.ZodBoolean;
504
+ declare const buttonLabelValidator: z.ZodString;
505
+ declare const buttonStyleValidator: z.ZodNumber;
506
+ declare const placeholderValidator: z.ZodString;
507
+ declare const minMaxValidator: z.ZodNumber;
508
+ declare const optionsValidator: z.ZodArray<z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>, "atleastone">;
509
+ declare function validateRequiredSelectMenuParameters(options: SelectMenuOption[], customId?: string): void;
510
+ declare const labelValueValidator: z.ZodString;
511
+ declare const defaultValidator: z.ZodBoolean;
512
+ declare function validateRequiredSelectMenuOptionParameters(label?: string, value?: string): void;
513
+ declare const urlValidator: z.ZodString;
514
+ declare function validateRequiredButtonParameters(style: ButtonStyle, label?: string, emoji?: APIMessageComponentEmoji, customId?: string, url?: string): void;
515
+
516
+ declare const Assertions$2_customIdValidator: typeof customIdValidator;
517
+ declare const Assertions$2_emojiValidator: typeof emojiValidator;
518
+ declare const Assertions$2_disabledValidator: typeof disabledValidator;
519
+ declare const Assertions$2_buttonLabelValidator: typeof buttonLabelValidator;
520
+ declare const Assertions$2_buttonStyleValidator: typeof buttonStyleValidator;
521
+ declare const Assertions$2_placeholderValidator: typeof placeholderValidator;
522
+ declare const Assertions$2_minMaxValidator: typeof minMaxValidator;
523
+ declare const Assertions$2_optionsValidator: typeof optionsValidator;
524
+ declare const Assertions$2_validateRequiredSelectMenuParameters: typeof validateRequiredSelectMenuParameters;
525
+ declare const Assertions$2_labelValueValidator: typeof labelValueValidator;
526
+ declare const Assertions$2_defaultValidator: typeof defaultValidator;
527
+ declare const Assertions$2_validateRequiredSelectMenuOptionParameters: typeof validateRequiredSelectMenuOptionParameters;
528
+ declare const Assertions$2_urlValidator: typeof urlValidator;
529
+ declare const Assertions$2_validateRequiredButtonParameters: typeof validateRequiredButtonParameters;
530
+ declare namespace Assertions$2 {
531
+ export {
532
+ Assertions$2_customIdValidator as customIdValidator,
533
+ Assertions$2_emojiValidator as emojiValidator,
534
+ Assertions$2_disabledValidator as disabledValidator,
535
+ Assertions$2_buttonLabelValidator as buttonLabelValidator,
536
+ Assertions$2_buttonStyleValidator as buttonStyleValidator,
537
+ Assertions$2_placeholderValidator as placeholderValidator,
538
+ Assertions$2_minMaxValidator as minMaxValidator,
539
+ Assertions$2_optionsValidator as optionsValidator,
540
+ Assertions$2_validateRequiredSelectMenuParameters as validateRequiredSelectMenuParameters,
541
+ Assertions$2_labelValueValidator as labelValueValidator,
542
+ Assertions$2_defaultValidator as defaultValidator,
543
+ Assertions$2_validateRequiredSelectMenuOptionParameters as validateRequiredSelectMenuOptionParameters,
544
+ Assertions$2_urlValidator as urlValidator,
545
+ Assertions$2_validateRequiredButtonParameters as validateRequiredButtonParameters,
546
+ };
547
+ }
548
+
549
+ /**
550
+ * Represents a discord component
551
+ */
552
+ interface Component {
553
+ /**
554
+ * The type of this component
555
+ */
556
+ readonly type: ComponentType;
557
+ /**
558
+ * Converts this component to an API-compatible JSON object
559
+ */
560
+ toJSON: () => APIMessageComponent;
561
+ }
562
+
563
+ declare type ActionRowComponent = ButtonComponent | SelectMenuComponent;
564
+ /**
565
+ * Represents an action row component
566
+ */
567
+ declare class ActionRow<T extends ActionRowComponent> implements Component {
568
+ readonly components: T[];
569
+ readonly type = ComponentType.ActionRow;
570
+ constructor(data?: APIActionRowComponent);
571
+ /**
572
+ * Adds components to this action row.
573
+ * @param components The components to add to this action row.
574
+ * @returns
575
+ */
576
+ addComponents(...components: T[]): this;
577
+ /**
578
+ * Sets the components in this action row
579
+ * @param components The components to set this row to
580
+ */
581
+ setComponents(components: T[]): this;
582
+ toJSON(): APIActionRowComponent;
583
+ }
584
+
585
+ declare class ButtonComponent implements Component {
586
+ readonly type: ComponentType.Button;
587
+ readonly style: ButtonStyle;
588
+ readonly label?: string;
589
+ readonly emoji?: APIMessageComponentEmoji;
590
+ readonly disabled?: boolean;
591
+ readonly custom_id: string;
592
+ readonly url: string;
593
+ constructor(data?: APIButtonComponent);
594
+ /**
595
+ * Sets the style of this button
596
+ * @param style The style of the button
597
+ */
598
+ setStyle(style: ButtonStyle): this;
599
+ /**
600
+ * Sets the URL for this button
601
+ * @param url The URL to open when this button is clicked
602
+ */
603
+ setURL(url: string): this;
604
+ /**
605
+ * Sets the custom Id for this button
606
+ * @param customId The custom ID to use for this button
607
+ */
608
+ setCustomId(customId: string): this;
609
+ /**
610
+ * Sets the emoji to display on this button
611
+ * @param emoji The emoji to display on this button
612
+ */
613
+ setEmoji(emoji: APIMessageComponentEmoji): this;
614
+ /**
615
+ * Sets whether this button is disable or not
616
+ * @param disabled Whether or not to disable this button or not
617
+ */
618
+ setDisabled(disabled: boolean): this;
619
+ /**
620
+ * Sets the label for this button
621
+ * @param label The label to display on this button
622
+ */
623
+ setLabel(label: string): this;
624
+ toJSON(): APIButtonComponent;
625
+ }
626
+
627
+ interface MappedComponentTypes {
628
+ [ComponentType.ActionRow]: ActionRow<ActionRowComponent>;
629
+ [ComponentType.Button]: ButtonComponent;
630
+ [ComponentType.SelectMenu]: SelectMenuComponent;
631
+ }
632
+ /**
633
+ * Factory for creating components from API data
634
+ * @param data The api data to transform to a component class
635
+ */
636
+ declare function createComponent<T extends keyof MappedComponentTypes>(data: APIMessageComponent & {
637
+ type: T;
638
+ }): MappedComponentTypes[T];
639
+
640
+ /**
641
+ * Represents a select menu component
642
+ */
643
+ declare class SelectMenuComponent implements Component {
644
+ readonly type: ComponentType.SelectMenu;
645
+ readonly options: SelectMenuOption[];
646
+ readonly placeholder?: string;
647
+ readonly min_values?: number;
648
+ readonly max_values?: number;
649
+ readonly custom_id: string;
650
+ readonly disabled?: boolean;
651
+ constructor(data?: APISelectMenuComponent);
652
+ /**
653
+ * Sets the placeholder for this select menu
654
+ * @param placeholder The placeholder to use for this select menu
655
+ */
656
+ setPlaceholder(placeholder: string): this;
657
+ /**
658
+ * Sets thes minimum values that must be selected in the select menu
659
+ * @param minValues The minimum values that must be selected
660
+ */
661
+ setMinValues(minValues: number): this;
662
+ /**
663
+ * Sets thes maximum values that must be selected in the select menu
664
+ * @param minValues The maximum values that must be selected
665
+ */
666
+ setMaxValues(maxValues: number): this;
667
+ /**
668
+ * Sets the custom Id for this select menu
669
+ * @param customId The custom ID to use for this select menu
670
+ */
671
+ setCustomId(customId: string): this;
672
+ /**
673
+ * Sets whether or not this select menu is disabled
674
+ * @param disabled Whether or not this select menu is disabled
675
+ */
676
+ setDisabled(disabled: boolean): this;
677
+ /**
678
+ * Adds options to this select menu
679
+ * @param options The options to add to this select menu
680
+ * @returns
681
+ */
682
+ addOptions(...options: SelectMenuOption[]): this;
683
+ /**
684
+ * Sets the options on this select menu
685
+ * @param options The options to set on this select menu
686
+ */
687
+ setOptions(options: SelectMenuOption[]): this;
688
+ toJSON(): APISelectMenuComponent;
689
+ }
690
+
691
+ declare class SharedNameAndDescription {
692
+ readonly name: string;
693
+ readonly description: string;
694
+ /**
695
+ * Sets the name
696
+ *
697
+ * @param name The name
698
+ */
699
+ setName(name: string): this;
700
+ /**
701
+ * Sets the description
702
+ *
703
+ * @param description The description
704
+ */
705
+ setDescription(description: string): this;
706
+ }
707
+
708
+ declare abstract class ApplicationCommandOptionBase extends SharedNameAndDescription {
709
+ abstract readonly type: ApplicationCommandOptionType;
710
+ readonly required: boolean;
711
+ /**
712
+ * Marks the option as required
713
+ *
714
+ * @param required If this option should be required
715
+ */
716
+ setRequired(required: boolean): this;
717
+ abstract toJSON(): APIApplicationCommandBasicOption;
718
+ protected runRequiredValidations(): void;
719
+ }
720
+
721
+ declare class SlashCommandBooleanOption extends ApplicationCommandOptionBase {
434
722
  readonly type: ApplicationCommandOptionType.Boolean;
435
- constructor();
723
+ toJSON(): APIApplicationCommandBooleanOption;
436
724
  }
437
725
 
438
- declare abstract class ApplicationCommandOptionWithChannelTypesBase extends SlashCommandOptionBase implements ToAPIApplicationCommandOptions {
439
- channelTypes?: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>[];
726
+ declare const allowedChannelTypes: readonly [ChannelType.GuildText, ChannelType.GuildVoice, ChannelType.GuildCategory, ChannelType.GuildNews, ChannelType.GuildStore, ChannelType.GuildNewsThread, ChannelType.GuildPublicThread, ChannelType.GuildPrivateThread, ChannelType.GuildStageVoice];
727
+ declare type ApplicationCommandOptionAllowedChannelTypes = typeof allowedChannelTypes[number];
728
+ declare class ApplicationCommandOptionChannelTypesMixin {
729
+ readonly channel_types?: ApplicationCommandOptionAllowedChannelTypes[];
440
730
  /**
441
731
  * Adds a channel type to this option
442
732
  *
443
733
  * @param channelType The type of channel to allow
444
734
  */
445
- addChannelType(channelType: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>): this;
735
+ addChannelType(channelType: ApplicationCommandOptionAllowedChannelTypes): this;
446
736
  /**
447
737
  * Adds channel types to this option
448
738
  *
449
739
  * @param channelTypes The channel types to add
450
740
  */
451
- addChannelTypes(channelTypes: Exclude<ChannelType, ChannelType.DM | ChannelType.GroupDM>[]): this;
452
- toJSON(): APIApplicationCommandChannelOptions;
741
+ addChannelTypes(channelTypes: ApplicationCommandOptionAllowedChannelTypes[]): this;
453
742
  }
454
743
 
455
- declare class SlashCommandChannelOption extends ApplicationCommandOptionWithChannelTypesBase {
744
+ declare class SlashCommandChannelOption extends ApplicationCommandOptionBase {
456
745
  readonly type: ApplicationCommandOptionType.Channel;
457
- constructor();
746
+ toJSON(): APIApplicationCommandChannelOption;
747
+ }
748
+ interface SlashCommandChannelOption extends ApplicationCommandOptionChannelTypesMixin {
458
749
  }
459
750
 
460
- declare abstract class ApplicationCommandOptionWithChoicesBase<T extends string | number> extends SlashCommandOptionBase implements ToAPIApplicationCommandOptions {
461
- choices?: APIApplicationCommandOptionChoice[];
751
+ declare abstract class ApplicationCommandNumericOptionMinMaxValueMixin {
752
+ readonly max_value?: number;
753
+ readonly min_value?: number;
754
+ /**
755
+ * Sets the maximum number value of this option
756
+ * @param max The maximum value this option can be
757
+ */
758
+ abstract setMaxValue(max: number): this;
759
+ /**
760
+ * Sets the minimum number value of this option
761
+ * @param min The minimum value this option can be
762
+ */
763
+ abstract setMinValue(min: number): this;
764
+ }
765
+
766
+ declare class ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T extends string | number> {
767
+ readonly choices?: APIApplicationCommandOptionChoice<T>[];
768
+ readonly autocomplete?: boolean;
769
+ readonly type: ApplicationCommandOptionType;
462
770
  /**
463
771
  * Adds a choice for this option
464
772
  *
465
773
  * @param name The name of the choice
466
774
  * @param value The value of the choice
467
775
  */
468
- addChoice(name: string, value: T): this;
776
+ addChoice(name: string, value: T): Omit<this, 'setAutocomplete'>;
469
777
  /**
470
778
  * Adds multiple choices for this option
471
779
  *
472
780
  * @param choices The choices to add
473
781
  */
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
- };
506
- }
507
-
508
- declare class SlashCommandIntegerOption extends ApplicationCommandOptionWithChoicesBase<number> {
782
+ addChoices(choices: [name: string, value: T][]): Omit<this, 'setAutocomplete'>;
783
+ setChoices<Input extends [name: string, value: T][]>(choices: Input): Input extends [] ? this & Pick<ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T>, 'setAutocomplete'> : Omit<this, 'setAutocomplete'>;
784
+ /**
785
+ * Marks the option as autocompletable
786
+ * @param autocomplete If this option should be autocompletable
787
+ */
788
+ setAutocomplete<U extends boolean>(autocomplete: U): U extends true ? Omit<this, 'addChoice' | 'addChoices'> : this & Pick<ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T>, 'addChoice' | 'addChoices'>;
789
+ }
790
+
791
+ declare class SlashCommandIntegerOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
509
792
  readonly type: ApplicationCommandOptionType.Integer;
510
- constructor();
793
+ setMaxValue(max: number): this;
794
+ setMinValue(min: number): this;
795
+ toJSON(): APIApplicationCommandIntegerOption;
796
+ }
797
+ interface SlashCommandIntegerOption extends ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {
511
798
  }
512
799
 
513
- declare class SlashCommandMentionableOption extends SlashCommandOptionBase {
800
+ declare class SlashCommandMentionableOption extends ApplicationCommandOptionBase {
514
801
  readonly type: ApplicationCommandOptionType.Mentionable;
515
- constructor();
802
+ toJSON(): APIApplicationCommandMentionableOption;
516
803
  }
517
804
 
518
- declare class SlashCommandNumberOption extends ApplicationCommandOptionWithChoicesBase<number> {
805
+ declare class SlashCommandNumberOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
519
806
  readonly type: ApplicationCommandOptionType.Number;
520
- constructor();
807
+ setMaxValue(max: number): this;
808
+ setMinValue(min: number): this;
809
+ toJSON(): APIApplicationCommandNumberOption;
810
+ }
811
+ interface SlashCommandNumberOption extends ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin<number> {
521
812
  }
522
813
 
523
- declare class SlashCommandRoleOption extends SlashCommandOptionBase {
814
+ declare class SlashCommandRoleOption extends ApplicationCommandOptionBase {
524
815
  readonly type: ApplicationCommandOptionType.Role;
525
- constructor();
816
+ toJSON(): APIApplicationCommandRoleOption;
526
817
  }
527
818
 
528
- declare class SlashCommandStringOption extends ApplicationCommandOptionWithChoicesBase<string> {
819
+ declare class SlashCommandStringOption extends ApplicationCommandOptionBase {
529
820
  readonly type: ApplicationCommandOptionType.String;
530
- constructor();
821
+ toJSON(): APIApplicationCommandStringOption;
822
+ }
823
+ interface SlashCommandStringOption extends ApplicationCommandOptionWithChoicesAndAutocompleteMixin<string> {
531
824
  }
532
825
 
533
- declare class SlashCommandUserOption extends SlashCommandOptionBase {
826
+ declare class SlashCommandUserOption extends ApplicationCommandOptionBase {
534
827
  readonly type: ApplicationCommandOptionType.User;
535
- constructor();
828
+ toJSON(): APIApplicationCommandUserOption;
536
829
  }
537
830
 
538
831
  declare class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
@@ -572,43 +865,26 @@ declare class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
572
865
  *
573
866
  * @param input A function that returns an option builder, or an already built builder
574
867
  */
575
- addStringOption(input: SlashCommandStringOption | ((builder: SlashCommandStringOption) => SlashCommandStringOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
868
+ 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
869
  /**
577
870
  * Adds an integer option
578
871
  *
579
872
  * @param input A function that returns an option builder, or an already built builder
580
873
  */
581
- addIntegerOption(input: SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
874
+ 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
875
  /**
583
876
  * Adds a number option
584
877
  *
585
878
  * @param input A function that returns an option builder, or an already built builder
586
879
  */
587
- addNumberOption(input: SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption)): ShouldOmitSubcommandFunctions extends true ? Omit<this, "addSubcommand" | "addSubcommandGroup"> : this;
880
+ 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
881
  private _sharedAddOptionMethod;
589
882
  }
590
883
 
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
884
  /**
609
885
  * Represents a folder for subcommands
610
886
  *
611
- * For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups
887
+ * For more information, go to https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups
612
888
  */
613
889
  declare class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationCommandOptions {
614
890
  /**
@@ -622,21 +898,21 @@ declare class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationComm
622
898
  /**
623
899
  * The subcommands part of this subcommand group
624
900
  */
625
- readonly options: ToAPIApplicationCommandOptions[];
901
+ readonly options: SlashCommandSubcommandBuilder[];
626
902
  /**
627
903
  * Adds a new subcommand to this group
628
904
  *
629
905
  * @param input A function that returns a subcommand builder, or an already built builder
630
906
  */
631
907
  addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): this;
632
- toJSON(): APIApplicationCommandSubCommandOptions;
908
+ toJSON(): APIApplicationCommandSubcommandGroupOption;
633
909
  }
634
910
  interface SlashCommandSubcommandGroupBuilder extends SharedNameAndDescription {
635
911
  }
636
912
  /**
637
913
  * Represents a subcommand
638
914
  *
639
- * For more information, go to https://discord.com/developers/docs/interactions/slash-commands#subcommands-and-subcommand-groups
915
+ * For more information, go to https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups
640
916
  */
641
917
  declare class SlashCommandSubcommandBuilder implements ToAPIApplicationCommandOptions {
642
918
  /**
@@ -650,8 +926,8 @@ declare class SlashCommandSubcommandBuilder implements ToAPIApplicationCommandOp
650
926
  /**
651
927
  * The options of this subcommand
652
928
  */
653
- readonly options: ToAPIApplicationCommandOptions[];
654
- toJSON(): APIApplicationCommandSubCommandOptions;
929
+ readonly options: ApplicationCommandOptionBase[];
930
+ toJSON(): APIApplicationCommandSubcommandOption;
655
931
  }
656
932
  interface SlashCommandSubcommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions<false> {
657
933
  }
@@ -711,41 +987,31 @@ interface SlashCommandSubcommandsOnlyBuilder extends SharedNameAndDescription, P
711
987
  interface SlashCommandOptionsOnlyBuilder extends SharedNameAndDescription, SharedSlashCommandOptions, Pick<SlashCommandBuilder, 'toJSON'> {
712
988
  }
713
989
  interface ToAPIApplicationCommandOptions {
714
- toJSON(): APIApplicationCommandOption;
715
- }
716
-
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;
990
+ toJSON: () => APIApplicationCommandOption;
728
991
  }
729
992
 
730
- declare function validateRequiredParameters$1(name: string, description: string, options: ToAPIApplicationCommandOptions[]): void;
731
993
  declare function validateName$1(name: unknown): asserts name is string;
732
994
  declare function validateDescription(description: unknown): asserts description is string;
733
- declare function validateDefaultPermission$1(value: unknown): asserts value is boolean;
734
995
  declare function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[];
996
+ declare function validateRequiredParameters$1(name: string, description: string, options: ToAPIApplicationCommandOptions[]): void;
997
+ declare function validateDefaultPermission$1(value: unknown): asserts value is boolean;
998
+ declare function validateRequired(required: unknown): asserts required is boolean;
735
999
  declare function validateMaxChoicesLength(choices: APIApplicationCommandOptionChoice[]): void;
736
- declare function assertReturnOfBuilder<T extends SlashCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
1000
+ declare function assertReturnOfBuilder<T extends ApplicationCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
737
1001
 
738
1002
  declare const Assertions$1_validateDescription: typeof validateDescription;
739
1003
  declare const Assertions$1_validateMaxOptionsLength: typeof validateMaxOptionsLength;
1004
+ declare const Assertions$1_validateRequired: typeof validateRequired;
740
1005
  declare const Assertions$1_validateMaxChoicesLength: typeof validateMaxChoicesLength;
741
1006
  declare const Assertions$1_assertReturnOfBuilder: typeof assertReturnOfBuilder;
742
1007
  declare namespace Assertions$1 {
743
1008
  export {
744
- validateRequiredParameters$1 as validateRequiredParameters,
745
1009
  validateName$1 as validateName,
746
1010
  Assertions$1_validateDescription as validateDescription,
747
- validateDefaultPermission$1 as validateDefaultPermission,
748
1011
  Assertions$1_validateMaxOptionsLength as validateMaxOptionsLength,
1012
+ validateRequiredParameters$1 as validateRequiredParameters,
1013
+ validateDefaultPermission$1 as validateDefaultPermission,
1014
+ Assertions$1_validateRequired as validateRequired,
749
1015
  Assertions$1_validateMaxChoicesLength as validateMaxChoicesLength,
750
1016
  Assertions$1_assertReturnOfBuilder as assertReturnOfBuilder,
751
1017
  };
@@ -797,22 +1063,22 @@ declare class ContextMenuCommandBuilder {
797
1063
  }
798
1064
  declare type ContextMenuCommandType = ApplicationCommandType.User | ApplicationCommandType.Message;
799
1065
 
800
- declare function validateRequiredParameters(name: string, type: number): void;
1066
+ declare function validateDefaultPermission(value: unknown): asserts value is boolean;
801
1067
  declare function validateName(name: unknown): asserts name is string;
802
1068
  declare function validateType(type: unknown): asserts type is ContextMenuCommandType;
803
- declare function validateDefaultPermission(value: unknown): asserts value is boolean;
1069
+ declare function validateRequiredParameters(name: string, type: number): void;
804
1070
 
805
- declare const Assertions_validateRequiredParameters: typeof validateRequiredParameters;
1071
+ declare const Assertions_validateDefaultPermission: typeof validateDefaultPermission;
806
1072
  declare const Assertions_validateName: typeof validateName;
807
1073
  declare const Assertions_validateType: typeof validateType;
808
- declare const Assertions_validateDefaultPermission: typeof validateDefaultPermission;
1074
+ declare const Assertions_validateRequiredParameters: typeof validateRequiredParameters;
809
1075
  declare namespace Assertions {
810
1076
  export {
811
- Assertions_validateRequiredParameters as validateRequiredParameters,
1077
+ Assertions_validateDefaultPermission as validateDefaultPermission,
812
1078
  Assertions_validateName as validateName,
813
1079
  Assertions_validateType as validateType,
814
- Assertions_validateDefaultPermission as validateDefaultPermission,
1080
+ Assertions_validateRequiredParameters as validateRequiredParameters,
815
1081
  };
816
1082
  }
817
1083
 
818
- export { AuthorOptions, Assertions as ContextMenuCommandAssertions, ContextMenuCommandBuilder, ContextMenuCommandType, Embed, Assertions$2 as EmbedAssertions, Faces, FooterOptions, Assertions$1 as SlashCommandAssertions, SlashCommandBooleanOption, SlashCommandBuilder, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandOptionsOnlyBuilder, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandUserOption, TimestampStyles, TimestampStylesString, ToAPIApplicationCommandOptions, blockQuote, bold, channelMention, codeBlock, formatEmoji, hideLinkEmbed, hyperlink, inlineCode, italic, memberNicknameMention, quote, roleMention, spoiler, strikethrough, time, underscore, userMention };
1084
+ export { ActionRow, ActionRowComponent, AuthorOptions, ButtonComponent, Component, Assertions$2 as ComponentAssertions, Assertions as ContextMenuCommandAssertions, ContextMenuCommandBuilder, ContextMenuCommandType, Embed, Assertions$3 as EmbedAssertions, Faces, FooterOptions, MappedComponentTypes, SelectMenuComponent, SelectMenuOption, Assertions$1 as SlashCommandAssertions, SlashCommandBooleanOption, SlashCommandBuilder, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandOptionsOnlyBuilder, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandUserOption, TimestampStyles, TimestampStylesString, ToAPIApplicationCommandOptions, blockQuote, bold, channelMention, codeBlock, createComponent, formatEmoji, hideLinkEmbed, hyperlink, inlineCode, italic, memberNicknameMention, quote, roleMention, spoiler, strikethrough, time, underscore, userMention };