@discordjs/builders 1.4.0-dev.1667304280-8b400ca.0 → 1.4.0-dev.1667390683-5152abf.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,5 +1,5 @@
1
1
  import * as _sapphire_shapeshift from '@sapphire/shapeshift';
2
- import { APIEmbedField, APIEmbedAuthor, APIEmbedFooter, APIEmbedImage, APIEmbed, APISelectMenuOption, APIMessageComponentEmoji, ButtonStyle, APIActionRowComponent, APIActionRowComponentTypes, APIBaseComponent, ComponentType, APIButtonComponent, APISelectMenuComponent, APITextInputComponent, TextInputStyle, APIMessageActionRowComponent, APIModalActionRowComponent, APIModalComponent, APIMessageComponent, APIModalInteractionResponseCallbackData, LocalizationMap, LocaleString, ApplicationCommandOptionType, APIApplicationCommandBasicOption, APIApplicationCommandAttachmentOption, APIApplicationCommandBooleanOption, ChannelType, APIApplicationCommandChannelOption, APIApplicationCommandOptionChoice, APIApplicationCommandIntegerOption, APIApplicationCommandMentionableOption, APIApplicationCommandNumberOption, APIApplicationCommandRoleOption, APIApplicationCommandStringOption, APIApplicationCommandUserOption, APIApplicationCommandSubcommandGroupOption, APIApplicationCommandSubcommandOption, Permissions, RESTPostAPIChatInputApplicationCommandsJSONBody, APIApplicationCommandOption, Locale, RESTPostAPIContextMenuApplicationCommandsJSONBody, ApplicationCommandType } from 'discord-api-types/v10';
2
+ import { APIEmbedField, APIEmbedAuthor, APIEmbedFooter, APIEmbedImage, APIEmbed, APISelectMenuOption, APIMessageComponentEmoji, ButtonStyle, ChannelType, APIActionRowComponent, APIActionRowComponentTypes, APIBaseComponent, ComponentType, APIButtonComponent, APISelectMenuComponent, APIChannelSelectComponent, APIMentionableSelectComponent, APIRoleSelectComponent, APIStringSelectComponent, APIUserSelectComponent, APITextInputComponent, TextInputStyle, APIMessageActionRowComponent, APIModalActionRowComponent, APIModalComponent, APIMessageComponent, APIModalInteractionResponseCallbackData, LocalizationMap, LocaleString, ApplicationCommandOptionType, APIApplicationCommandBasicOption, APIApplicationCommandAttachmentOption, APIApplicationCommandBooleanOption, APIApplicationCommandChannelOption, APIApplicationCommandOptionChoice, APIApplicationCommandIntegerOption, APIApplicationCommandMentionableOption, APIApplicationCommandNumberOption, APIApplicationCommandRoleOption, APIApplicationCommandStringOption, APIApplicationCommandUserOption, APIApplicationCommandSubcommandGroupOption, APIApplicationCommandSubcommandOption, Permissions, RESTPostAPIChatInputApplicationCommandsJSONBody, APIApplicationCommandOption, Locale, RESTPostAPIContextMenuApplicationCommandsJSONBody, ApplicationCommandType } from 'discord-api-types/v10';
3
3
  import { URL } from 'node:url';
4
4
  import { Snowflake } from 'discord-api-types/globals';
5
5
  import { JSONEncodable, Equatable } from '@discordjs/util';
@@ -519,16 +519,16 @@ declare enum Faces {
519
519
  }
520
520
 
521
521
  /**
522
- * Represents a option within a select menu component
522
+ * Represents an option within a string select menu component
523
523
  */
