@discordjs/builders 0.13.0-dev.1649937819-b01f414 → 0.13.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,7 +1,7 @@
1
1
  import * as _sapphire_shapeshift from '@sapphire/shapeshift';
2
- import { APIEmbedField, APIEmbedAuthor, APIEmbedFooter, APIEmbedImage, APIEmbed, APISelectMenuOption, APIMessageComponentEmoji, ButtonStyle, APIBaseComponent, ComponentType, APIModalComponent, APIMessageComponent, APIActionRowComponent, APIModalActionRowComponent, APIMessageActionRowComponent, APIActionRowComponentTypes, APIButtonComponent, APITextInputComponent, TextInputStyle, APIModalInteractionResponseCallbackData, APISelectMenuComponent, ApplicationCommandOptionType, APIApplicationCommandBasicOption, APIApplicationCommandBooleanOption, ChannelType, APIApplicationCommandChannelOption, APIApplicationCommandOptionChoice, APIApplicationCommandIntegerOption, APIApplicationCommandMentionableOption, APIApplicationCommandNumberOption, APIApplicationCommandRoleOption, APIApplicationCommandAttachmentOption, APIApplicationCommandStringOption, APIApplicationCommandUserOption, APIApplicationCommandSubcommandGroupOption, APIApplicationCommandSubcommandOption, RESTPostAPIApplicationCommandsJSONBody, APIApplicationCommandOption, ApplicationCommandType } from 'discord-api-types/v10';
3
- import { Snowflake } from 'discord-api-types/globals';
2
+ import { APIEmbedField, APIEmbedAuthor, APIEmbedFooter, APIEmbedImage, APIEmbed, APISelectMenuOption, APIMessageComponentEmoji, ButtonStyle, APIActionRowComponentTypes, APIActionRowComponent, APIBaseComponent, ComponentType, APIMessageActionRowComponent, APIModalActionRowComponent, APIButtonComponent, APIMessageComponent, APIModalComponent, APITextInputComponent, TextInputStyle, APIModalInteractionResponseCallbackData, APISelectMenuComponent, LocalizationMap, LocaleString, ApplicationCommandOptionType, APIApplicationCommandBasicOption, APIApplicationCommandAttachmentOption, APIApplicationCommandBooleanOption, ChannelType, APIApplicationCommandChannelOption, APIApplicationCommandOptionChoice, APIApplicationCommandIntegerOption, APIApplicationCommandMentionableOption, APIApplicationCommandNumberOption, APIApplicationCommandRoleOption, APIApplicationCommandStringOption, APIApplicationCommandUserOption, APIApplicationCommandSubcommandGroupOption, APIApplicationCommandSubcommandOption, RESTPostAPIApplicationCommandsJSONBody, APIApplicationCommandOption, Locale, ApplicationCommandType } from 'discord-api-types/v10';
4
3
  import { URL } from 'url';
4
+ import { Snowflake } from 'discord-api-types/globals';
5
5
 
6
6
  declare const fieldNamePredicate: _sapphire_shapeshift.StringValidator<string>;
7
7
  declare const fieldValuePredicate: _sapphire_shapeshift.StringValidator<string>;
