@discordjs/builders 0.13.0-dev.1649505810-3c0bbac → 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 +61 -36
- package/dist/index.js +122 -81
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +99 -50
- package/dist/index.mjs.map +1 -1
- package/package.json +88 -89
- package/CHANGELOG.md +0 -126
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,
|
|
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>;
|
|
@@ -297,12 +297,6 @@ declare function spoiler<C extends string>(content: C): `||${C}||`;
|
|
|
297
297
|
* @param userId The user ID to format
|
|
298
298
|
*/
|
|
299
299
|
declare function userMention<C extends Snowflake>(userId: C): `<@${C}>`;
|
|
300
|
-
/**
|
|
301
|
-
* Formats a user ID into a member-nickname mention
|
|
302
|
-
*
|
|
303
|
-
* @param memberId The user ID to format
|
|
304
|
-
*/
|
|
305
|
-
declare function memberNicknameMention<C extends Snowflake>(memberId: C): `<@!${C}>`;
|
|
306
300
|
/**
|
|
307
301
|
* Formats a channel ID into a channel mention
|
|
308
302
|
*
|
|
@@ -545,35 +539,33 @@ interface JSONEncodable<T> {
|
|
|
545
539
|
*/
|
|
546
540
|
declare function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown>;
|
|
547
541
|
|
|
542
|
+
declare type AnyAPIActionRowComponent = APIActionRowComponentTypes | APIActionRowComponent<APIActionRowComponentTypes>;
|
|
548
543
|
/**
|
|
549
544
|
* Represents a discord component
|
|
550
545
|
*/
|
|
551
|
-
declare abstract class ComponentBuilder<DataType extends Partial<APIBaseComponent<ComponentType>>
|
|
552
|
-
type: ComponentType;
|
|
553
|
-
} = APIBaseComponent<ComponentType>> implements JSONEncodable<APIModalComponent | APIMessageComponent | APIActionRowComponent<APIModalActionRowComponent | APIMessageActionRowComponent>> {
|
|
546
|
+
declare abstract class ComponentBuilder<DataType extends Partial<APIBaseComponent<ComponentType>> = APIBaseComponent<ComponentType>> implements JSONEncodable<AnyAPIActionRowComponent> {
|
|
554
547
|
/**
|
|
555
548
|
* The API data associated with this component
|
|
556
549
|
*/
|
|
557
|
-
readonly data: DataType
|
|
558
|
-
abstract toJSON():
|
|
559
|
-
constructor(data: DataType);
|
|
550
|
+
readonly data: Partial<DataType>;
|
|
551
|
+
abstract toJSON(): AnyAPIActionRowComponent;
|
|
552
|
+
constructor(data: Partial<DataType>);
|
|
560
553
|
}
|
|
561
554
|
|
|
562
555
|
declare type MessageComponentBuilder = MessageActionRowComponentBuilder | ActionRowBuilder<MessageActionRowComponentBuilder>;
|
|
563
556
|
declare type ModalComponentBuilder = ModalActionRowComponentBuilder | ActionRowBuilder<ModalActionRowComponentBuilder>;
|
|
564
557
|
declare type MessageActionRowComponentBuilder = ButtonBuilder | SelectMenuBuilder;
|
|
565
558
|
declare type ModalActionRowComponentBuilder = TextInputBuilder;
|
|
559
|
+
declare type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder;
|
|
566
560
|
/**
|
|
567
561
|
* Represents an action row component
|
|
568
562
|
*/
|
|
569
|
-
declare class ActionRowBuilder<T extends
|
|
570
|
-
type: ComponentType.ActionRow;
|
|
571
|
-
}, 'components'>> {
|
|
563
|
+
declare class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentBuilder<APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>> {
|
|
572
564
|
/**
|
|
573
565
|
* The components within this action row
|
|
574
566
|
*/
|
|
575
567
|
readonly components: T[];
|
|
576
|
-
constructor({ components, ...data }?: Partial<APIActionRowComponent<
|
|
568
|
+
constructor({ components, ...data }?: Partial<APIActionRowComponent<APIActionRowComponentTypes>>);
|
|
577
569
|
/**
|
|
578
570
|
* Adds components to this action row.
|
|
579
571
|
* @param components The components to add to this action row.
|
|
@@ -591,9 +583,7 @@ declare class ActionRowBuilder<T extends MessageActionRowComponentBuilder | Moda
|
|
|
591
583
|
/**
|
|
592
584
|
* Represents a non-validated button component
|
|
593
585
|
*/
|
|
594
|
-
declare class UnsafeButtonBuilder extends ComponentBuilder<
|
|
595
|
-
type: ComponentType.Button;
|
|
596
|
-
}> {
|
|
586
|
+
declare class UnsafeButtonBuilder extends ComponentBuilder<APIButtonComponent> {
|
|
597
587
|
constructor(data?: Partial<APIButtonComponent>);
|
|
598
588
|
/**
|
|
599
589
|
* Sets the style of this button
|
|
@@ -642,7 +632,7 @@ declare class ButtonBuilder extends UnsafeButtonBuilder {
|
|
|
642
632
|
}
|
|
643
633
|
|
|
644
634
|
interface MappedComponentTypes {
|
|
645
|
-
[ComponentType.ActionRow]: ActionRowBuilder
|
|
635
|
+
[ComponentType.ActionRow]: ActionRowBuilder<AnyComponentBuilder>;
|
|
646
636
|
[ComponentType.Button]: ButtonBuilder;
|
|
647
637
|
[ComponentType.SelectMenu]: SelectMenuBuilder;
|
|
648
638
|
[ComponentType.TextInput]: TextInputBuilder;
|
|
@@ -656,9 +646,7 @@ declare function createComponentBuilder<T extends keyof MappedComponentTypes>(da
|
|
|
656
646
|
}): MappedComponentTypes[T];
|
|
657
647
|
declare function createComponentBuilder<C extends MessageComponentBuilder | ModalComponentBuilder>(data: C): C;
|
|
658
648
|
|
|
659
|
-
declare class UnsafeTextInputBuilder extends ComponentBuilder<
|
|
660
|
-
type: ComponentType.TextInput;
|
|
661
|
-
}> {
|
|
649
|
+
declare class UnsafeTextInputBuilder extends ComponentBuilder<APITextInputComponent> {
|
|
662
650
|
constructor(data?: APITextInputComponent & {
|
|
663
651
|
type?: ComponentType.TextInput;
|
|
664
652
|
});
|
|
@@ -745,7 +733,7 @@ declare namespace Assertions$3 {
|
|
|
745
733
|
}
|
|
746
734
|
|
|
747
735
|
declare class UnsafeModalBuilder implements JSONEncodable<APIModalInteractionResponseCallbackData> {
|
|
748
|
-
readonly data: Partial<
|
|
736
|
+
readonly data: Partial<APIModalInteractionResponseCallbackData>;
|
|
749
737
|
readonly components: ActionRowBuilder<ModalActionRowComponentBuilder>[];
|
|
750
738
|
constructor({ components, ...data }?: Partial<APIModalInteractionResponseCallbackData>);
|
|
751
739
|
/**
|
|
@@ -778,7 +766,7 @@ declare class ModalBuilder extends UnsafeModalBuilder {
|
|
|
778
766
|
}
|
|
779
767
|
|
|
780
768
|
declare const titleValidator: _sapphire_shapeshift.StringValidator<string>;
|
|
781
|
-
declare const componentsValidator: _sapphire_shapeshift.BaseValidator<[ActionRowBuilder<
|
|
769
|
+
declare const componentsValidator: _sapphire_shapeshift.BaseValidator<[ActionRowBuilder<AnyComponentBuilder>, ...ActionRowBuilder<AnyComponentBuilder>[]]>;
|
|
782
770
|
declare function validateRequiredParameters$2(customId?: string, title?: string, components?: ActionRowBuilder<ModalActionRowComponentBuilder>[]): void;
|
|
783
771
|
|
|
784
772
|
declare const Assertions$2_titleValidator: typeof titleValidator;
|
|
@@ -794,9 +782,7 @@ declare namespace Assertions$2 {
|
|
|
794
782
|
/**
|
|
795
783
|
* Represents a non-validated select menu component
|
|
796
784
|
*/
|
|
797
|
-
declare class UnsafeSelectMenuBuilder extends ComponentBuilder<
|
|
798
|
-
type: ComponentType.SelectMenu;
|
|
799
|
-
}> {
|
|
785
|
+
declare class UnsafeSelectMenuBuilder extends ComponentBuilder<APISelectMenuComponent> {
|
|
800
786
|
/**
|
|
801
787
|
* The options within this select menu
|
|
802
788
|
*/
|
|
@@ -857,7 +843,9 @@ declare class SelectMenuBuilder extends UnsafeSelectMenuBuilder {
|
|
|
857
843
|
|
|
858
844
|
declare class SharedNameAndDescription {
|
|
859
845
|
readonly name: string;
|
|
846
|
+
readonly name_localizations?: LocalizationMap;
|
|
860
847
|
readonly description: string;
|
|
848
|
+
readonly description_localizations?: LocalizationMap;
|
|
861
849
|
/**
|
|
862
850
|
* Sets the name
|
|
863
851
|
*
|
|
@@ -870,6 +858,32 @@ declare class SharedNameAndDescription {
|
|
|
870
858
|
* @param description The description
|
|
871
859
|
*/
|
|
872
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;
|
|
873
887
|
}
|
|
874
888
|
|
|
875
889
|
declare abstract class ApplicationCommandOptionBase extends SharedNameAndDescription {
|
|
@@ -885,6 +899,11 @@ declare abstract class ApplicationCommandOptionBase extends SharedNameAndDescrip
|
|
|
885
899
|
protected runRequiredValidations(): void;
|
|
886
900
|
}
|
|
887
901
|
|
|
902
|
+
declare class SlashCommandAttachmentOption extends ApplicationCommandOptionBase {
|
|
903
|
+
readonly type: ApplicationCommandOptionType.Attachment;
|
|
904
|
+
toJSON(): APIApplicationCommandAttachmentOption;
|
|
905
|
+
}
|
|
906
|
+
|
|
888
907
|
declare class SlashCommandBooleanOption extends ApplicationCommandOptionBase {
|
|
889
908
|
readonly type: ApplicationCommandOptionType.Boolean;
|
|
890
909
|
toJSON(): APIApplicationCommandBooleanOption;
|
|
@@ -970,11 +989,6 @@ declare class SlashCommandRoleOption extends ApplicationCommandOptionBase {
|
|
|
970
989
|
toJSON(): APIApplicationCommandRoleOption;
|
|
971
990
|
}
|
|
972
991
|
|
|
973
|
-
declare class SlashCommandAttachmentOption extends ApplicationCommandOptionBase {
|
|
974
|
-
readonly type: ApplicationCommandOptionType.Attachment;
|
|
975
|
-
toJSON(): APIApplicationCommandAttachmentOption;
|
|
976
|
-
}
|
|
977
|
-
|
|
978
992
|
declare class SlashCommandStringOption extends ApplicationCommandOptionBase {
|
|
979
993
|
readonly type: ApplicationCommandOptionType.String;
|
|
980
994
|
toJSON(): APIApplicationCommandStringOption;
|
|
@@ -1102,10 +1116,18 @@ declare class SlashCommandBuilder {
|
|
|
1102
1116
|
* The name of this slash command
|
|
1103
1117
|
*/
|
|
1104
1118
|
readonly name: string;
|
|
1119
|
+
/**
|
|
1120
|
+
* The localized names for this command
|
|
1121
|
+
*/
|
|
1122
|
+
readonly name_localizations?: LocalizationMap;
|
|
1105
1123
|
/**
|
|
1106
1124
|
* The description of this slash command
|
|
1107
1125
|
*/
|
|
1108
1126
|
readonly description: string;
|
|
1127
|
+
/**
|
|
1128
|
+
* The localized descriptions for this command
|
|
1129
|
+
*/
|
|
1130
|
+
readonly description_localizations?: LocalizationMap;
|
|
1109
1131
|
/**
|
|
1110
1132
|
* The options of this slash command
|
|
1111
1133
|
*/
|
|
@@ -1157,6 +1179,7 @@ interface ToAPIApplicationCommandOptions {
|
|
|
1157
1179
|
|
|
1158
1180
|
declare function validateName$1(name: unknown): asserts name is string;
|
|
1159
1181
|
declare function validateDescription(description: unknown): asserts description is string;
|
|
1182
|
+
declare function validateLocale(locale: unknown): Locale;
|
|
1160
1183
|
declare function validateMaxOptionsLength(options: unknown): asserts options is ToAPIApplicationCommandOptions[];
|
|
1161
1184
|
declare function validateRequiredParameters$1(name: string, description: string, options: ToAPIApplicationCommandOptions[]): void;
|
|
1162
1185
|
declare function validateDefaultPermission$1(value: unknown): asserts value is boolean;
|
|
@@ -1165,6 +1188,7 @@ declare function validateChoicesLength(amountAdding: number, choices?: APIApplic
|
|
|
1165
1188
|
declare function assertReturnOfBuilder<T extends ApplicationCommandOptionBase | SlashCommandSubcommandBuilder | SlashCommandSubcommandGroupBuilder>(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
|
|
1166
1189
|
|
|
1167
1190
|
declare const Assertions$1_validateDescription: typeof validateDescription;
|
|
1191
|
+
declare const Assertions$1_validateLocale: typeof validateLocale;
|
|
1168
1192
|
declare const Assertions$1_validateMaxOptionsLength: typeof validateMaxOptionsLength;
|
|
1169
1193
|
declare const Assertions$1_validateRequired: typeof validateRequired;
|
|
1170
1194
|
declare const Assertions$1_validateChoicesLength: typeof validateChoicesLength;
|
|
@@ -1173,6 +1197,7 @@ declare namespace Assertions$1 {
|
|
|
1173
1197
|
export {
|
|
1174
1198
|
validateName$1 as validateName,
|
|
1175
1199
|
Assertions$1_validateDescription as validateDescription,
|
|
1200
|
+
Assertions$1_validateLocale as validateLocale,
|
|
1176
1201
|
Assertions$1_validateMaxOptionsLength as validateMaxOptionsLength,
|
|
1177
1202
|
validateRequiredParameters$1 as validateRequiredParameters,
|
|
1178
1203
|
validateDefaultPermission$1 as validateDefaultPermission,
|
|
@@ -1260,4 +1285,4 @@ declare function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatab
|
|
|
1260
1285
|
|
|
1261
1286
|
declare function embedLength(data: APIEmbed): number;
|
|
1262
1287
|
|
|
1263
|
-
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,
|
|
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 };
|