524
- declare class SelectMenuOptionBuilder implements JSONEncodable<APISelectMenuOption> {
524
+ declare class StringSelectMenuOptionBuilder implements JSONEncodable<APISelectMenuOption> {
525
525
  data: Partial<APISelectMenuOption>;
526
526
  /**
527
- * Creates a new select menu option from API data
527
+ * Creates a new string select menu option from API data
528
528
  *
529
- * @param data - The API data to create this select menu option with
529
+ * @param data - The API data to create this string select menu option with
530
530
  * @example
531
- * Creating a select menu option from an API data object
531
+ * Creating a string select menu option from an API data object
532
532
  * ```ts
533
533
  * const selectMenuOption = new SelectMenuOptionBuilder({
534
534
  * label: 'catchy label',
@@ -536,7 +536,7 @@ declare class SelectMenuOptionBuilder implements JSONEncodable<APISelectMenuOpti
536
536
  * });
537
537
  * ```
538
538
  * @example
539
- * Creating a select menu option using setters and API data
539
+ * Creating a string select menu option using setters and API data
540
540
  * ```ts
541
541
  * const selectMenuOption = new SelectMenuOptionBuilder({
542
542
  * default: true,
@@ -619,12 +619,13 @@ declare const jsonOptionValidator: _sapphire_shapeshift.ObjectValidator<{
619
619
  }> | undefined;
620
620
  default: boolean | undefined;
621
621
  }>>;
622
- declare const optionValidator: _sapphire_shapeshift.InstanceValidator<SelectMenuOptionBuilder>;
623
- declare const optionsValidator: _sapphire_shapeshift.ArrayValidator<SelectMenuOptionBuilder[], SelectMenuOptionBuilder>;
622
+ declare const optionValidator: _sapphire_shapeshift.InstanceValidator<StringSelectMenuOptionBuilder>;
623
+ declare const optionsValidator: _sapphire_shapeshift.ArrayValidator<StringSelectMenuOptionBuilder[], StringSelectMenuOptionBuilder>;
624
624
  declare const optionsLengthValidator: _sapphire_shapeshift.NumberValidator<number>;
625
- declare function validateRequiredSelectMenuParameters(options: SelectMenuOptionBuilder[], customId?: string): void;
625
+ declare function validateRequiredSelectMenuParameters(options: StringSelectMenuOptionBuilder[], customId?: string): void;
626
626
  declare const defaultValidator: _sapphire_shapeshift.BooleanValidator<boolean>;
627
627
  declare function validateRequiredSelectMenuOptionParameters(label?: string, value?: string): void;
628
+ declare const channelTypesValidator: _sapphire_shapeshift.ArrayValidator<ChannelType[], ChannelType>;
628
629
  declare const urlValidator: _sapphire_shapeshift.StringValidator<string>;
629
630
  declare function validateRequiredButtonParameters(style?: ButtonStyle, label?: string, emoji?: APIMessageComponentEmoji, customId?: string, url?: string): void;
630
631
 
@@ -642,6 +643,7 @@ declare const Assertions$4_optionsLengthValidator: typeof optionsLengthValidator
642
643
  declare const Assertions$4_validateRequiredSelectMenuParameters: typeof validateRequiredSelectMenuParameters;
643
644
  declare const Assertions$4_defaultValidator: typeof defaultValidator;
644
645
  declare const Assertions$4_validateRequiredSelectMenuOptionParameters: typeof validateRequiredSelectMenuOptionParameters;
646
+ declare const Assertions$4_channelTypesValidator: typeof channelTypesValidator;
645
647
  declare const Assertions$4_urlValidator: typeof urlValidator;
646
648
  declare const Assertions$4_validateRequiredButtonParameters: typeof validateRequiredButtonParameters;
647
649
  declare namespace Assertions$4 {
@@ -661,6 +663,7 @@ declare namespace Assertions$4 {
661
663
  Assertions$4_validateRequiredSelectMenuParameters as validateRequiredSelectMenuParameters,
662
664
  Assertions$4_defaultValidator as defaultValidator,
663
665
  Assertions$4_validateRequiredSelectMenuOptionParameters as validateRequiredSelectMenuOptionParameters,
666
+ Assertions$4_channelTypesValidator as channelTypesValidator,
664
667
  Assertions$4_urlValidator as urlValidator,
665
668
  Assertions$4_validateRequiredButtonParameters as validateRequiredButtonParameters,
666
669
  };
@@ -768,14 +771,41 @@ declare class ButtonBuilder extends ComponentBuilder<APIButtonComponent> {
768
771
  toJSON(): APIButtonComponent;
769
772
  }
770
773
 
771
- /**
772
- * Represents a select menu component
773
- */
774
- declare class SelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent> {
774
+ declare class BaseSelectMenuBuilder<SelectMenuType extends APISelectMenuComponent> extends ComponentBuilder<SelectMenuType> {
775
775
  /**
776
- * The options within this select menu
776
+ * Sets the placeholder for this select menu
777
+ *
778
+ * @param placeholder - The placeholder to use for this select menu
779
+ */
780
+ setPlaceholder(placeholder: string): this;
781
+ /**
782
+ * Sets the minimum values that must be selected in the select menu
783
+ *
784
+ * @param minValues - The minimum values that must be selected
777
785
  */
778
- readonly options: SelectMenuOptionBuilder[];
786
+ setMinValues(minValues: number): this;
787
+ /**
788
+ * Sets the maximum values that must be selected in the select menu
789
+ *
790
+ * @param maxValues - The maximum values that must be selected
791
+ */
792
+ setMaxValues(maxValues: number): this;
793
+ /**
794
+ * Sets the custom id for this select menu
795
+ *
796
+ * @param customId - The custom id to use for this select menu
797
+ */
798
+ setCustomId(customId: string): this;
799
+ /**
800
+ * Sets whether this select menu is disabled
801
+ *
802
+ * @param disabled - Whether this select menu is disabled
803
+ */
804
+ setDisabled(disabled?: boolean): this;
805
+ toJSON(): SelectMenuType;
806
+ }
807
+
808
+ declare class ChannelSelectMenuBuilder extends BaseSelectMenuBuilder<APIChannelSelectComponent> {
779
809
  /**
780
810
  * Creates a new select menu from API data
781
811
  *
@@ -783,78 +813,166 @@ declare class SelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent>
783
813
  * @example
784
814
  * Creating a select menu from an API data object
785
815
  * ```ts
786
- * const selectMenu = new SelectMenuBuilder({
816
+ * const selectMenu = new ChannelSelectMenuBuilder({
787
817
  * custom_id: 'a cool select menu',
788
818
  * placeholder: 'select an option',
789
819
  * max_values: 2,
790
- * options: [
791
- * { label: 'option 1', value: '1' },
792
- * { label: 'option 2', value: '2' },
793
- * { label: 'option 3', value: '3' },
794
- * ],
795
820
  * });
796
821
  * ```
797
822
  * @example
798
823
  * Creating a select menu using setters and API data
799
824
  * ```ts
800
- * const selectMenu = new SelectMenuBuilder({
825
+ * const selectMenu = new ChannelSelectMenuBuilder({
801
826
  * custom_id: 'a cool select menu',
802
827
  * })
803
- * .setMinValues(1)
804
- * .addOptions({
805
- * label: 'Catchy',
806
- * value: 'catch',
807
- * });
828
+ * .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
829
+ * .setMinValues(2)
808
830
  * ```
809
831
  */
810
- constructor(data?: Partial<APISelectMenuComponent>);
832
+ constructor(data?: Partial<APIChannelSelectComponent>);
833
+ addChannelTypes(...types: RestOrArray<ChannelType>): this;
834
+ setChannelTypes(...types: RestOrArray<ChannelType>): this;
811
835
  /**
812
- * Sets the placeholder for this select menu
813
- *
814
- * @param placeholder - The placeholder to use for this select menu
836
+ * {@inheritDoc ComponentBuilder.toJSON}
815
837
  */
816
- setPlaceholder(placeholder: string): this;
838
+ toJSON(): APIChannelSelectComponent;
839
+ }
840
+
841
+ declare class MentionableSelectMenuBuilder extends BaseSelectMenuBuilder<APIMentionableSelectComponent> {
817
842
  /**
818
- * Sets the minimum values that must be selected in the select menu
843
+ * Creates a new select menu from API data
819
844
  *
820
- * @param minValues - The minimum values that must be selected
845
+ * @param data - The API data to create this select menu with
846
+ * @example
847
+ * Creating a select menu from an API data object
848
+ * ```ts
849
+ * const selectMenu = new MentionableSelectMenuBuilder({
850
+ * custom_id: 'a cool select menu',
851
+ * placeholder: 'select an option',
852
+ * max_values: 2,
853
+ * });
854
+ * ```
855
+ * @example
856
+ * Creating a select menu using setters and API data
857
+ * ```ts
858
+ * const selectMenu = new MentionableSelectMenuBuilder({
859
+ * custom_id: 'a cool select menu',
860
+ * })
861
+ * .setMinValues(1)
862
+ * ```
821
863
  */
822
- setMinValues(minValues: number): this;
864
+ constructor(data?: Partial<APIMentionableSelectComponent>);
865
+ }
866
+
867
+ declare class RoleSelectMenuBuilder extends BaseSelectMenuBuilder<APIRoleSelectComponent> {
823
868
  /**
824
- * Sets the maximum values that must be selected in the select menu
869
+ * Creates a new select menu from API data
825
870
  *
826
- * @param maxValues - The maximum values that must be selected
871
+ * @param data - The API data to create this select menu with
872
+ * @example
873
+ * Creating a select menu from an API data object
874
+ * ```ts
875
+ * const selectMenu = new RoleSelectMenuBuilder({
876
+ * custom_id: 'a cool select menu',
877
+ * placeholder: 'select an option',
878
+ * max_values: 2,
879
+ * });
880
+ * ```
881
+ * @example
882
+ * Creating a select menu using setters and API data
883
+ * ```ts
884
+ * const selectMenu = new RoleSelectMenuBuilder({
885
+ * custom_id: 'a cool select menu',
886
+ * })
887
+ * .setMinValues(1)
888
+ * ```
827
889
  */
828
- setMaxValues(maxValues: number): this;
890
+ constructor(data?: Partial<APIRoleSelectComponent>);
891
+ }
892
+
893
+ /**
894
+ * Represents a string select menu component
895
+ */
896
+ declare class StringSelectMenuBuilder extends BaseSelectMenuBuilder<APIStringSelectComponent> {
829
897
  /**
830
- * Sets the custom id for this select menu
831
- *
832
- * @param customId - The custom id to use for this select menu
898
+ * The options within this select menu
833
899
  */
834
- setCustomId(customId: string): this;
900
+ readonly options: StringSelectMenuOptionBuilder[];
835
901
  /**
836
- * Sets whether this select menu is disabled
902
+ * Creates a new select menu from API data
837
903
  *
838
- * @param disabled - Whether this select menu is disabled
904
+ * @param data - The API data to create this select menu with
905
+ * @example
906
+ * Creating a select menu from an API data object
907
+ * ```ts
908
+ * const selectMenu = new StringSelectMenuBuilder({
909
+ * custom_id: 'a cool select menu',
910
+ * placeholder: 'select an option',
911
+ * max_values: 2,
912
+ * options: [
913
+ * { label: 'option 1', value: '1' },
914
+ * { label: 'option 2', value: '2' },
915
+ * { label: 'option 3', value: '3' },
916
+ * ],
917
+ * });
918
+ * ```
919
+ * @example
920
+ * Creating a select menu using setters and API data
921
+ * ```ts
922
+ * const selectMenu = new StringSelectMenuBuilder({
923
+ * custom_id: 'a cool select menu',
924
+ * })
925
+ * .setMinValues(1)
926
+ * .addOptions({
927
+ * label: 'Catchy',
928
+ * value: 'catch',
929
+ * });
930
+ * ```
839
931
  */
840
- setDisabled(disabled?: boolean): this;
932
+ constructor(data?: Partial<APIStringSelectComponent>);
841
933
  /**
842
934
  * Adds options to this select menu
843
935
  *
844
936
  * @param options - The options to add to this select menu
845
937
  * @returns
846
938
  */
847
- addOptions(...options: RestOrArray<APISelectMenuOption | SelectMenuOptionBuilder>): this;
939
+ addOptions(...options: RestOrArray<APISelectMenuOption | StringSelectMenuOptionBuilder>): this;
848
940
  /**
849
941
  * Sets the options on this select menu
850
942
  *
851
943
  * @param options - The options to set on this select menu
852
944
  */
853
- setOptions(...options: RestOrArray<APISelectMenuOption | SelectMenuOptionBuilder>): this;
945
+ setOptions(...options: RestOrArray<APISelectMenuOption | StringSelectMenuOptionBuilder>): this;
854
946
  /**
855
947
  * {@inheritDoc ComponentBuilder.toJSON}
856
948
  */
857
- toJSON(): APISelectMenuComponent;
949
+ toJSON(): APIStringSelectComponent;
950
+ }
951
+
952
+ declare class UserSelectMenuBuilder extends BaseSelectMenuBuilder<APIUserSelectComponent> {
953
+ /**
954
+ * Creates a new select menu from API data
955
+ *
956
+ * @param data - The API data to create this select menu with
957
+ * @example
958
+ * Creating a select menu from an API data object
959
+ * ```ts
960
+ * const selectMenu = new UserSelectMenuBuilder({
961
+ * custom_id: 'a cool select menu',
962
+ * placeholder: 'select an option',
963
+ * max_values: 2,
964
+ * });
965
+ * ```
966
+ * @example
967
+ * Creating a select menu using setters and API data
968
+ * ```ts
969
+ * const selectMenu = new UserSelectMenuBuilder({
970
+ * custom_id: 'a cool select menu',
971
+ * })
972
+ * .setMinValues(1)
973
+ * ```
974
+ */
975
+ constructor(data?: Partial<APIUserSelectComponent>);
858
976
  }
859
977
 
860
978
  declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent> implements Equatable<APITextInputComponent | JSONEncodable<APITextInputComponent>> {
@@ -944,7 +1062,7 @@ declare class TextInputBuilder extends ComponentBuilder<APITextInputComponent> i
944
1062
 
945
1063
  declare type MessageComponentBuilder = ActionRowBuilder<MessageActionRowComponentBuilder> | MessageActionRowComponentBuilder;
946
1064
  declare type ModalComponentBuilder = ActionRowBuilder<ModalActionRowComponentBuilder> | ModalActionRowComponentBuilder;
947
- declare type MessageActionRowComponentBuilder = ButtonBuilder | SelectMenuBuilder;
1065
+ declare type MessageActionRowComponentBuilder = ButtonBuilder | ChannelSelectMenuBuilder | MentionableSelectMenuBuilder | RoleSelectMenuBuilder | StringSelectMenuBuilder | UserSelectMenuBuilder;
948
1066
  declare type ModalActionRowComponentBuilder = TextInputBuilder;
949
1067
  declare type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder;
950
1068
  /**
@@ -1013,8 +1131,12 @@ declare class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentB
1013
1131
  interface MappedComponentTypes {
1014
1132
  [ComponentType.ActionRow]: ActionRowBuilder<AnyComponentBuilder>;
1015
1133
  [ComponentType.Button]: ButtonBuilder;
1016
- [ComponentType.SelectMenu]: SelectMenuBuilder;
1134
+ [ComponentType.StringSelect]: StringSelectMenuBuilder;
1017
1135
  [ComponentType.TextInput]: TextInputBuilder;
1136
+ [ComponentType.UserSelect]: UserSelectMenuBuilder;
1137
+ [ComponentType.RoleSelect]: RoleSelectMenuBuilder;
1138
+ [ComponentType.MentionableSelect]: MentionableSelectMenuBuilder;
1139
+ [ComponentType.ChannelSelect]: ChannelSelectMenuBuilder;
1018
1140
  }
1019
1141
  /**
1020
1142
  * Factory for creating components from API data
@@ -1665,4 +1787,4 @@ declare const isValidationEnabled: () => boolean;
1665
1787
  */
1666
1788
  declare const version: string;
1667
1789
 
1668
- export { ActionRowBuilder, AnyAPIActionRowComponent, AnyComponentBuilder, ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionAllowedChannelTypes, ApplicationCommandOptionBase, ApplicationCommandOptionChannelTypesMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin, ButtonBuilder, Assertions$4 as ComponentAssertions, ComponentBuilder, Assertions as ContextMenuCommandAssertions, ContextMenuCommandBuilder, ContextMenuCommandType, Assertions$5 as EmbedAssertions, EmbedAuthorData, EmbedAuthorOptions, EmbedBuilder, EmbedFooterData, EmbedFooterOptions, EmbedImageData, Faces, IconData, MappedComponentTypes, MessageActionRowComponentBuilder, MessageComponentBuilder, ModalActionRowComponentBuilder, Assertions$2 as ModalAssertions, ModalBuilder, ModalComponentBuilder, RGBTuple, RestOrArray, SelectMenuBuilder, SelectMenuOptionBuilder, SharedNameAndDescription, SharedSlashCommandOptions, Assertions$1 as SlashCommandAssertions, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandBuilder, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandOptionsOnlyBuilder, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandUserOption, Assertions$3 as TextInputAssertions, TextInputBuilder, TimestampStyles, TimestampStylesString, ToAPIApplicationCommandOptions, blockQuote, bold, channelLink, channelMention, chatInputApplicationCommandMention, codeBlock, createComponentBuilder, disableValidators, embedLength, enableValidators, formatEmoji, hideLinkEmbed, hyperlink, inlineCode, isValidationEnabled, italic, messageLink, normalizeArray, quote, roleMention, spoiler, strikethrough, time, underscore, userMention, version };
1790
+ export { ActionRowBuilder, AnyAPIActionRowComponent, AnyComponentBuilder, ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionAllowedChannelTypes, ApplicationCommandOptionBase, ApplicationCommandOptionChannelTypesMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin, BaseSelectMenuBuilder, ButtonBuilder, ChannelSelectMenuBuilder, Assertions$4 as ComponentAssertions, ComponentBuilder, Assertions as ContextMenuCommandAssertions, ContextMenuCommandBuilder, ContextMenuCommandType, Assertions$5 as EmbedAssertions, EmbedAuthorData, EmbedAuthorOptions, EmbedBuilder, EmbedFooterData, EmbedFooterOptions, EmbedImageData, Faces, IconData, MappedComponentTypes, MentionableSelectMenuBuilder, MessageActionRowComponentBuilder, MessageComponentBuilder, ModalActionRowComponentBuilder, Assertions$2 as ModalAssertions, ModalBuilder, ModalComponentBuilder, RGBTuple, RestOrArray, RoleSelectMenuBuilder, StringSelectMenuBuilder as SelectMenuBuilder, StringSelectMenuOptionBuilder as SelectMenuOptionBuilder, SharedNameAndDescription, SharedSlashCommandOptions, Assertions$1 as SlashCommandAssertions, SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandBuilder, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandOptionsOnlyBuilder, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandSubcommandsOnlyBuilder, SlashCommandUserOption, StringSelectMenuBuilder, StringSelectMenuOptionBuilder, Assertions$3 as TextInputAssertions, TextInputBuilder, TimestampStyles, TimestampStylesString, ToAPIApplicationCommandOptions, UserSelectMenuBuilder, blockQuote, bold, channelLink, channelMention, chatInputApplicationCommandMention, codeBlock, createComponentBuilder, disableValidators, embedLength, enableValidators, formatEmoji, hideLinkEmbed, hyperlink, inlineCode, isValidationEnabled, italic, messageLink, normalizeArray, quote, roleMention, spoiler, strikethrough, time, underscore, userMention, version };