@@ -539,35 +539,33 @@ interface JSONEncodable<T> {
539
539
  */
540
540
  declare function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown>;
541
541
 
542
+ declare type AnyAPIActionRowComponent = APIActionRowComponentTypes | APIActionRowComponent<APIActionRowComponentTypes>;
542
543
  /**
543
544
  * Represents a discord component
544
545
  */
545
- declare abstract class ComponentBuilder<DataType extends Partial<APIBaseComponent<ComponentType>> & {
546
- type: ComponentType;
547
- } = APIBaseComponent<ComponentType>> implements JSONEncodable<APIModalComponent | APIMessageComponent | APIActionRowComponent<APIModalActionRowComponent | APIMessageActionRowComponent>> {
546
+ declare abstract class ComponentBuilder<DataType extends Partial<APIBaseComponent<ComponentType>> = APIBaseComponent<ComponentType>> implements JSONEncodable<AnyAPIActionRowComponent> {
548
547
  /**
549
548
  * The API data associated with this component
550
549
  */
551
- readonly data: DataType;
552
- abstract toJSON(): APIActionRowComponentTypes | APIActionRowComponent<APIModalActionRowComponent | APIMessageActionRowComponent>;
553
- constructor(data: DataType);
550
+ readonly data: Partial<DataType>;
551
+ abstract toJSON(): AnyAPIActionRowComponent;
552
+ constructor(data: Partial<DataType>);
554
553
  }
555
554
 
556
555
  declare type MessageComponentBuilder = MessageActionRowComponentBuilder | ActionRowBuilder<MessageActionRowComponentBuilder>;
557
556
  declare type ModalComponentBuilder = ModalActionRowComponentBuilder | ActionRowBuilder<ModalActionRowComponentBuilder>;
558
557
  declare type MessageActionRowComponentBuilder = ButtonBuilder | SelectMenuBuilder;
559
558
  declare type ModalActionRowComponentBuilder = TextInputBuilder;
559
+ declare type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder;
560
560
  /**
561
561
  * Represents an action row component
562
562
  */
563
- declare class ActionRowBuilder<T extends MessageActionRowComponentBuilder | ModalActionRowComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder> extends ComponentBuilder<Omit<Partial<APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>> & {
564
- type: ComponentType.ActionRow;
565
- }, 'components'>> {
563
+ declare class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentBuilder<APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>> {
566
564
  /**
567
565
  * The components within this action row
568
566
  */
569
567
  readonly components: T[];
570
- constructor({ components, ...data }?: Partial<APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>>);
568
+ constructor({ components, ...data }?: Partial<APIActionRowComponent<APIActionRowComponentTypes>>);
571
569
  /**
572
570
  * Adds components to this action row.
573
571
  * @param components The components to add to this action row.
@@ -585,9 +583,7 @@ declare class ActionRowBuilder<T extends MessageActionRowComponentBuilder | Moda
585
583
  /**
586
584
  * Represents a non-validated button component
587
585
  */
588
- declare class UnsafeButtonBuilder extends ComponentBuilder<Partial<APIButtonComponent> & {
589
- type: ComponentType.Button;
590
- }> {
586
+ declare class UnsafeButtonBuilder extends ComponentBuilder<APIButtonComponent> {
591
587
  constructor(data?: Partial<APIButtonComponent>);
592
588
  /**
593
589
  * Sets the style of this button
@@ -636,7 +632,7 @@ declare class ButtonBuilder extends UnsafeButtonBuilder {
636
632
  }
637
633
 
638
634
  interface MappedComponentTypes {
639
- [ComponentType.ActionRow]: ActionRowBuilder;
635
+ [ComponentType.ActionRow]: ActionRowBuilder<AnyComponentBuilder>;
640
636
  [ComponentType.Button]: ButtonBuilder;
641
637
  [ComponentType.SelectMenu]: SelectMenuBuilder;
642
638
  [ComponentType.TextInput]: TextInputBuilder;
@@ -650,9 +646,7 @@ declare function createComponentBuilder<T extends keyof MappedComponentTypes>(da
650
646
  }): MappedComponentTypes[T];
651
647
  declare function createComponentBuilder<C extends MessageComponentBuilder | ModalComponentBuilder>(data: C): C;
652
648
 
653
- declare class UnsafeTextInputBuilder extends ComponentBuilder<Partial<APITextInputComponent> & {
654
- type: ComponentType.TextInput;
655
- }> {
649
+ declare class UnsafeTextInputBuilder extends ComponentBuilder<APITextInputComponent> {
656
650
  constructor(data?: APITextInputComponent & {
657
651
  type?: ComponentType.TextInput;
658
652
  });
@@ -739,7 +733,7 @@ declare namespace Assertions$3 {
739
733
  }
740
734
 
741
735
  declare class UnsafeModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {
742
- readonly data: Partial<Omit<APIModalInteractionResponseCallbackData, 'components'>>;
736
+ readonly data: Partial<APIModalInteractionResponseCallbackData>;
743
737
  readonly components: ActionRowBuilder<ModalActionRowComponentBuilder>[];
744
738
  constructor({ components, ...data }?: Partial<APIModalInteractionResponseCallbackData>);
745
739
  /**
@@ -772,7 +766,7 @@ declare class ModalBuilder extends UnsafeModalBuilder {
772
766
  }
773
767
 
774
768
  declare const titleValidator: _sapphire_shapeshift.StringValidator<string>;
775
- declare const componentsValidator: _sapphire_shapeshift.BaseValidator<[ActionRowBuilder<MessageActionRowComponentBuilder | TextInputBuilder>, ...ActionRowBuilder<MessageActionRowComponentBuilder | TextInputBuilder>[]]>;
769
+ declare const componentsValidator: _sapphire_shapeshift.BaseValidator<[ActionRowBuilder<AnyComponentBuilder>, ...ActionRowBuilder<AnyComponentBuilder>[]]>;
776
770
  declare function validateRequiredParameters$2(customId?: string, title?: string, components?: ActionRowBuilder<ModalActionRowComponentBuilder>[]): void;
777
771
 
778
772
  declare const Assertions$2_titleValidator: typeof titleValidator;
@@ -788,9 +782,7 @@ declare namespace Assertions$2 {
788
782
  /**
789
783
  * Represents a non-validated select menu component
790
784
  */
791
- declare class UnsafeSelectMenuBuilder extends ComponentBuilder<Partial<Omit<APISelectMenuComponent, 'options'>> & {
792
- type: ComponentType.SelectMenu;
793
- }> {
785
+ declare class UnsafeSelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent> {
794
786
  /**
795
787
  * The options within this select menu
796
788
  */
@@ -851,7 +843,9 @@ declare class SelectMenuBuilder extends UnsafeSelectMenuBuilder {
851
843
 
852
844
  declare class SharedNameAndDescription {
853
845
  readonly name: string;
846
+ readonly name_localizations?: LocalizationMap;
854
847
  readonly description: string;
848
+ readonly description_localizations?: LocalizationMap;
855
849
  /**
856
850
  * Sets the name
857
851
  *
@@ -864,6 +858,32 @@ declare class SharedNameAndDescription {
864
858
  * @param description The description
865
859
  */
866
860
  setDescription(description: string): this;
861
+ /**
862
+ * Sets a name localization
863
+ *
864
+ * @param locale The locale to set a description for
865
+ * @param localizedName The localized description for the given locale
866
+ */
867
+ setNameLocalization(locale: LocaleString, localizedName: string | null): this;
868
+ /**
869
+ * Sets the name localizations
870
+ *
871
+ * @param localizedNames The dictionary of localized descriptions to set
872
+ */
873
+ setNameLocalizations(localizedNames: LocalizationMap | null): this;
874
+ /**
875
+ * Sets a description localization
876
+ *
877
+ * @param locale The locale to set a description for
878
+ * @param localizedDescription The localized description for the given locale
879
+ */
880
+ setDescriptionLocalization(locale: LocaleString, localizedDescription: string | null): this;
881
+ /**
882
+ * Sets the description localizations
883
+ *
884
+ * @param localizedDescriptions The dictionary of localized descriptions to set
885
+ */
886
+ setDescriptionLocalizations(localizedDescriptions: LocalizationMap | null): this;
867
887
  }
868
888
 
869
889
  declare abstract class ApplicationCommandOptionBase extends SharedNameAndDescription {
@@ -879,6 +899,11 @@ declare abstract class ApplicationCommandOptionBase extends SharedNameAndDescrip
879
899
  protected runRequiredValidations(): void;
880
900
  }
881
901
 
902
+ declare class SlashCommandAttachmentOption extends ApplicationCommandOptionBase {
903
+ readonly type: ApplicationCommandOptionType.Attachment;
904
+ toJSON(): APIApplicationCommandAttachmentOption;
905
+ }
906
+
882
907
  declare class SlashCommandBooleanOption extends ApplicationCommandOptionBase {
883
908
  readonly type: ApplicationCommandOptionType.Boolean;
884
909
  toJSON(): APIApplicationCommandBooleanOption;
@@ -964,11 +989,6 @@ declare class SlashCommandRoleOption extends ApplicationCommandOptionBase {
964
989
  toJSON(): APIApplicationCommandRoleOption;
965
990
  }
966
991
 
967
- declare class SlashCommandAttachmentOption extends ApplicationCommandOptionBase {
968
- readonly type: ApplicationCommandOptionType.Attachment;
969
- toJSON(): APIApplicationCommandAttachmentOption;
970
- }
971
-
972
992
  declare class SlashCommandStringOption extends ApplicationCommandOptionBase {
973
993
  readonly type: ApplicationCommandOptionType.String;
974
994
  toJSON(): APIApplicationCommandStringOption;
@@ -1096,10 +1116,18 @@ declare class SlashCommandBuilder {
1096
1116
  * The name of this slash command
1097
1117
  */
1098
1118
  readonly name: string;
1119
+ /**
1120
+ * The localized names for this command
1121
+ */
1122
+ readonly name_localizations?: LocalizationMap;
1099
1123
  /**
1100
1124
  * The description of this slash command
1101
1125
  */
1102
1126
  readonly description: string;
1127
+ /**
1128
+ * The localized descriptions for this command
1129
+ */
1130
+ readonly description_localizations?: LocalizationMap;
1103
1131
  /**
1104
1132
  * The options of this slash command
1105
1133
  */
@@ -1151,6 +1179,7 @@ interface ToAPIApplicationCommandOptions {
1151
1179
 
1152
1180
  declare function validateName$1(name: unknown): asserts name is string;
1153
1181
  declare function validateDescription(description: unknown): asserts description is string;
1182
+ declare function validateLocale(locale: unknown): Locale;
1154
1183
  declare function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[];
1155
1184
  declare function validateRequiredParameters$1(name: string, description: string, options: ToAPIApplicationCommandOptions[]): void;
1156
1185
  declare function validateDefaultPermission$1(value: unknown): asserts value is boolean;
@@ -1159,6 +1188,7 @@ declare function validateChoicesLength(amountAdding: number, choices?: APIApplic
1159
1188
  declare function assertReturnOfBuilder<T extends ApplicationCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
1160
1189
 
1161
1190
  declare const Assertions$1_validateDescription: typeof validateDescription;
1191
+ declare const Assertions$1_validateLocale: typeof validateLocale;
1162
1192
  declare const Assertions$1_validateMaxOptionsLength: typeof validateMaxOptionsLength;
1163
1193
  declare const Assertions$1_validateRequired: typeof validateRequired;
1164
1194
  declare const Assertions$1_validateChoicesLength: typeof validateChoicesLength;
@@ -1167,6 +1197,7 @@ declare namespace Assertions$1 {
1167
1197
  export {
1168
1198
  validateName$1 as validateName,
1169
1199
  Assertions$1_validateDescription as validateDescription,
1200
+ Assertions$1_validateLocale as validateLocale,
1170
1201
  Assertions$1_validateMaxOptionsLength as validateMaxOptionsLength,
1171
1202
  validateRequiredParameters$1 as validateRequiredParameters,
1172
1203
  validateDefaultPermission$1 as validateDefaultPermission,
@@ -1254,4 +1285,4 @@ declare function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatab
1254
1285
 
1255
1286
  declare function embedLength(data: APIEmbed): number;
1256
1287
 
1257
- export { ActionRowBuilder, ButtonBuilder, Assertions$4 as ComponentAssertions, ComponentBuilder, Assertions as ContextMenuCommandAssertions, ContextMenuCommandBuilder, ContextMenuCommandType, Assertions$5 as EmbedAssertions, EmbedAuthorData, EmbedAuthorOptions, EmbedBuilder, EmbedFooterData, EmbedFooterOptions, EmbedImageData, Equatable, Faces, IconData, JSONEncodable, MappedComponentTypes, MessageActionRowComponentBuilder, MessageComponentBuilder, ModalActionRowComponentBuilder, Assertions$2 as ModalAssertions, ModalBuilder, ModalComponentBuilder, RGBTuple, SelectMenuBuilder, SelectMenuOptionBuilder, 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, UnsafeButtonBuilder, UnsafeEmbedBuilder, UnsafeModalBuilder, UnsafeSelectMenuBuilder, UnsafeSelectMenuOptionBuilder, UnsafeTextInputBuilder, blockQuote, bold, channelMention, codeBlock, createComponentBuilder, embedLength, formatEmoji, hideLinkEmbed, hyperlink, inlineCode, isEquatable, isJSONEncodable, italic, quote, roleMention, spoiler, strikethrough, time, underscore, userMention };
1288
+ export { ActionRowBuilder, AnyAPIActionRowComponent, AnyComponentBuilder, ButtonBuilder, Assertions$4 as ComponentAssertions, ComponentBuilder, Assertions as ContextMenuCommandAssertions, ContextMenuCommandBuilder, ContextMenuCommandType, Assertions$5 as EmbedAssertions, EmbedAuthorData, EmbedAuthorOptions, EmbedBuilder, EmbedFooterData, EmbedFooterOptions, EmbedImageData, Equatable, Faces, IconData, JSONEncodable, MappedComponentTypes, MessageActionRowComponentBuilder, MessageComponentBuilder, ModalActionRowComponentBuilder, Assertions$2 as ModalAssertions, ModalBuilder, ModalComponentBuilder, RGBTuple, SelectMenuBuilder, SelectMenuOptionBuilder, 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, UnsafeButtonBuilder, UnsafeEmbedBuilder, UnsafeModalBuilder, UnsafeSelectMenuBuilder, UnsafeSelectMenuOptionBuilder, UnsafeTextInputBuilder, blockQuote, bold, channelMention, codeBlock, createComponentBuilder, embedLength, formatEmoji, hideLinkEmbed, hyperlink, inlineCode, isEquatable, isJSONEncodable, italic, quote, roleMention, spoiler, strikethrough, time, underscore, userMention };