+## About
+
+`@discordjs/builders` is a utility package for easily building Discord API payloads.
+
## Installation
**Node.js 16.9.0 or newer is required.**
-```sh-session
+```sh
npm install @discordjs/builders
yarn add @discordjs/builders
pnpm add @discordjs/builders
@@ -28,16 +32,14 @@ pnpm add @discordjs/builders
## Examples
-Here are some examples for the builders and utilities you can find in this package:
-
-- [Slash Command Builders][example]
+You can find examples of how to use the builders in the [Slash Command Builders][example] examples.
## Links
- [Website][website] ([source][website-source])
- [Documentation][documentation]
- [Guide][guide] ([source][guide-source])
- See also the [Update Guide][guide-update], including updated and removed items in the library.
+ Also see the v13 to v14 [Update Guide][guide-update], which includes updated and removed items from the library.
- [discord.js Discord server][discord]
- [Discord API Discord server][discord-api]
- [GitHub][source]
@@ -52,13 +54,12 @@ See [the contribution guide][contributing] if you'd like to submit a PR.
## Help
-If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle
-nudge in the right direction, please don't hesitate to join our official [discord.js Server][discord].
+If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to join our official [discord.js Server][discord].
[example]: https://github.com/discordjs/discord.js/blob/main/packages/builders/docs/examples/Slash%20Command%20Builders.md
-[website]: https://discord.js.org/
+[website]: https://discord.js.org
[website-source]: https://github.com/discordjs/discord.js/tree/main/apps/website
-[documentation]: https://discord.js.org/#/docs/builders
+[documentation]: https://discord.js.org/docs/packages/builders/stable
[guide]: https://discordjs.guide/
[guide-source]: https://github.com/discordjs/guide
[guide-update]: https://discordjs.guide/additional-info/changes-in-v14.html
diff --git a/node_modules/@discordjs/builders/dist/index.d.ts b/node_modules/@discordjs/builders/dist/index.d.ts
index f5df124..5237d9b 100644
--- a/node_modules/@discordjs/builders/dist/index.d.ts
+++ b/node_modules/@discordjs/builders/dist/index.d.ts
@@ -1,9 +1,7 @@
import * as _sapphire_shapeshift from '@sapphire/shapeshift';
-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';
-import { URL } from 'node:url';
-import { Snowflake } from 'discord-api-types/globals';
+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, ApplicationCommandType, RESTPostAPIContextMenuApplicationCommandsJSONBody } from 'discord-api-types/v10';
+export * from '@discordjs/formatters';
import { JSONEncodable, Equatable } from '@discordjs/util';
-export * from '@discordjs/util';
declare const fieldNamePredicate: _sapphire_shapeshift.StringValidator;
declare const fieldValuePredicate: _sapphire_shapeshift.StringValidator;
@@ -54,92 +52,136 @@ declare const embedFooterPredicate: _sapphire_shapeshift.ObjectValidator<{
declare const timestampPredicate: _sapphire_shapeshift.UnionValidator;
declare const titlePredicate: _sapphire_shapeshift.UnionValidator;
-declare const Assertions$5_fieldNamePredicate: typeof fieldNamePredicate;
-declare const Assertions$5_fieldValuePredicate: typeof fieldValuePredicate;
-declare const Assertions$5_fieldInlinePredicate: typeof fieldInlinePredicate;
-declare const Assertions$5_embedFieldPredicate: typeof embedFieldPredicate;
-declare const Assertions$5_embedFieldsArrayPredicate: typeof embedFieldsArrayPredicate;
-declare const Assertions$5_fieldLengthPredicate: typeof fieldLengthPredicate;
-declare const Assertions$5_validateFieldLength: typeof validateFieldLength;
-declare const Assertions$5_authorNamePredicate: typeof authorNamePredicate;
-declare const Assertions$5_imageURLPredicate: typeof imageURLPredicate;
-declare const Assertions$5_urlPredicate: typeof urlPredicate;
-declare const Assertions$5_embedAuthorPredicate: typeof embedAuthorPredicate;
declare const Assertions$5_RGBPredicate: typeof RGBPredicate;
+declare const Assertions$5_authorNamePredicate: typeof authorNamePredicate;
declare const Assertions$5_colorPredicate: typeof colorPredicate;
declare const Assertions$5_descriptionPredicate: typeof descriptionPredicate;
-declare const Assertions$5_footerTextPredicate: typeof footerTextPredicate;
+declare const Assertions$5_embedAuthorPredicate: typeof embedAuthorPredicate;
+declare const Assertions$5_embedFieldPredicate: typeof embedFieldPredicate;
+declare const Assertions$5_embedFieldsArrayPredicate: typeof embedFieldsArrayPredicate;
declare const Assertions$5_embedFooterPredicate: typeof embedFooterPredicate;
+declare const Assertions$5_fieldInlinePredicate: typeof fieldInlinePredicate;
+declare const Assertions$5_fieldLengthPredicate: typeof fieldLengthPredicate;
+declare const Assertions$5_fieldNamePredicate: typeof fieldNamePredicate;
+declare const Assertions$5_fieldValuePredicate: typeof fieldValuePredicate;
+declare const Assertions$5_footerTextPredicate: typeof footerTextPredicate;
+declare const Assertions$5_imageURLPredicate: typeof imageURLPredicate;
declare const Assertions$5_timestampPredicate: typeof timestampPredicate;
declare const Assertions$5_titlePredicate: typeof titlePredicate;
+declare const Assertions$5_urlPredicate: typeof urlPredicate;
+declare const Assertions$5_validateFieldLength: typeof validateFieldLength;
declare namespace Assertions$5 {
export {
- Assertions$5_fieldNamePredicate as fieldNamePredicate,
- Assertions$5_fieldValuePredicate as fieldValuePredicate,
- Assertions$5_fieldInlinePredicate as fieldInlinePredicate,
- Assertions$5_embedFieldPredicate as embedFieldPredicate,
- Assertions$5_embedFieldsArrayPredicate as embedFieldsArrayPredicate,
- Assertions$5_fieldLengthPredicate as fieldLengthPredicate,
- Assertions$5_validateFieldLength as validateFieldLength,
- Assertions$5_authorNamePredicate as authorNamePredicate,
- Assertions$5_imageURLPredicate as imageURLPredicate,
- Assertions$5_urlPredicate as urlPredicate,
- Assertions$5_embedAuthorPredicate as embedAuthorPredicate,
Assertions$5_RGBPredicate as RGBPredicate,
+ Assertions$5_authorNamePredicate as authorNamePredicate,
Assertions$5_colorPredicate as colorPredicate,
Assertions$5_descriptionPredicate as descriptionPredicate,
- Assertions$5_footerTextPredicate as footerTextPredicate,
+ Assertions$5_embedAuthorPredicate as embedAuthorPredicate,
+ Assertions$5_embedFieldPredicate as embedFieldPredicate,
+ Assertions$5_embedFieldsArrayPredicate as embedFieldsArrayPredicate,
Assertions$5_embedFooterPredicate as embedFooterPredicate,
+ Assertions$5_fieldInlinePredicate as fieldInlinePredicate,
+ Assertions$5_fieldLengthPredicate as fieldLengthPredicate,
+ Assertions$5_fieldNamePredicate as fieldNamePredicate,
+ Assertions$5_fieldValuePredicate as fieldValuePredicate,
+ Assertions$5_footerTextPredicate as footerTextPredicate,
+ Assertions$5_imageURLPredicate as imageURLPredicate,
Assertions$5_timestampPredicate as timestampPredicate,
Assertions$5_titlePredicate as titlePredicate,
+ Assertions$5_urlPredicate as urlPredicate,
+ Assertions$5_validateFieldLength as validateFieldLength,
};
}
+/**
+ * Normalizes data that is a rest parameter or an array into an array with a depth of 1.
+ *
+ * @typeParam T - The data that must satisfy {@link RestOrArray}.
+ * @param arr - The (possibly variadic) data to normalize
+ */
declare function normalizeArray(arr: RestOrArray): T[];
+/**
+ * Represents data that may be an array or came from a rest parameter.
+ *
+ * @remarks
+ * This type is used throughout builders to ensure both an array and variadic arguments
+ * may be used. It is normalized with {@link normalizeArray}.
+ */
type RestOrArray = T[] | [T[]];
+/**
+ * A tuple satisfying the RGB color model.
+ *
+ * @see {@link https://developer.mozilla.org/docs/Glossary/RGB}
+ */
type RGBTuple = [red: number, green: number, blue: number];
+/**
+ * The base icon data typically used in payloads.
+ */
interface IconData {
/**
- * The URL of the icon
+ * The URL of the icon.
*/
iconURL?: string;
/**
- * The proxy URL of the icon
+ * The proxy URL of the icon.
*/
proxyIconURL?: string;
}
+/**
+ * Represents the author data of an embed.
+ */
type EmbedAuthorData = IconData & Omit;
+/**
+ * Represents the author options of an embed.
+ */
type EmbedAuthorOptions = Omit;
+/**
+ * Represents the footer data of an embed.
+ */
type EmbedFooterData = IconData & Omit;
+/**
+ * Represents the footer options of an embed.
+ */
type EmbedFooterOptions = Omit;
+/**
+ * Represents the image data of an embed.
+ */
interface EmbedImageData extends Omit {
/**
- * The proxy URL for the image
+ * The proxy URL for the image.
*/
proxyURL?: string;
}
/**
- * Represents a embed in a message (image/video preview, rich embed, etc.)
+ * A builder that creates API-compatible JSON data for embeds.
*/
declare class EmbedBuilder {
+ /**
+ * The API data associated with this embed.
+ */
readonly data: APIEmbed;
+ /**
+ * Creates a new embed from API data.
+ *
+ * @param data - The API data to create this embed with
+ */
constructor(data?: APIEmbed);
/**
- * Appends fields to the embed
+ * Appends fields to the embed.
*
* @remarks
* This method accepts either an array of fields or a variable number of field parameters.
* The maximum amount of fields that can be added is 25.
* @example
- * Using an array
+ * Using an array:
* ```ts
* const fields: APIEmbedField[] = ...;
* const embed = new EmbedBuilder()
* .addFields(fields);
* ```
* @example
- * Using rest parameters (variadic)
+ * Using rest parameters (variadic):
* ```ts
* const embed = new EmbedBuilder()
* .addFields(
@@ -151,27 +193,27 @@ declare class EmbedBuilder {
*/
addFields(...fields: RestOrArray): this;
/**
- * Removes, replaces, or inserts fields in the embed.
+ * Removes, replaces, or inserts fields for this embed.
*
* @remarks
* This method behaves similarly
- * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice}.
+ * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
* The maximum amount of fields that can be added is 25.
*
* It's useful for modifying and adjusting order of the already-existing fields of an embed.
* @example
- * Remove the first field
+ * Remove the first field:
* ```ts
* embed.spliceFields(0, 1);
* ```
* @example
- * Remove the first n fields
+ * Remove the first n fields:
* ```ts
- * const n = 4
+ * const n = 4;
* embed.spliceFields(0, n);
* ```
* @example
- * Remove the last field
+ * Remove the last field:
* ```ts
* embed.spliceFields(-1, 1);
* ```
@@ -181,7 +223,7 @@ declare class EmbedBuilder {
*/
spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this;
/**
- * Sets the embed's fields
+ * Sets the fields for this embed.
*
* @remarks
* This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,
@@ -192,350 +234,80 @@ declare class EmbedBuilder {
*/
setFields(...fields: RestOrArray): this;
/**
- * Sets the author of this embed
+ * Sets the author of this embed.
*
- * @param options - The options for the author
+ * @param options - The options to use
*/
setAuthor(options: EmbedAuthorOptions | null): this;
/**
- * Sets the color of this embed
+ * Sets the color of this embed.
*
- * @param color - The color of the embed
+ * @param color - The color to use
*/
setColor(color: RGBTuple | number | null): this;
/**
- * Sets the description of this embed
+ * Sets the description of this embed.
*
- * @param description - The description
+ * @param description - The description to use
*/
setDescription(description: string | null): this;
/**
- * Sets the footer of this embed
+ * Sets the footer of this embed.
*
- * @param options - The options for the footer
+ * @param options - The footer to use
*/
setFooter(options: EmbedFooterOptions | null): this;
/**
- * Sets the image of this embed
+ * Sets the image of this embed.
*
- * @param url - The URL of the image
+ * @param url - The image URL to use
*/
setImage(url: string | null): this;
/**
- * Sets the thumbnail of this embed
+ * Sets the thumbnail of this embed.
*
- * @param url - The URL of the thumbnail
+ * @param url - The thumbnail URL to use
*/
setThumbnail(url: string | null): this;
/**
- * Sets the timestamp of this embed
+ * Sets the timestamp of this embed.
*
- * @param timestamp - The timestamp or date
+ * @param timestamp - The timestamp or date to use
*/
setTimestamp(timestamp?: Date | number | null): this;
/**
- * Sets the title of this embed
+ * Sets the title for this embed.
*
- * @param title - The title
+ * @param title - The title to use
*/
setTitle(title: string | null): this;
/**
- * Sets the URL of this embed
+ * Sets the URL of this embed.
*
- * @param url - The URL
+ * @param url - The URL to use
*/
setURL(url: string | null): this;
/**
- * Transforms the embed to a plain object
+ * Serializes this builder to API-compatible JSON data.
+ *
+ * @remarks
+ * This method runs validations on the data before serializing it.
+ * As such, it may throw an error if the data is invalid.
*/
toJSON(): APIEmbed;
}
/**
- * Wraps the content inside a codeblock with no language
- *
- * @param content - The content to wrap
- */
-declare function codeBlock(content: C): `\`\`\`\n${C}\n\`\`\``;
-/**
- * Wraps the content inside a codeblock with the specified language
- *
- * @param language - The language for the codeblock
- * @param content - The content to wrap
- */
-declare function codeBlock(language: L, content: C): `\`\`\`${L}\n${C}\n\`\`\``;
-/**
- * Wraps the content inside \`backticks\`, which formats it as inline code
- *
- * @param content - The content to wrap
- */
-declare function inlineCode(content: C): `\`${C}\``;
-/**
- * Formats the content into italic text
- *
- * @param content - The content to wrap
- */
-declare function italic(content: C): `_${C}_`;
-/**
- * Formats the content into bold text
- *
- * @param content - The content to wrap
- */
-declare function bold(content: C): `**${C}**`;
-/**
- * Formats the content into underscored text
- *
- * @param content - The content to wrap
- */
-declare function underscore(content: C): `__${C}__`;
-/**
- * Formats the content into strike-through text
- *
- * @param content - The content to wrap
- */
-declare function strikethrough(content: C): `~~${C}~~`;
-/**
- * Formats the content into a quote. This needs to be at the start of the line for Discord to format it
- *
- * @param content - The content to wrap
- */
-declare function quote(content: C): `> ${C}`;
-/**
- * Formats the content into a block quote. This needs to be at the start of the line for Discord to format it
- *
- * @param content - The content to wrap
- */
-declare function blockQuote(content: C): `>>> ${C}`;
-/**
- * Wraps the URL into `<>`, which stops it from embedding
- *
- * @param url - The URL to wrap
- */
-declare function hideLinkEmbed(url: C): `<${C}>`;
-/**
- * Wraps the URL into `<>`, which stops it from embedding
- *
- * @param url - The URL to wrap
- */
-declare function hideLinkEmbed(url: URL): `<${string}>`;
-/**
- * Formats the content and the URL into a masked URL
- *
- * @param content - The content to display
- * @param url - The URL the content links to
- */
-declare function hyperlink(content: C, url: URL): `[${C}](${string})`;
-/**
- * Formats the content and the URL into a masked URL
- *
- * @param content - The content to display
- * @param url - The URL the content links to
- */
-declare function hyperlink(content: C, url: U): `[${C}](${U})`;
-/**
- * Formats the content and the URL into a masked URL
- *
- * @param content - The content to display
- * @param url - The URL the content links to
- * @param title - The title shown when hovering on the masked link
- */
-declare function hyperlink(content: C, url: URL, title: T): `[${C}](${string} "${T}")`;
-/**
- * Formats the content and the URL into a masked URL
- *
- * @param content - The content to display
- * @param url - The URL the content links to
- * @param title - The title shown when hovering on the masked link
- */
-declare function hyperlink(content: C, url: U, title: T): `[${C}](${U} "${T}")`;
-/**
- * Wraps the content inside spoiler (hidden text)
- *
- * @param content - The content to wrap
- */
-declare function spoiler(content: C): `||${C}||`;
-/**
- * Formats a user ID into a user mention
- *
- * @param userId - The user ID to format
- */
-declare function userMention(userId: C): `<@${C}>`;
-/**
- * Formats a channel ID into a channel mention
- *
- * @param channelId - The channel ID to format
- */
-declare function channelMention(channelId: C): `<#${C}>`;
-/**
- * Formats a role ID into a role mention
- *
- * @param roleId - The role ID to format
- */
-declare function roleMention(roleId: C): `<@&${C}>`;
-/**
- * Formats an application command name, subcommand group name, subcommand name, and ID into an application command mention
- *
- * @param commandName - The application command name to format
- * @param subcommandGroupName - The subcommand group name to format
- * @param subcommandName - The subcommand name to format
- * @param commandId - The application command ID to format
- */
-declare function chatInputApplicationCommandMention(commandName: N, subcommandGroupName: G, subcommandName: S, commandId: I): `${N} ${G} ${S}:${I}>`;
-/**
- * Formats an application command name, subcommand name, and ID into an application command mention
- *
- * @param commandName - The application command name to format
- * @param subcommandName - The subcommand name to format
- * @param commandId - The application command ID to format
- */
-declare function chatInputApplicationCommandMention(commandName: N, subcommandName: S, commandId: I): `${N} ${S}:${I}>`;
-/**
- * Formats an application command name and ID into an application command mention
- *
- * @param commandName - The application command name to format
- * @param commandId - The application command ID to format
- */
-declare function chatInputApplicationCommandMention(commandName: N, commandId: I): `${N}:${I}>`;
-/**
- * Formats an emoji ID into a fully qualified emoji identifier
- *
- * @param emojiId - The emoji ID to format
- */
-declare function formatEmoji(emojiId: C, animated?: false): `<:_:${C}>`;
-/**
- * Formats an emoji ID into a fully qualified emoji identifier
- *
- * @param emojiId - The emoji ID to format
- * @param animated - Whether the emoji is animated or not. Defaults to `false`
- */
-declare function formatEmoji(emojiId: C, animated?: true): ``;
-/**
- * Formats an emoji ID into a fully qualified emoji identifier
- *
- * @param emojiId - The emoji ID to format
- * @param animated - Whether the emoji is animated or not. Defaults to `false`
- */
-declare function formatEmoji(emojiId: C, animated?: boolean): `<:_:${C}>` | ``;
-/**
- * Formats a channel link for a direct message channel.
- *
- * @param channelId - The channel's id
- */
-declare function channelLink(channelId: C): `https://discord.com/channels/@me/${C}`;
-/**
- * Formats a channel link for a guild channel.
- *
- * @param channelId - The channel's id
- * @param guildId - The guild's id
- */
-declare function channelLink(channelId: C, guildId: G): `https://discord.com/channels/${G}/${C}`;
-/**
- * Formats a message link for a direct message channel.
- *
- * @param channelId - The channel's id
- * @param messageId - The message's id
- */
-declare function messageLink(channelId: C, messageId: M): `https://discord.com/channels/@me/${C}/${M}`;
-/**
- * Formats a message link for a guild channel.
- *
- * @param channelId - The channel's id
- * @param messageId - The message's id
- * @param guildId - The guild's id
- */
-declare function messageLink(channelId: C, messageId: M, guildId: G): `https://discord.com/channels/${G}/${C}/${M}`;
-/**
- * Formats a date into a short date-time string
- *
- * @param date - The date to format, defaults to the current time
- */
-declare function time(date?: Date): ``;
-/**
- * Formats a date given a format style
- *
- * @param date - The date to format
- * @param style - The style to use
- */
-declare function time(date: Date, style: S): ``;
-/**
- * Formats the given timestamp into a short date-time string
- *
- * @param seconds - The time to format, represents an UNIX timestamp in seconds
- */
-declare function time(seconds: C): ``;
-/**
- * Formats the given timestamp into a short date-time string
- *
- * @param seconds - The time to format, represents an UNIX timestamp in seconds
- * @param style - The style to use
- */
-declare function time(seconds: C, style: S): ``;
-/**
- * The {@link https://discord.com/developers/docs/reference#message-formatting-timestamp-styles | message formatting timestamp styles} supported by Discord
- */
-declare const TimestampStyles: {
- /**
- * Short time format, consisting of hours and minutes, e.g. 16:20
- */
- readonly ShortTime: "t";
- /**
- * Long time format, consisting of hours, minutes, and seconds, e.g. 16:20:30
- */
- readonly LongTime: "T";
- /**
- * Short date format, consisting of day, month, and year, e.g. 20/04/2021
- */
- readonly ShortDate: "d";
- /**
- * Long date format, consisting of day, month, and year, e.g. 20 April 2021
- */
- readonly LongDate: "D";
- /**
- * Short date-time format, consisting of short date and short time formats, e.g. 20 April 2021 16:20
- */
- readonly ShortDateTime: "f";
- /**
- * Long date-time format, consisting of long date and short time formats, e.g. Tuesday, 20 April 2021 16:20
- */
- readonly LongDateTime: "F";
- /**
- * Relative time format, consisting of a relative duration format, e.g. 2 months ago
- */
- readonly RelativeTime: "R";
-};
-/**
- * The possible values, see {@link TimestampStyles} for more information
- */
-type TimestampStylesString = typeof TimestampStyles[keyof typeof TimestampStyles];
-/**
- * An enum with all the available faces from Discord's native slash commands
- */
-declare enum Faces {
- /**
- * ¯\\_(ツ)\\_/¯
- */
- Shrug = "\u00AF\\_(\u30C4)\\_/\u00AF",
- /**
- * (╯°□°)╯︵ ┻━┻
- */
- Tableflip = "(\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35 \u253B\u2501\u253B",
- /**
- * ┬─┬ ノ( ゜-゜ノ)
- */
- Unflip = "\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)"
-}
-
-/**
- * Represents an option within a string select menu component
+ * A builder that creates API-compatible JSON data for string select menu options.
*/
declare class StringSelectMenuOptionBuilder implements JSONEncodable {
data: Partial;
/**
- * Creates a new string select menu option from API data
+ * Creates a new string select menu option from API data.
*
* @param data - The API data to create this string select menu option with
* @example
- * Creating a string select menu option from an API data object
+ * Creating a string select menu option from an API data object:
* ```ts
* const selectMenuOption = new SelectMenuOptionBuilder({
* label: 'catchy label',
@@ -543,48 +315,48 @@ declare class StringSelectMenuOptionBuilder implements JSONEncodable);
/**
- * Sets the label of this option
+ * Sets the label for this option.
*
- * @param label - The label to show on this option
+ * @param label - The label to use
*/
setLabel(label: string): this;
/**
- * Sets the value of this option
+ * Sets the value for this option.
*
- * @param value - The value of this option
+ * @param value - The value to use
*/
setValue(value: string): this;
/**
- * Sets the description of this option
+ * Sets the description for this option.
*
- * @param description - The description of this option
+ * @param description - The description to use
*/
setDescription(description: string): this;
/**
- * Sets whether this option is selected by default
+ * Sets whether this option is selected by default.
*
* @param isDefault - Whether this option is selected by default
*/
setDefault(isDefault?: boolean): this;
/**
- * Sets the emoji to display on this option
+ * Sets the emoji to display for this option.
*
- * @param emoji - The emoji to display on this option
+ * @param emoji - The emoji to use
*/
setEmoji(emoji: APIMessageComponentEmoji): this;
/**
- * {@inheritDoc ComponentBuilder.toJSON}
+ * {@inheritDoc BaseSelectMenuBuilder.toJSON}
*/
toJSON(): APISelectMenuOption;
}
@@ -636,78 +408,86 @@ declare const channelTypesValidator: _sapphire_shapeshift.ArrayValidator;
declare function validateRequiredButtonParameters(style?: ButtonStyle, label?: string, emoji?: APIMessageComponentEmoji, customId?: string, url?: string): void;
-declare const Assertions$4_customIdValidator: typeof customIdValidator;
-declare const Assertions$4_emojiValidator: typeof emojiValidator;
-declare const Assertions$4_disabledValidator: typeof disabledValidator;
declare const Assertions$4_buttonLabelValidator: typeof buttonLabelValidator;
declare const Assertions$4_buttonStyleValidator: typeof buttonStyleValidator;
-declare const Assertions$4_minMaxValidator: typeof minMaxValidator;
-declare const Assertions$4_labelValueDescriptionValidator: typeof labelValueDescriptionValidator;
-declare const Assertions$4_jsonOptionValidator: typeof jsonOptionValidator;
-declare const Assertions$4_optionValidator: typeof optionValidator;
-declare const Assertions$4_optionsValidator: typeof optionsValidator;
-declare const Assertions$4_optionsLengthValidator: typeof optionsLengthValidator;
-declare const Assertions$4_validateRequiredSelectMenuParameters: typeof validateRequiredSelectMenuParameters;
-declare const Assertions$4_defaultValidator: typeof defaultValidator;
-declare const Assertions$4_validateRequiredSelectMenuOptionParameters: typeof validateRequiredSelectMenuOptionParameters;
declare const Assertions$4_channelTypesValidator: typeof channelTypesValidator;
+declare const Assertions$4_customIdValidator: typeof customIdValidator;
+declare const Assertions$4_defaultValidator: typeof defaultValidator;
+declare const Assertions$4_disabledValidator: typeof disabledValidator;
+declare const Assertions$4_emojiValidator: typeof emojiValidator;
+declare const Assertions$4_jsonOptionValidator: typeof jsonOptionValidator;
+declare const Assertions$4_labelValueDescriptionValidator: typeof labelValueDescriptionValidator;
+declare const Assertions$4_minMaxValidator: typeof minMaxValidator;
+declare const Assertions$4_optionValidator: typeof optionValidator;
+declare const Assertions$4_optionsLengthValidator: typeof optionsLengthValidator;
+declare const Assertions$4_optionsValidator: typeof optionsValidator;
declare const Assertions$4_urlValidator: typeof urlValidator;
declare const Assertions$4_validateRequiredButtonParameters: typeof validateRequiredButtonParameters;
+declare const Assertions$4_validateRequiredSelectMenuOptionParameters: typeof validateRequiredSelectMenuOptionParameters;
+declare const Assertions$4_validateRequiredSelectMenuParameters: typeof validateRequiredSelectMenuParameters;
declare namespace Assertions$4 {
export {
- Assertions$4_customIdValidator as customIdValidator,
- Assertions$4_emojiValidator as emojiValidator,
- Assertions$4_disabledValidator as disabledValidator,
Assertions$4_buttonLabelValidator as buttonLabelValidator,
Assertions$4_buttonStyleValidator as buttonStyleValidator,
- placeholderValidator$1 as placeholderValidator,
- Assertions$4_minMaxValidator as minMaxValidator,
- Assertions$4_labelValueDescriptionValidator as labelValueDescriptionValidator,
- Assertions$4_jsonOptionValidator as jsonOptionValidator,
- Assertions$4_optionValidator as optionValidator,
- Assertions$4_optionsValidator as optionsValidator,
- Assertions$4_optionsLengthValidator as optionsLengthValidator,
- Assertions$4_validateRequiredSelectMenuParameters as validateRequiredSelectMenuParameters,
- Assertions$4_defaultValidator as defaultValidator,
- Assertions$4_validateRequiredSelectMenuOptionParameters as validateRequiredSelectMenuOptionParameters,
Assertions$4_channelTypesValidator as channelTypesValidator,
+ Assertions$4_customIdValidator as customIdValidator,
+ Assertions$4_defaultValidator as defaultValidator,
+ Assertions$4_disabledValidator as disabledValidator,
+ Assertions$4_emojiValidator as emojiValidator,
+ Assertions$4_jsonOptionValidator as jsonOptionValidator,
+ Assertions$4_labelValueDescriptionValidator as labelValueDescriptionValidator,
+ Assertions$4_minMaxValidator as minMaxValidator,
+ Assertions$4_optionValidator as optionValidator,
+ Assertions$4_optionsLengthValidator as optionsLengthValidator,
+ Assertions$4_optionsValidator as optionsValidator,
+ placeholderValidator$1 as placeholderValidator,
Assertions$4_urlValidator as urlValidator,
Assertions$4_validateRequiredButtonParameters as validateRequiredButtonParameters,
+ Assertions$4_validateRequiredSelectMenuOptionParameters as validateRequiredSelectMenuOptionParameters,
+ Assertions$4_validateRequiredSelectMenuParameters as validateRequiredSelectMenuParameters,
};
}
+/**
+ * Any action row component data represented as an object.
+ */
type AnyAPIActionRowComponent = APIActionRowComponent | APIActionRowComponentTypes;
/**
- * Represents a discord component
+ * The base component builder that contains common symbols for all sorts of components.
*
* @typeParam DataType - The type of internal API data that is stored within the component
*/
declare abstract class ComponentBuilder> = APIBaseComponent> implements JSONEncodable {
/**
- * The API data associated with this component
+ * The API data associated with this component.
*/
readonly data: Partial;
/**
- * Serializes this component to an API-compatible JSON object
+ * Serializes this builder to API-compatible JSON data.
*
* @remarks
* This method runs validations on the data before serializing it.
* As such, it may throw an error if the data is invalid.
*/
abstract toJSON(): AnyAPIActionRowComponent;
+ /**
+ * Constructs a new kind of component.
+ *
+ * @param data - The data to construct a component out of
+ */
constructor(data: Partial);
}
/**
- * Represents a button component
+ * A builder that creates API-compatible JSON data for buttons.
*/
declare class ButtonBuilder extends ComponentBuilder {
/**
- * Creates a new button from API data
+ * Creates a new button from API data.
*
* @param data - The API data to create this button with
* @example
- * Creating a button from an API data object
+ * Creating a button from an API data object:
* ```ts
* const button = new ButtonBuilder({
* custom_id: 'a cool button',
@@ -720,7 +500,7 @@ declare class ButtonBuilder extends ComponentBuilder {
* });
* ```
* @example
- * Creating a button using setters and API data
+ * Creating a button using setters and API data:
* ```ts
* const button = new ButtonBuilder({
* style: ButtonStyle.Secondary,
@@ -732,44 +512,44 @@ declare class ButtonBuilder extends ComponentBuilder {
*/
constructor(data?: Partial);
/**
- * Sets the style of this button
+ * Sets the style of this button.
*
- * @param style - The style of the button
+ * @param style - The style to use
*/
setStyle(style: ButtonStyle): this;
/**
- * Sets the URL for this button
+ * Sets the URL for this button.
*
* @remarks
* This method is only available to buttons using the `Link` button style.
- * Only three types of URL schemes are currently supported: `https://`, `http://` and `discord://`
- * @param url - The URL to open when this button is clicked
+ * Only three types of URL schemes are currently supported: `https://`, `http://`, and `discord://`.
+ * @param url - The URL to use
*/
setURL(url: string): this;
/**
- * Sets the custom id for this button
+ * Sets the custom id for this button.
*
* @remarks
* This method is only applicable to buttons that are not using the `Link` button style.
- * @param customId - The custom id to use for this button
+ * @param customId - The custom id to use
*/
setCustomId(customId: string): this;
/**
- * Sets the emoji to display on this button
+ * Sets the emoji to display on this button.
*
- * @param emoji - The emoji to display on this button
+ * @param emoji - The emoji to use
*/
setEmoji(emoji: APIMessageComponentEmoji): this;
/**
- * Sets whether this button is disabled
+ * Sets whether this button is disabled.
*
* @param disabled - Whether to disable this button
*/
setDisabled(disabled?: boolean): this;
/**
- * Sets the label for this button
+ * Sets the label for this button.
*
- * @param label - The label to display on this button
+ * @param label - The label to use
*/
setLabel(label: string): this;
/**
@@ -778,47 +558,58 @@ declare class ButtonBuilder extends ComponentBuilder {
toJSON(): APIButtonComponent;
}
-declare class BaseSelectMenuBuilder extends ComponentBuilder {
+/**
+ * The base select menu builder that contains common symbols for select menu builders.
+ *
+ * @typeParam SelectMenuType - The type of select menu this would be instantiated for.
+ */
+declare abstract class BaseSelectMenuBuilder extends ComponentBuilder {
/**
- * Sets the placeholder for this select menu
+ * Sets the placeholder for this select menu.
*
- * @param placeholder - The placeholder to use for this select menu
+ * @param placeholder - The placeholder to use
*/
setPlaceholder(placeholder: string): this;
/**
- * Sets the minimum values that must be selected in the select menu
+ * Sets the minimum values that must be selected in the select menu.
*
* @param minValues - The minimum values that must be selected
*/
setMinValues(minValues: number): this;
/**
- * Sets the maximum values that must be selected in the select menu
+ * Sets the maximum values that must be selected in the select menu.
*
* @param maxValues - The maximum values that must be selected
*/
setMaxValues(maxValues: number): this;
/**
- * Sets the custom id for this select menu
+ * Sets the custom id for this select menu.
*
- * @param customId - The custom id to use for this select menu
+ * @param customId - The custom id to use
*/
setCustomId(customId: string): this;
/**
- * Sets whether this select menu is disabled
+ * Sets whether this select menu is disabled.
*
* @param disabled - Whether this select menu is disabled
*/
setDisabled(disabled?: boolean): this;
+ /**
+ * {@inheritDoc ComponentBuilder.toJSON}
+ */
toJSON(): SelectMenuType;
}
+/**
+ * A builder that creates API-compatible JSON data for channel select menus.
+ */
declare class ChannelSelectMenuBuilder extends BaseSelectMenuBuilder {
/**
- * Creates a new select menu from API data
+ * Creates a new select menu from API data.
*
* @param data - The API data to create this select menu with
* @example
- * Creating a select menu from an API data object
+ * Creating a select menu from an API data object:
* ```ts
* const selectMenu = new ChannelSelectMenuBuilder({
* custom_id: 'a cool select menu',
@@ -827,31 +618,44 @@ declare class ChannelSelectMenuBuilder extends BaseSelectMenuBuilder);
+ /**
+ * Adds channel types to this select menu.
+ *
+ * @param types - The channel types to use
+ */
addChannelTypes(...types: RestOrArray): this;
+ /**
+ * Sets channel types for this select menu.
+ *
+ * @param types - The channel types to use
+ */
setChannelTypes(...types: RestOrArray): this;
/**
- * {@inheritDoc ComponentBuilder.toJSON}
+ * {@inheritDoc BaseSelectMenuBuilder.toJSON}
*/
toJSON(): APIChannelSelectComponent;
}
+/**
+ * A builder that creates API-compatible JSON data for mentionable select menus.
+ */
declare class MentionableSelectMenuBuilder extends BaseSelectMenuBuilder {
/**
- * Creates a new select menu from API data
+ * Creates a new select menu from API data.
*
* @param data - The API data to create this select menu with
* @example
- * Creating a select menu from an API data object
+ * Creating a select menu from an API data object:
* ```ts
* const selectMenu = new MentionableSelectMenuBuilder({
* custom_id: 'a cool select menu',
@@ -860,24 +664,27 @@ declare class MentionableSelectMenuBuilder extends BaseSelectMenuBuilder);
}
+/**
+ * A builder that creates API-compatible JSON data for role select menus.
+ */
declare class RoleSelectMenuBuilder extends BaseSelectMenuBuilder {
/**
- * Creates a new select menu from API data
+ * Creates a new select menu from API data.
*
* @param data - The API data to create this select menu with
* @example
- * Creating a select menu from an API data object
+ * Creating a select menu from an API data object:
* ```ts
* const selectMenu = new RoleSelectMenuBuilder({
* custom_id: 'a cool select menu',
@@ -886,31 +693,31 @@ declare class RoleSelectMenuBuilder extends BaseSelectMenuBuilder);
}
/**
- * Represents a string select menu component
+ * A builder that creates API-compatible JSON data for string select menus.
*/
declare class StringSelectMenuBuilder extends BaseSelectMenuBuilder {
/**
- * The options within this select menu
+ * The options within this select menu.
*/
readonly options: StringSelectMenuOptionBuilder[];
/**
- * Creates a new select menu from API data
+ * Creates a new select menu from API data.
*
* @param data - The API data to create this select menu with
* @example
- * Creating a select menu from an API data object
+ * Creating a select menu from an API data object:
* ```ts
* const selectMenu = new StringSelectMenuBuilder({
* custom_id: 'a cool select menu',
@@ -924,7 +731,7 @@ declare class StringSelectMenuBuilder extends BaseSelectMenuBuilder);
/**
- * Adds options to this select menu
+ * Adds options to this select menu.
*
- * @param options - The options to add to this select menu
- * @returns
+ * @param options - The options to add
*/
addOptions(...options: RestOrArray): this;
/**
- * Sets the options on this select menu
+ * Sets the options for this select menu.
*
- * @param options - The options to set on this select menu
+ * @param options - The options to set
*/
setOptions(...options: RestOrArray): this;
/**
- * {@inheritDoc ComponentBuilder.toJSON}
+ * Removes, replaces, or inserts options for this select menu.
+ *
+ * @remarks
+ * This method behaves similarly
+ * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice()}.
+ * It's useful for modifying and adjusting the order of existing options.
+ * @example
+ * Remove the first option:
+ * ```ts
+ * selectMenu.spliceOptions(0, 1);
+ * ```
+ * @example
+ * Remove the first n option:
+ * ```ts
+ * const n = 4;
+ * selectMenu.spliceOptions(0, n);
+ * ```
+ * @example
+ * Remove the last option:
+ * ```ts
+ * selectMenu.spliceOptions(-1, 1);
+ * ```
+ * @param index - The index to start at
+ * @param deleteCount - The number of options to remove
+ * @param options - The replacing option objects or builders
+ */
+ spliceOptions(index: number, deleteCount: number, ...options: RestOrArray): this;
+ /**
+ * {@inheritDoc BaseSelectMenuBuilder.toJSON}
*/
toJSON(): APIStringSelectComponent;
}
+/**
+ * A builder that creates API-compatible JSON data for user select menus.
+ */
declare class UserSelectMenuBuilder extends BaseSelectMenuBuilder {
/**
- * Creates a new select menu from API data
+ * Creates a new select menu from API data.
*
* @param data - The API data to create this select menu with
* @example
- * Creating a select menu from an API data object
+ * Creating a select menu from an API data object:
* ```ts
* const selectMenu = new UserSelectMenuBuilder({
* custom_id: 'a cool select menu',
@@ -971,24 +808,27 @@ declare class UserSelectMenuBuilder extends BaseSelectMenuBuilder);
}
+/**
+ * A builder that creates API-compatible JSON data for text inputs.
+ */
declare class TextInputBuilder extends ComponentBuilder implements Equatable> {
/**
- * Creates a new text input from API data
+ * Creates a new text input from API data.
*
* @param data - The API data to create this text input with
* @example
- * Creating a select menu option from an API data object
+ * Creating a select menu option from an API data object:
* ```ts
* const textInput = new TextInputBuilder({
* custom_id: 'a cool select menu',
@@ -997,7 +837,7 @@ declare class TextInputBuilder extends ComponentBuilder i
* });
* ```
* @example
- * Creating a select menu option using setters and API data
+ * Creating a select menu option using setters and API data:
* ```ts
* const textInput = new TextInputBuilder({
* label: 'Type something else',
@@ -1010,49 +850,49 @@ declare class TextInputBuilder extends ComponentBuilder i
type?: ComponentType.TextInput;
});
/**
- * Sets the custom id for this text input
+ * Sets the custom id for this text input.
*
- * @param customId - The custom id of this text input
+ * @param customId - The custom id to use
*/
setCustomId(customId: string): this;
/**
- * Sets the label for this text input
+ * Sets the label for this text input.
*
- * @param label - The label for this text input
+ * @param label - The label to use
*/
setLabel(label: string): this;
/**
- * Sets the style for this text input
+ * Sets the style for this text input.
*
- * @param style - The style for this text input
+ * @param style - The style to use
*/
setStyle(style: TextInputStyle): this;
/**
- * Sets the minimum length of text for this text input
+ * Sets the minimum length of text for this text input.
*
* @param minLength - The minimum length of text for this text input
*/
setMinLength(minLength: number): this;
/**
- * Sets the maximum length of text for this text input
+ * Sets the maximum length of text for this text input.
*
* @param maxLength - The maximum length of text for this text input
*/
setMaxLength(maxLength: number): this;
/**
- * Sets the placeholder of this text input
+ * Sets the placeholder for this text input.
*
- * @param placeholder - The placeholder of this text input
+ * @param placeholder - The placeholder to use
*/
setPlaceholder(placeholder: string): this;
/**
- * Sets the value of this text input
+ * Sets the value for this text input.
*
- * @param value - The value for this text input
+ * @param value - The value to use
*/
setValue(value: string): this;
/**
- * Sets whether this text input is required
+ * Sets whether this text input is required.
*
* @param required - Whether this text input is required
*/
@@ -1067,27 +907,42 @@ declare class TextInputBuilder extends ComponentBuilder i
equals(other: APITextInputComponent | JSONEncodable): boolean;
}
+/**
+ * The builders that may be used for messages.
+ */
type MessageComponentBuilder = ActionRowBuilder | MessageActionRowComponentBuilder;
+/**
+ * The builders that may be used for modals.
+ */
type ModalComponentBuilder = ActionRowBuilder | ModalActionRowComponentBuilder;
+/**
+ * The builders that may be used within an action row for messages.
+ */
type MessageActionRowComponentBuilder = ButtonBuilder | ChannelSelectMenuBuilder | MentionableSelectMenuBuilder | RoleSelectMenuBuilder | StringSelectMenuBuilder | UserSelectMenuBuilder;
+/**
+ * The builders that may be used within an action row for modals.
+ */
type ModalActionRowComponentBuilder = TextInputBuilder;
+/**
+ * Any builder.
+ */
type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder;
/**
- * Represents an action row component
+ * A builder that creates API-compatible JSON data for action rows.
*
* @typeParam T - The types of components this action row holds
*/
declare class ActionRowBuilder extends ComponentBuilder> {
/**
- * The components within this action row
+ * The components within this action row.
*/
readonly components: T[];
/**
- * Creates a new action row from API data
+ * Creates a new action row from API data.
*
* @param data - The API data to create this action row with
* @example
- * Creating an action row from an API data object
+ * Creating an action row from an API data object:
* ```ts
* const actionRow = new ActionRowBuilder({
* components: [
@@ -1101,7 +956,7 @@ declare class ActionRowBuilder extends ComponentB
* });
* ```
* @example
- * Creating an action row using setters and API data
+ * Creating an action row using setters and API data:
* ```ts
* const actionRow = new ActionRowBuilder({
* components: [
@@ -1120,13 +975,13 @@ declare class ActionRowBuilder extends ComponentB
/**
* Adds components to this action row.
*
- * @param components - The components to add to this action row.
+ * @param components - The components to add
*/
addComponents(...components: RestOrArray): this;
/**
- * Sets the components in this action row
+ * Sets components for this action row.
*
- * @param components - The components to set this row to
+ * @param components - The components to set
*/
setComponents(...components: RestOrArray): this;
/**
@@ -1135,24 +990,58 @@ declare class ActionRowBuilder extends ComponentB
toJSON(): APIActionRowComponent>;
}
+/**
+ * Components here are mapped to their respective builder.
+ */
interface MappedComponentTypes {
+ /**
+ * The action row component type is associated with an {@link ActionRowBuilder}.
+ */
[ComponentType.ActionRow]: ActionRowBuilder;
+ /**
+ * The button component type is associated with an {@link ButtonBuilder}.
+ */
[ComponentType.Button]: ButtonBuilder;
+ /**
+ * The string select component type is associated with an {@link StringSelectMenuBuilder}.
+ */
[ComponentType.StringSelect]: StringSelectMenuBuilder;
+ /**
+ * The text inpiut component type is associated with an {@link TextInputBuilder}.
+ */
[ComponentType.TextInput]: TextInputBuilder;
+ /**
+ * The user select component type is associated with an {@link UserSelectMenuBuilder}.
+ */
[ComponentType.UserSelect]: UserSelectMenuBuilder;
+ /**
+ * The role select component type is associated with an {@link RoleSelectMenuBuilder}.
+ */
[ComponentType.RoleSelect]: RoleSelectMenuBuilder;
+ /**
+ * The mentionable select component type is associated with an {@link MentionableSelectMenuBuilder}.
+ */
[ComponentType.MentionableSelect]: MentionableSelectMenuBuilder;
+ /**
+ * The channel select component type is associated with an {@link ChannelSelectMenuBuilder}.
+ */
[ComponentType.ChannelSelect]: ChannelSelectMenuBuilder;
}
/**
- * Factory for creating components from API data
+ * Factory for creating components from API data.
*
- * @param data - The api data to transform to a component class
+ * @typeParam T - The type of component to use
+ * @param data - The API data to transform to a component class
*/
declare function createComponentBuilder(data: (APIModalComponent | APIMessageComponent) & {
type: T;
}): MappedComponentTypes[T];
+/**
+ * Factory for creating components from API data.
+ *
+ * @typeParam C - The type of component to use
+ * @param data - The API data to transform to a component class
+ */
declare function createComponentBuilder(data: C): C;
declare const textInputStyleValidator: _sapphire_shapeshift.NativeEnumValidator;
@@ -1164,52 +1053,66 @@ declare const placeholderValidator: _sapphire_shapeshift.StringValidator
declare const labelValidator: _sapphire_shapeshift.StringValidator;
declare function validateRequiredParameters$3(customId?: string, style?: TextInputStyle, label?: string): void;
-declare const Assertions$3_textInputStyleValidator: typeof textInputStyleValidator;
-declare const Assertions$3_minLengthValidator: typeof minLengthValidator;
-declare const Assertions$3_maxLengthValidator: typeof maxLengthValidator;
-declare const Assertions$3_requiredValidator: typeof requiredValidator;
-declare const Assertions$3_valueValidator: typeof valueValidator;
-declare const Assertions$3_placeholderValidator: typeof placeholderValidator;
declare const Assertions$3_labelValidator: typeof labelValidator;
+declare const Assertions$3_maxLengthValidator: typeof maxLengthValidator;
+declare const Assertions$3_minLengthValidator: typeof minLengthValidator;
+declare const Assertions$3_placeholderValidator: typeof placeholderValidator;
+declare const Assertions$3_requiredValidator: typeof requiredValidator;
+declare const Assertions$3_textInputStyleValidator: typeof textInputStyleValidator;
+declare const Assertions$3_valueValidator: typeof valueValidator;
declare namespace Assertions$3 {
export {
- Assertions$3_textInputStyleValidator as textInputStyleValidator,
- Assertions$3_minLengthValidator as minLengthValidator,
- Assertions$3_maxLengthValidator as maxLengthValidator,
- Assertions$3_requiredValidator as requiredValidator,
- Assertions$3_valueValidator as valueValidator,
- Assertions$3_placeholderValidator as placeholderValidator,
Assertions$3_labelValidator as labelValidator,
+ Assertions$3_maxLengthValidator as maxLengthValidator,
+ Assertions$3_minLengthValidator as minLengthValidator,
+ Assertions$3_placeholderValidator as placeholderValidator,
+ Assertions$3_requiredValidator as requiredValidator,
+ Assertions$3_textInputStyleValidator as textInputStyleValidator,
validateRequiredParameters$3 as validateRequiredParameters,
+ Assertions$3_valueValidator as valueValidator,
};
}
+/**
+ * A builder that creates API-compatible JSON data for modals.
+ */
declare class ModalBuilder implements JSONEncodable {
+ /**
+ * The API data associated with this modal.
+ */
readonly data: Partial;
+ /**
+ * The components within this modal.
+ */
readonly components: ActionRowBuilder[];
+ /**
+ * Creates a new modal from API data.
+ *
+ * @param data - The API data to create this modal with
+ */
constructor({ components, ...data }?: Partial);
/**
- * Sets the title of the modal
+ * Sets the title of this modal.
*
- * @param title - The title of the modal
+ * @param title - The title to use
*/
setTitle(title: string): this;
/**
- * Sets the custom id of the modal
+ * Sets the custom id of this modal.
*
- * @param customId - The custom id of this modal
+ * @param customId - The custom id to use
*/
setCustomId(customId: string): this;
/**
- * Adds components to this modal
+ * Adds components to this modal.
*
- * @param components - The components to add to this modal
+ * @param components - The components to add
*/
addComponents(...components: RestOrArray | APIActionRowComponent>): this;
/**
- * Sets the components in this modal
+ * Sets components for this modal.
*
- * @param components - The components to set this modal to
+ * @param components - The components to set
*/
setComponents(...components: RestOrArray>): this;
/**
@@ -1222,140 +1125,252 @@ declare const titleValidator: _sapphire_shapeshift.StringValidator;
declare const componentsValidator: _sapphire_shapeshift.ArrayValidator<[ActionRowBuilder, ...ActionRowBuilder[]], ActionRowBuilder>;
declare function validateRequiredParameters$2(customId?: string, title?: string, components?: ActionRowBuilder[]): void;
-declare const Assertions$2_titleValidator: typeof titleValidator;
declare const Assertions$2_componentsValidator: typeof componentsValidator;
+declare const Assertions$2_titleValidator: typeof titleValidator;
declare namespace Assertions$2 {
export {
- Assertions$2_titleValidator as titleValidator,
Assertions$2_componentsValidator as componentsValidator,
+ Assertions$2_titleValidator as titleValidator,
validateRequiredParameters$2 as validateRequiredParameters,
};
}
+/**
+ * This mixin holds name and description symbols for slash commands.
+ */
declare class SharedNameAndDescription {
+ /**
+ * The name of this command.
+ */
readonly name: string;
+ /**
+ * The name localizations of this command.
+ */
readonly name_localizations?: LocalizationMap;
+ /**
+ * The description of this command.
+ */
readonly description: string;
+ /**
+ * The description localizations of this command.
+ */
readonly description_localizations?: LocalizationMap;
/**
- * Sets the name
+ * Sets the name of this command.
*
- * @param name - The name
+ * @param name - The name to use
*/
setName(name: string): this;
/**
- * Sets the description
+ * Sets the description of this command.
*
- * @param description - The description
+ * @param description - The description to use
*/
setDescription(description: string): this;
/**
- * Sets a name localization
+ * SSets a name localization for this command.
*
- * @param locale - The locale to set a description for
- * @param localizedName - The localized description for the given locale
+ * @param locale - The locale to set
+ * @param localizedName - The localized name for the given `locale`
*/
setNameLocalization(locale: LocaleString, localizedName: string | null): this;
/**
- * Sets the name localizations
+ * Sets the name localizations for this command.
*
- * @param localizedNames - The dictionary of localized descriptions to set
+ * @param localizedNames - The object of localized names to set
*/
setNameLocalizations(localizedNames: LocalizationMap | null): this;
/**
- * Sets a description localization
+ * Sets a description localization for this command.
*
- * @param locale - The locale to set a description for
+ * @param locale - The locale to set
* @param localizedDescription - The localized description for the given locale
*/
setDescriptionLocalization(locale: LocaleString, localizedDescription: string | null): this;
/**
- * Sets the description localizations
+ * Sets the description localizations for this command.
*
- * @param localizedDescriptions - The dictionary of localized descriptions to set
+ * @param localizedDescriptions - The object of localized descriptions to set
*/
setDescriptionLocalizations(localizedDescriptions: LocalizationMap | null): this;
}
+/**
+ * The base application command option builder that contains common symbols for application command builders.
+ */
declare abstract class ApplicationCommandOptionBase extends SharedNameAndDescription {
+ /**
+ * The type of this option.
+ */
abstract readonly type: ApplicationCommandOptionType;
+ /**
+ * Whether this option is required.
+ *
+ * @defaultValue `false`
+ */
readonly required: boolean;
/**
- * Marks the option as required
+ * Sets whether this option is required.
*
- * @param required - If this option should be required
+ * @param required - Whether this option should be required
*/
setRequired(required: boolean): this;
+ /**
+ * Serializes this builder to API-compatible JSON data.
+ *
+ * @remarks
+ * This method runs validations on the data before serializing it.
+ * As such, it may throw an error if the data is invalid.
+ */
abstract toJSON(): APIApplicationCommandBasicOption;
+ /**
+ * This method runs required validators on this builder.
+ */
protected runRequiredValidations(): void;
}
+/**
+ * A slash command attachment option.
+ */
declare class SlashCommandAttachmentOption extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
readonly type: ApplicationCommandOptionType.Attachment;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON(): APIApplicationCommandAttachmentOption;
}
+/**
+ * A slash command boolean option.
+ */
declare class SlashCommandBooleanOption extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
readonly type: ApplicationCommandOptionType.Boolean;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON(): APIApplicationCommandBooleanOption;
}
+/**
+ * The allowed channel types used for a channel option in a slash command builder.
+ *
+ * @privateRemarks This can't be dynamic because const enums are erased at runtime.
+ * @internal
+ */
declare const allowedChannelTypes: readonly [ChannelType.GuildText, ChannelType.GuildVoice, ChannelType.GuildCategory, ChannelType.GuildAnnouncement, ChannelType.AnnouncementThread, ChannelType.PublicThread, ChannelType.PrivateThread, ChannelType.GuildStageVoice, ChannelType.GuildForum];
-type ApplicationCommandOptionAllowedChannelTypes = typeof allowedChannelTypes[number];
+/**
+ * The type of allowed channel types used for a channel option.
+ */
+type ApplicationCommandOptionAllowedChannelTypes = (typeof allowedChannelTypes)[number];
+/**
+ * This mixin holds channel type symbols used for options.
+ */
declare class ApplicationCommandOptionChannelTypesMixin {
+ /**
+ * The channel types of this option.
+ */
readonly channel_types?: ApplicationCommandOptionAllowedChannelTypes[];
/**
- * Adds channel types to this option
+ * Adds channel types to this option.
*
- * @param channelTypes - The channel types to add
+ * @param channelTypes - The channel types
*/
addChannelTypes(...channelTypes: ApplicationCommandOptionAllowedChannelTypes[]): this;
}
+/**
+ * A slash command channel option.
+ */
declare class SlashCommandChannelOption extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
readonly type: ApplicationCommandOptionType.Channel;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON(): APIApplicationCommandChannelOption;
}
interface SlashCommandChannelOption extends ApplicationCommandOptionChannelTypesMixin {
}
+/**
+ * This mixin holds minimum and maximum symbols used for options.
+ */
declare abstract class ApplicationCommandNumericOptionMinMaxValueMixin {
+ /**
+ * The maximum value of this option.
+ */
readonly max_value?: number;
+ /**
+ * The minimum value of this option.
+ */
readonly min_value?: number;
/**
- * Sets the maximum number value of this option
+ * Sets the maximum number value of this option.
*
* @param max - The maximum value this option can be
*/
abstract setMaxValue(max: number): this;
/**
- * Sets the minimum number value of this option
+ * Sets the minimum number value of this option.
*
* @param min - The minimum value this option can be
*/
abstract setMinValue(min: number): this;
}
+/**
+ * This mixin holds choices and autocomplete symbols used for options.
+ */
declare class ApplicationCommandOptionWithChoicesAndAutocompleteMixin {
+ /**
+ * The choices of this option.
+ */
readonly choices?: APIApplicationCommandOptionChoice[];
+ /**
+ * Whether this option utilizes autocomplete.
+ */
readonly autocomplete?: boolean;
+ /**
+ * The type of this option.
+ *
+ * @privateRemarks Since this is present and this is a mixin, this is needed.
+ */
readonly type: ApplicationCommandOptionType;
/**
- * Adds multiple choices for this option
+ * Adds multiple choices to this option.
*
* @param choices - The choices to add
*/
addChoices(...choices: APIApplicationCommandOptionChoice[]): this;
+ /**
+ * Sets multiple choices for this option.
+ *
+ * @param choices - The choices to set
+ */
setChoices[]>(...choices: Input): this;
/**
- * Marks the option as autocompletable
+ * Whether this option uses autocomplete.
*
- * @param autocomplete - If this option should be autocompletable
+ * @param autocomplete - Whether this option should use autocomplete
*/
setAutocomplete(autocomplete: boolean): this;
}
+/**
+ * A slash command integer option.
+ */
declare class SlashCommandIntegerOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
+ /**
+ * The type of this option.
+ */
readonly type: ApplicationCommandOptionType.Integer;
/**
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
@@ -1365,17 +1380,35 @@ declare class SlashCommandIntegerOption extends ApplicationCommandOptionBase imp
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
*/
setMinValue(min: number): this;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON(): APIApplicationCommandIntegerOption;
}
interface SlashCommandIntegerOption extends ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin {
}
+/**
+ * A slash command mentionable option.
+ */
declare class SlashCommandMentionableOption extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
readonly type: ApplicationCommandOptionType.Mentionable;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON(): APIApplicationCommandMentionableOption;
}
+/**
+ * A slash command number option.
+ */
declare class SlashCommandNumberOption extends ApplicationCommandOptionBase implements ApplicationCommandNumericOptionMinMaxValueMixin {
+ /**
+ * The type of this option.
+ */
readonly type: ApplicationCommandOptionType.Number;
/**
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
@@ -1385,19 +1418,43 @@ declare class SlashCommandNumberOption extends ApplicationCommandOptionBase impl
* {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
*/
setMinValue(min: number): this;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON(): APIApplicationCommandNumberOption;
}
interface SlashCommandNumberOption extends ApplicationCommandNumericOptionMinMaxValueMixin, ApplicationCommandOptionWithChoicesAndAutocompleteMixin {
}
+/**
+ * A slash command role option.
+ */
declare class SlashCommandRoleOption extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
readonly type: ApplicationCommandOptionType.Role;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON(): APIApplicationCommandRoleOption;
}
+/**
+ * A slash command string option.
+ */
declare class SlashCommandStringOption extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
readonly type: ApplicationCommandOptionType.String;
+ /**
+ * The maximum length of this option.
+ */
readonly max_length?: number;
+ /**
+ * The minimum length of this option.
+ */
readonly min_length?: number;
/**
* Sets the maximum length of this string option.
@@ -1411,179 +1468,217 @@ declare class SlashCommandStringOption extends ApplicationCommandOptionBase {
* @param min - The minimum length this option can be
*/
setMinLength(min: number): this;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON(): APIApplicationCommandStringOption;
}
interface SlashCommandStringOption extends ApplicationCommandOptionWithChoicesAndAutocompleteMixin {
}
+/**
+ * A slash command user option.
+ */
declare class SlashCommandUserOption extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
readonly type: ApplicationCommandOptionType.User;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON(): APIApplicationCommandUserOption;
}
+/**
+ * This mixin holds symbols that can be shared in slash command options.
+ *
+ * @typeParam ShouldOmitSubcommandFunctions - Whether to omit subcommand functions.
+ */
declare class SharedSlashCommandOptions {
readonly options: ToAPIApplicationCommandOptions[];
/**
- * Adds a boolean option
+ * Adds a boolean option.
*
- * @param input - A function that returns an option builder, or an already built builder
+ * @param input - A function that returns an option builder or an already built builder
*/
addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): ShouldOmitSubcommandFunctions extends true ? Omit : this;
/**
- * Adds a user option
+ * Adds a user option.
*
- * @param input - A function that returns an option builder, or an already built builder
+ * @param input - A function that returns an option builder or an already built builder
*/
addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): ShouldOmitSubcommandFunctions extends true ? Omit : this;
/**
- * Adds a channel option
+ * Adds a channel option.
*
- * @param input - A function that returns an option builder, or an already built builder
+ * @param input - A function that returns an option builder or an already built builder
*/
addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): ShouldOmitSubcommandFunctions extends true ? Omit : this;
/**
- * Adds a role option
+ * Adds a role option.
*
- * @param input - A function that returns an option builder, or an already built builder
+ * @param input - A function that returns an option builder or an already built builder
*/
addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): ShouldOmitSubcommandFunctions extends true ? Omit : this;
/**
- * Adds an attachment option
+ * Adds an attachment option.
*
- * @param input - A function that returns an option builder, or an already built builder
+ * @param input - A function that returns an option builder or an already built builder
*/
addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): ShouldOmitSubcommandFunctions extends true ? Omit : this;
/**
- * Adds a mentionable option
+ * Adds a mentionable option.
*
- * @param input - A function that returns an option builder, or an already built builder
+ * @param input - A function that returns an option builder or an already built builder
*/
addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): ShouldOmitSubcommandFunctions extends true ? Omit : this;
/**
- * Adds a string option
+ * Adds a string option.
*
- * @param input - A function that returns an option builder, or an already built builder
+ * @param input - A function that returns an option builder or an already built builder
*/
addStringOption(input: Omit | Omit | SlashCommandStringOption | ((builder: SlashCommandStringOption) => Omit | Omit | SlashCommandStringOption)): ShouldOmitSubcommandFunctions extends true ? Omit : this;
/**
- * Adds an integer option
+ * Adds an integer option.
*
- * @param input - A function that returns an option builder, or an already built builder
+ * @param input - A function that returns an option builder or an already built builder
*/
addIntegerOption(input: Omit | Omit | SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => Omit | Omit | SlashCommandIntegerOption)): ShouldOmitSubcommandFunctions extends true ? Omit : this;
/**
- * Adds a number option
+ * Adds a number option.
*
- * @param input - A function that returns an option builder, or an already built builder
+ * @param input - A function that returns an option builder or an already built builder
*/
addNumberOption(input: Omit | Omit | SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => Omit | Omit | SlashCommandNumberOption)): ShouldOmitSubcommandFunctions extends true ? Omit : this;
+ /**
+ * Where the actual adding magic happens. ✨
+ *
+ * @param input - The input. What else?
+ * @param Instance - The instance of whatever is being added
+ * @internal
+ */
private _sharedAddOptionMethod;
}
/**
- * Represents a folder for subcommands
+ * Represents a folder for subcommands.
*
- * For more information, go to https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups}
*/
declare class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationCommandOptions {
/**
- * The name of this subcommand group
+ * The name of this subcommand group.
*/
readonly name: string;
/**
- * The description of this subcommand group
+ * The description of this subcommand group.
*/
readonly description: string;
/**
- * The subcommands part of this subcommand group
+ * The subcommands within this subcommand group.
*/
readonly options: SlashCommandSubcommandBuilder[];
/**
- * Adds a new subcommand to this group
+ * Adds a new subcommand to this group.
*
- * @param input - A function that returns a subcommand builder, or an already built builder
+ * @param input - A function that returns a subcommand builder or an already built builder
*/
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): this;
- toJSON(): APIApplicationCommandSubcommandGroupOption;
-}
-interface SlashCommandSubcommandGroupBuilder extends SharedNameAndDescription {
-}
-/**
- * Represents a subcommand
- *
- * For more information, go to https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups
- */
-declare class SlashCommandSubcommandBuilder implements ToAPIApplicationCommandOptions {
/**
- * The name of this subcommand
- */
- readonly name: string;
- /**
- * The description of this subcommand
- */
- readonly description: string;
- /**
- * The options of this subcommand
- */
- readonly options: ApplicationCommandOptionBase[];
- toJSON(): APIApplicationCommandSubcommandOption;
-}
-interface SlashCommandSubcommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {
-}
-
-declare class SlashCommandBuilder {
- /**
- * The name of this slash command
- */
- readonly name: string;
- /**
- * The localized names for this command
- */
- readonly name_localizations?: LocalizationMap;
- /**
- * The description of this slash command
- */
- readonly description: string;
- /**
- * The localized descriptions for this command
- */
- readonly description_localizations?: LocalizationMap;
- /**
- * The options of this slash command
- */
- readonly options: ToAPIApplicationCommandOptions[];
- /**
- * Whether the command is enabled by default when the app is added to a guild
- *
- * @deprecated This property is deprecated and will be removed in the future.
- * You should use {@link (SlashCommandBuilder:class).setDefaultMemberPermissions} or {@link (SlashCommandBuilder:class).setDMPermission} instead.
- */
- readonly default_permission: boolean | undefined;
- /**
- * Set of permissions represented as a bit set for the command
- */
- readonly default_member_permissions: Permissions | null | undefined;
- /**
- * Indicates whether the command is available in DMs with the application, only for globally-scoped commands.
- * By default, commands are visible.
- */
- readonly dm_permission: boolean | undefined;
- /**
- * Returns the final data that should be sent to Discord.
+ * Serializes this builder to API-compatible JSON data.
*
* @remarks
* This method runs validations on the data before serializing it.
* As such, it may throw an error if the data is invalid.
*/
- toJSON(): RESTPostAPIChatInputApplicationCommandsJSONBody;
+ toJSON(): APIApplicationCommandSubcommandGroupOption;
+}
+interface SlashCommandSubcommandGroupBuilder extends SharedNameAndDescription {
+}
+/**
+ * A builder that creates API-compatible JSON data for slash command subcommands.
+ *
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#subcommands-and-subcommand-groups}
+ */
+declare class SlashCommandSubcommandBuilder implements ToAPIApplicationCommandOptions {
+ /**
+ * The name of this subcommand.
+ */
+ readonly name: string;
+ /**
+ * The description of this subcommand.
+ */
+ readonly description: string;
+ /**
+ * The options within this subcommand.
+ */
+ readonly options: ApplicationCommandOptionBase[];
+ /**
+ * Serializes this builder to API-compatible JSON data.
+ *
+ * @remarks
+ * This method runs validations on the data before serializing it.
+ * As such, it may throw an error if the data is invalid.
+ */
+ toJSON(): APIApplicationCommandSubcommandOption;
+}
+interface SlashCommandSubcommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {
+}
+
+/**
+ * A builder that creates API-compatible JSON data for slash commands.
+ */
+declare class SlashCommandBuilder {
+ /**
+ * The name of this command.
+ */
+ readonly name: string;
+ /**
+ * The name localizations of this command.
+ */
+ readonly name_localizations?: LocalizationMap;
+ /**
+ * The description of this command.
+ */
+ readonly description: string;
+ /**
+ * The description localizations of this command.
+ */
+ readonly description_localizations?: LocalizationMap;
+ /**
+ * The options of this command.
+ */
+ readonly options: ToAPIApplicationCommandOptions[];
+ /**
+ * Whether this command is enabled by default when the application is added to a guild.
+ *
+ * @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
+ */
+ readonly default_permission: boolean | undefined;
+ /**
+ * The set of permissions represented as a bit set for the command.
+ */
+ readonly default_member_permissions: Permissions | null | undefined;
+ /**
+ * Indicates whether the command is available in direct messages with the application.
+ *
+ * @remarks
+ * By default, commands are visible. This property is only for global commands.
+ */
+ readonly dm_permission: boolean | undefined;
+ /**
+ * Whether this command is NSFW.
+ */
+ readonly nsfw: boolean | undefined;
/**
* Sets whether the command is enabled by default when the application is added to a guild.
*
* @remarks
* If set to `false`, you will have to later `PUT` the permissions for this command.
* @param value - Whether or not to enable this command by default
- * @see https://discord.com/developers/docs/interactions/application-commands#permissions
- * @deprecated Use {@link (SlashCommandBuilder:class).setDefaultMemberPermissions} or {@link (SlashCommandBuilder:class).setDMPermission} instead.
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ * @deprecated Use {@link SlashCommandBuilder.setDefaultMemberPermissions} or {@link SlashCommandBuilder.setDMPermission} instead.
*/
setDefaultPermission(value: boolean): this;
/**
@@ -1592,36 +1687,61 @@ declare class SlashCommandBuilder {
* @remarks
* You can set this to `'0'` to disable the command by default.
* @param permissions - The permissions bit field to set
- * @see https://discord.com/developers/docs/interactions/application-commands#permissions
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
*/
setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined): this;
/**
- * Sets if the command is available in DMs with the application, only for globally-scoped commands.
- * By default, commands are visible.
+ * Sets if the command is available in direct messages with the application.
*
- * @param enabled - If the command should be enabled in DMs
- * @see https://discord.com/developers/docs/interactions/application-commands#permissions
+ * @remarks
+ * By default, commands are visible. This method is only for global commands.
+ * @param enabled - Whether the command should be enabled in direct messages
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
*/
setDMPermission(enabled: boolean | null | undefined): this;
/**
- * Adds a new subcommand group to this command
+ * Sets whether this command is NSFW.
*
- * @param input - A function that returns a subcommand group builder, or an already built builder
+ * @param nsfw - Whether this command is NSFW
+ */
+ setNSFW(nsfw?: boolean): this;
+ /**
+ * Adds a new subcommand group to this command.
+ *
+ * @param input - A function that returns a subcommand group builder or an already built builder
*/
addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): SlashCommandSubcommandsOnlyBuilder;
/**
- * Adds a new subcommand to this command
+ * Adds a new subcommand to this command.
*
- * @param input - A function that returns a subcommand builder, or an already built builder
+ * @param input - A function that returns a subcommand builder or an already built builder
*/
addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): SlashCommandSubcommandsOnlyBuilder;
+ /**
+ * Serializes this builder to API-compatible JSON data.
+ *
+ * @remarks
+ * This method runs validations on the data before serializing it.
+ * As such, it may throw an error if the data is invalid.
+ */
+ toJSON(): RESTPostAPIChatInputApplicationCommandsJSONBody;
}
interface SlashCommandBuilder extends SharedNameAndDescription, SharedSlashCommandOptions {
}
+/**
+ * An interface specifically for slash command subcommands.
+ */
interface SlashCommandSubcommandsOnlyBuilder extends Omit> {
}
+/**
+ * An interface specifically for slash command options.
+ */
interface SlashCommandOptionsOnlyBuilder extends SharedNameAndDescription, SharedSlashCommandOptions, Pick {
}
+/**
+ * An interface that ensures the `toJSON()` call will return something
+ * that can be serialized into API-compatible data.
+ */
interface ToAPIApplicationCommandOptions {
toJSON(): APIApplicationCommandOption;
}
@@ -1635,76 +1755,87 @@ declare function validateDefaultPermission$1(value: unknown): asserts value is b
declare function validateRequired(required: unknown): asserts required is boolean;
declare function validateChoicesLength(amountAdding: number, choices?: APIApplicationCommandOptionChoice[]): void;
declare function assertReturnOfBuilder(input: unknown, ExpectedInstanceOf: new () => T): asserts input is T;
-declare const localizationMapPredicate: _sapphire_shapeshift.UnionValidator<_sapphire_shapeshift.UndefinedToOptional>> | null | undefined>;
+declare const localizationMapPredicate: _sapphire_shapeshift.UnionValidator<_sapphire_shapeshift.UndefinedToOptional>> | null | undefined>;
declare function validateLocalizationMap(value: unknown): asserts value is LocalizationMap;
declare function validateDMPermission$1(value: unknown): asserts value is boolean | null | undefined;
declare function validateDefaultMemberPermissions$1(permissions: unknown): string | null | undefined;
+declare function validateNSFW(value: unknown): asserts value is boolean;
-declare const Assertions$1_validateDescription: typeof validateDescription;
-declare const Assertions$1_validateLocale: typeof validateLocale;
-declare const Assertions$1_validateMaxOptionsLength: typeof validateMaxOptionsLength;
-declare const Assertions$1_validateRequired: typeof validateRequired;
-declare const Assertions$1_validateChoicesLength: typeof validateChoicesLength;
declare const Assertions$1_assertReturnOfBuilder: typeof assertReturnOfBuilder;
declare const Assertions$1_localizationMapPredicate: typeof localizationMapPredicate;
+declare const Assertions$1_validateChoicesLength: typeof validateChoicesLength;
+declare const Assertions$1_validateDescription: typeof validateDescription;
+declare const Assertions$1_validateLocale: typeof validateLocale;
declare const Assertions$1_validateLocalizationMap: typeof validateLocalizationMap;
+declare const Assertions$1_validateMaxOptionsLength: typeof validateMaxOptionsLength;
+declare const Assertions$1_validateNSFW: typeof validateNSFW;
+declare const Assertions$1_validateRequired: typeof validateRequired;
declare namespace Assertions$1 {
export {
- validateName$1 as validateName,
- Assertions$1_validateDescription as validateDescription,
- Assertions$1_validateLocale as validateLocale,
- Assertions$1_validateMaxOptionsLength as validateMaxOptionsLength,
- validateRequiredParameters$1 as validateRequiredParameters,
- validateDefaultPermission$1 as validateDefaultPermission,
- Assertions$1_validateRequired as validateRequired,
- Assertions$1_validateChoicesLength as validateChoicesLength,
Assertions$1_assertReturnOfBuilder as assertReturnOfBuilder,
Assertions$1_localizationMapPredicate as localizationMapPredicate,
- Assertions$1_validateLocalizationMap as validateLocalizationMap,
+ Assertions$1_validateChoicesLength as validateChoicesLength,
validateDMPermission$1 as validateDMPermission,
validateDefaultMemberPermissions$1 as validateDefaultMemberPermissions,
+ validateDefaultPermission$1 as validateDefaultPermission,
+ Assertions$1_validateDescription as validateDescription,
+ Assertions$1_validateLocale as validateLocale,
+ Assertions$1_validateLocalizationMap as validateLocalizationMap,
+ Assertions$1_validateMaxOptionsLength as validateMaxOptionsLength,
+ Assertions$1_validateNSFW as validateNSFW,
+ validateName$1 as validateName,
+ Assertions$1_validateRequired as validateRequired,
+ validateRequiredParameters$1 as validateRequiredParameters,
};
}
+/**
+ * The type a context menu command can be.
+ */
+type ContextMenuCommandType = ApplicationCommandType.Message | ApplicationCommandType.User;
+/**
+ * A builder that creates API-compatible JSON data for context menu commands.
+ */
declare class ContextMenuCommandBuilder {
/**
- * The name of this context menu command
+ * The name of this command.
*/
readonly name: string;
/**
- * The localized names for this command
+ * The name localizations of this command.
*/
readonly name_localizations?: LocalizationMap;
/**
- * The type of this context menu command
+ * The type of this command.
*/
readonly type: ContextMenuCommandType;
/**
- * Whether the command is enabled by default when the app is added to a guild
+ * Whether this command is enabled by default when the application is added to a guild.
*
- * @deprecated This property is deprecated and will be removed in the future.
- * You should use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
+ * @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
*/
readonly default_permission: boolean | undefined;
/**
- * Set of permissions represented as a bit set for the command
+ * The set of permissions represented as a bit set for the command.
*/
readonly default_member_permissions: Permissions | null | undefined;
/**
- * Indicates whether the command is available in DMs with the application, only for globally-scoped commands.
- * By default, commands are visible.
+ * Indicates whether the command is available in direct messages with the application.
+ *
+ * @remarks
+ * By default, commands are visible. This property is only for global commands.
*/
readonly dm_permission: boolean | undefined;
/**
- * Sets the name
+ * Sets the name of this command.
*
- * @param name - The name
+ * @param name - The name to use
*/
setName(name: string): this;
/**
- * Sets the type
+ * Sets the type of this command.
*
- * @param type - The type
+ * @param type - The type to use
*/
setType(type: ContextMenuCommandType): this;
/**
@@ -1712,43 +1843,44 @@ declare class ContextMenuCommandBuilder {
*
* @remarks
* If set to `false`, you will have to later `PUT` the permissions for this command.
- * @param value - Whether or not to enable this command by default
- * @see https://discord.com/developers/docs/interactions/application-commands#permissions
+ * @param value - Whether to enable this command by default
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
* @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
*/
setDefaultPermission(value: boolean): this;
/**
- * Sets the default permissions a member should have in order to run the command.
+ * Sets the default permissions a member should have in order to run this command.
*
* @remarks
* You can set this to `'0'` to disable the command by default.
* @param permissions - The permissions bit field to set
- * @see https://discord.com/developers/docs/interactions/application-commands#permissions
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
*/
setDefaultMemberPermissions(permissions: Permissions | bigint | number | null | undefined): this;
/**
- * Sets if the command is available in DMs with the application, only for globally-scoped commands.
- * By default, commands are visible.
+ * Sets if the command is available in direct messages with the application.
*
- * @param enabled - If the command should be enabled in DMs
- * @see https://discord.com/developers/docs/interactions/application-commands#permissions
+ * @remarks
+ * By default, commands are visible. This method is only for global commands.
+ * @param enabled - Whether the command should be enabled in direct messages
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
*/
setDMPermission(enabled: boolean | null | undefined): this;
/**
- * Sets a name localization
+ * Sets a name localization for this command.
*
- * @param locale - The locale to set a description for
- * @param localizedName - The localized description for the given locale
+ * @param locale - The locale to set
+ * @param localizedName - The localized name for the given `locale`
*/
setNameLocalization(locale: LocaleString, localizedName: string | null): this;
/**
- * Sets the name localizations
+ * Sets the name localizations for this command.
*
- * @param localizedNames - The dictionary of localized descriptions to set
+ * @param localizedNames - The object of localized names to set
*/
setNameLocalizations(localizedNames: LocalizationMap | null): this;
/**
- * Returns the final data that should be sent to Discord.
+ * Serializes this builder to API-compatible JSON data.
*
* @remarks
* This method runs validations on the data before serializing it.
@@ -1756,7 +1888,6 @@ declare class ContextMenuCommandBuilder {
*/
toJSON(): RESTPostAPIContextMenuApplicationCommandsJSONBody;
}
-type ContextMenuCommandType = ApplicationCommandType.Message | ApplicationCommandType.User;
declare function validateDefaultPermission(value: unknown): asserts value is boolean;
declare function validateName(name: unknown): asserts name is string;
@@ -1765,33 +1896,53 @@ declare function validateRequiredParameters(name: string, type: number): void;
declare function validateDMPermission(value: unknown): asserts value is boolean | null | undefined;
declare function validateDefaultMemberPermissions(permissions: unknown): string | null | undefined;
-declare const Assertions_validateDefaultPermission: typeof validateDefaultPermission;
-declare const Assertions_validateName: typeof validateName;
-declare const Assertions_validateType: typeof validateType;
-declare const Assertions_validateRequiredParameters: typeof validateRequiredParameters;
declare const Assertions_validateDMPermission: typeof validateDMPermission;
declare const Assertions_validateDefaultMemberPermissions: typeof validateDefaultMemberPermissions;
+declare const Assertions_validateDefaultPermission: typeof validateDefaultPermission;
+declare const Assertions_validateName: typeof validateName;
+declare const Assertions_validateRequiredParameters: typeof validateRequiredParameters;
+declare const Assertions_validateType: typeof validateType;
declare namespace Assertions {
export {
- Assertions_validateDefaultPermission as validateDefaultPermission,
- Assertions_validateName as validateName,
- Assertions_validateType as validateType,
- Assertions_validateRequiredParameters as validateRequiredParameters,
Assertions_validateDMPermission as validateDMPermission,
Assertions_validateDefaultMemberPermissions as validateDefaultMemberPermissions,
+ Assertions_validateDefaultPermission as validateDefaultPermission,
+ Assertions_validateName as validateName,
+ Assertions_validateRequiredParameters as validateRequiredParameters,
+ Assertions_validateType as validateType,
};
}
+/**
+ * Calculates the length of the embed.
+ *
+ * @param data - The embed data to check
+ */
declare function embedLength(data: APIEmbed): number;
-declare const enableValidators: () => boolean;
-declare const disableValidators: () => boolean;
-declare const isValidationEnabled: () => boolean;
+/**
+ * Enables validators.
+ *
+ * @returns Whether validation is occurring.
+ */
+declare function enableValidators(): boolean;
+/**
+ * Disables validators.
+ *
+ * @returns Whether validation is occurring.
+ */
+declare function disableValidators(): boolean;
+/**
+ * Checks whether validation is occurring.
+ */
+declare function isValidationEnabled(): boolean;
/**
- * The {@link https://github.com/discordjs/discord.js/blob/main/packages/builders/#readme | @discordjs/builders} version
+ * The {@link https://github.com/discordjs/discord.js/blob/main/packages/builders#readme | @discordjs/builders} version
* that you are currently using.
+ *
+ * @privateRemarks This needs to explicitly be `string` so it is not typed as a "const string" that gets injected by esbuild.
*/
declare const version: string;
-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 };
+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, 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, ToAPIApplicationCommandOptions, UserSelectMenuBuilder, createComponentBuilder, disableValidators, embedLength, enableValidators, isValidationEnabled, normalizeArray, version };
diff --git a/node_modules/@discordjs/builders/dist/index.js b/node_modules/@discordjs/builders/dist/index.js
index 8e6a442..456ed60 100644
--- a/node_modules/@discordjs/builders/dist/index.js
+++ b/node_modules/@discordjs/builders/dist/index.js
@@ -20,6 +20,10 @@ var __copyProps = (to, from, except, desc) => {
};
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
+ // If the importer is in node compatibility mode or this is not an ESM
+ // file that has been converted to a CommonJS file using a Babel-
+ // compatible transform (i.e. "__esModule" has not been set), then set
+ // "default" to the CommonJS "module.exports" for node compatibility.
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
@@ -51,7 +55,6 @@ __export(src_exports, {
ContextMenuCommandBuilder: () => ContextMenuCommandBuilder,
EmbedAssertions: () => Assertions_exports,
EmbedBuilder: () => EmbedBuilder,
- Faces: () => Faces,
MentionableSelectMenuBuilder: () => MentionableSelectMenuBuilder,
ModalAssertions: () => Assertions_exports4,
ModalBuilder: () => ModalBuilder,
@@ -77,33 +80,13 @@ __export(src_exports, {
StringSelectMenuOptionBuilder: () => StringSelectMenuOptionBuilder,
TextInputAssertions: () => Assertions_exports3,
TextInputBuilder: () => TextInputBuilder,
- TimestampStyles: () => TimestampStyles,
UserSelectMenuBuilder: () => UserSelectMenuBuilder,
- blockQuote: () => blockQuote,
- bold: () => bold,
- channelLink: () => channelLink,
- channelMention: () => channelMention,
- chatInputApplicationCommandMention: () => chatInputApplicationCommandMention,
- codeBlock: () => codeBlock,
createComponentBuilder: () => createComponentBuilder,
disableValidators: () => disableValidators,
embedLength: () => embedLength,
enableValidators: () => enableValidators,
- formatEmoji: () => formatEmoji,
- hideLinkEmbed: () => hideLinkEmbed,
- hyperlink: () => hyperlink,
- inlineCode: () => inlineCode,
isValidationEnabled: () => isValidationEnabled,
- italic: () => italic,
- messageLink: () => messageLink,
normalizeArray: () => normalizeArray,
- quote: () => quote,
- roleMention: () => roleMention,
- spoiler: () => spoiler,
- strikethrough: () => strikethrough,
- time: () => time,
- underscore: () => underscore,
- userMention: () => userMention,
version: () => version
});
module.exports = __toCommonJS(src_exports);
@@ -134,9 +117,18 @@ var import_shapeshift = require("@sapphire/shapeshift");
// src/util/validation.ts
var validate = true;
-var enableValidators = /* @__PURE__ */ __name(() => validate = true, "enableValidators");
-var disableValidators = /* @__PURE__ */ __name(() => validate = false, "disableValidators");
-var isValidationEnabled = /* @__PURE__ */ __name(() => validate, "isValidationEnabled");
+function enableValidators() {
+ return validate = true;
+}
+__name(enableValidators, "enableValidators");
+function disableValidators() {
+ return validate = false;
+}
+__name(disableValidators, "disableValidators");
+function isValidationEnabled() {
+ return validate;
+}
+__name(isValidationEnabled, "isValidationEnabled");
// src/messages/embed/Assertions.ts
var fieldNamePredicate = import_shapeshift.s.string.lengthGreaterThanOrEqual(1).lengthLessThanOrEqual(256).setValidationEnabled(isValidationEnabled);
@@ -186,22 +178,83 @@ __name(normalizeArray, "normalizeArray");
// src/messages/embed/Embed.ts
var EmbedBuilder = class {
+ /**
+ * The API data associated with this embed.
+ */
data;
+ /**
+ * Creates a new embed from API data.
+ *
+ * @param data - The API data to create this embed with
+ */
constructor(data = {}) {
this.data = { ...data };
if (data.timestamp)
this.data.timestamp = new Date(data.timestamp).toISOString();
}
+ /**
+ * Appends fields to the embed.
+ *
+ * @remarks
+ * This method accepts either an array of fields or a variable number of field parameters.
+ * The maximum amount of fields that can be added is 25.
+ * @example
+ * Using an array:
+ * ```ts
+ * const fields: APIEmbedField[] = ...;
+ * const embed = new EmbedBuilder()
+ * .addFields(fields);
+ * ```
+ * @example
+ * Using rest parameters (variadic):
+ * ```ts
+ * const embed = new EmbedBuilder()
+ * .addFields(
+ * { name: 'Field 1', value: 'Value 1' },
+ * { name: 'Field 2', value: 'Value 2' },
+ * );
+ * ```
+ * @param fields - The fields to add
+ */
addFields(...fields) {
- fields = normalizeArray(fields);
- validateFieldLength(fields.length, this.data.fields);
- embedFieldsArrayPredicate.parse(fields);
+ const normalizedFields = normalizeArray(fields);
+ validateFieldLength(normalizedFields.length, this.data.fields);
+ embedFieldsArrayPredicate.parse(normalizedFields);
if (this.data.fields)
- this.data.fields.push(...fields);
+ this.data.fields.push(...normalizedFields);
else
- this.data.fields = fields;
+ this.data.fields = normalizedFields;
return this;
}
+ /**
+ * Removes, replaces, or inserts fields for this embed.
+ *
+ * @remarks
+ * This method behaves similarly
+ * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/splice | Array.prototype.splice()}.
+ * The maximum amount of fields that can be added is 25.
+ *
+ * It's useful for modifying and adjusting order of the already-existing fields of an embed.
+ * @example
+ * Remove the first field:
+ * ```ts
+ * embed.spliceFields(0, 1);
+ * ```
+ * @example
+ * Remove the first n fields:
+ * ```ts
+ * const n = 4;
+ * embed.spliceFields(0, n);
+ * ```
+ * @example
+ * Remove the last field:
+ * ```ts
+ * embed.spliceFields(-1, 1);
+ * ```
+ * @param index - The index to start at
+ * @param deleteCount - The number of fields to remove
+ * @param fields - The replacing field objects
+ */
spliceFields(index, deleteCount, ...fields) {
validateFieldLength(fields.length - deleteCount, this.data.fields);
embedFieldsArrayPredicate.parse(fields);
@@ -211,10 +264,25 @@ var EmbedBuilder = class {
this.data.fields = fields;
return this;
}
+ /**
+ * Sets the fields for this embed.
+ *
+ * @remarks
+ * This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,
+ * it splices the entire array of fields, replacing them with the provided fields.
+ *
+ * You can set a maximum of 25 fields.
+ * @param fields - The fields to set
+ */
setFields(...fields) {
this.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));
return this;
}
+ /**
+ * Sets the author of this embed.
+ *
+ * @param options - The options to use
+ */
setAuthor(options) {
if (options === null) {
this.data.author = void 0;
@@ -224,6 +292,11 @@ var EmbedBuilder = class {
this.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };
return this;
}
+ /**
+ * Sets the color of this embed.
+ *
+ * @param color - The color to use
+ */
setColor(color) {
colorPredicate.parse(color);
if (Array.isArray(color)) {
@@ -234,11 +307,21 @@ var EmbedBuilder = class {
this.data.color = color ?? void 0;
return this;
}
+ /**
+ * Sets the description of this embed.
+ *
+ * @param description - The description to use
+ */
setDescription(description) {
descriptionPredicate.parse(description);
this.data.description = description ?? void 0;
return this;
}
+ /**
+ * Sets the footer of this embed.
+ *
+ * @param options - The footer to use
+ */
setFooter(options) {
if (options === null) {
this.data.footer = void 0;
@@ -248,142 +331,71 @@ var EmbedBuilder = class {
this.data.footer = { text: options.text, icon_url: options.iconURL };
return this;
}
+ /**
+ * Sets the image of this embed.
+ *
+ * @param url - The image URL to use
+ */
setImage(url) {
imageURLPredicate.parse(url);
this.data.image = url ? { url } : void 0;
return this;
}
+ /**
+ * Sets the thumbnail of this embed.
+ *
+ * @param url - The thumbnail URL to use
+ */
setThumbnail(url) {
imageURLPredicate.parse(url);
this.data.thumbnail = url ? { url } : void 0;
return this;
}
+ /**
+ * Sets the timestamp of this embed.
+ *
+ * @param timestamp - The timestamp or date to use
+ */
setTimestamp(timestamp = Date.now()) {
timestampPredicate.parse(timestamp);
this.data.timestamp = timestamp ? new Date(timestamp).toISOString() : void 0;
return this;
}
+ /**
+ * Sets the title for this embed.
+ *
+ * @param title - The title to use
+ */
setTitle(title) {
titlePredicate.parse(title);
this.data.title = title ?? void 0;
return this;
}
+ /**
+ * Sets the URL of this embed.
+ *
+ * @param url - The URL to use
+ */
setURL(url) {
urlPredicate.parse(url);
this.data.url = url ?? void 0;
return this;
}
+ /**
+ * Serializes this builder to API-compatible JSON data.
+ *
+ * @remarks
+ * This method runs validations on the data before serializing it.
+ * As such, it may throw an error if the data is invalid.
+ */
toJSON() {
return { ...this.data };
}
};
__name(EmbedBuilder, "EmbedBuilder");
-// src/messages/formatters.ts
-function codeBlock(language, content) {
- return typeof content === "undefined" ? `\`\`\`
-${language}
-\`\`\`` : `\`\`\`${language}
-${content}
-\`\`\``;
-}
-__name(codeBlock, "codeBlock");
-function inlineCode(content) {
- return `\`${content}\``;
-}
-__name(inlineCode, "inlineCode");
-function italic(content) {
- return `_${content}_`;
-}
-__name(italic, "italic");
-function bold(content) {
- return `**${content}**`;
-}
-__name(bold, "bold");
-function underscore(content) {
- return `__${content}__`;
-}
-__name(underscore, "underscore");
-function strikethrough(content) {
- return `~~${content}~~`;
-}
-__name(strikethrough, "strikethrough");
-function quote(content) {
- return `> ${content}`;
-}
-__name(quote, "quote");
-function blockQuote(content) {
- return `>>> ${content}`;
-}
-__name(blockQuote, "blockQuote");
-function hideLinkEmbed(url) {
- return `<${url}>`;
-}
-__name(hideLinkEmbed, "hideLinkEmbed");
-function hyperlink(content, url, title) {
- return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`;
-}
-__name(hyperlink, "hyperlink");
-function spoiler(content) {
- return `||${content}||`;
-}
-__name(spoiler, "spoiler");
-function userMention(userId) {
- return `<@${userId}>`;
-}
-__name(userMention, "userMention");
-function channelMention(channelId) {
- return `<#${channelId}>`;
-}
-__name(channelMention, "channelMention");
-function roleMention(roleId) {
- return `<@&${roleId}>`;
-}
-__name(roleMention, "roleMention");
-function chatInputApplicationCommandMention(commandName, subcommandGroupName, subcommandName, commandId) {
- if (typeof commandId !== "undefined") {
- return `${commandName} ${subcommandGroupName} ${subcommandName}:${commandId}>`;
- }
- if (typeof subcommandName !== "undefined") {
- return `${commandName} ${subcommandGroupName}:${subcommandName}>`;
- }
- return `${commandName}:${subcommandGroupName}>`;
-}
-__name(chatInputApplicationCommandMention, "chatInputApplicationCommandMention");
-function formatEmoji(emojiId, animated = false) {
- return `<${animated ? "a" : ""}:_:${emojiId}>`;
-}
-__name(formatEmoji, "formatEmoji");
-function channelLink(channelId, guildId) {
- return `https://discord.com/channels/${guildId ?? "@me"}/${channelId}`;
-}
-__name(channelLink, "channelLink");
-function messageLink(channelId, messageId, guildId) {
- return `${typeof guildId === "undefined" ? channelLink(channelId) : channelLink(channelId, guildId)}/${messageId}`;
-}
-__name(messageLink, "messageLink");
-function time(timeOrSeconds, style) {
- if (typeof timeOrSeconds !== "number") {
- timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1e3);
- }
- return typeof style === "string" ? `` : ``;
-}
-__name(time, "time");
-var TimestampStyles = {
- ShortTime: "t",
- LongTime: "T",
- ShortDate: "d",
- LongDate: "D",
- ShortDateTime: "f",
- LongDateTime: "F",
- RelativeTime: "R"
-};
-var Faces = /* @__PURE__ */ ((Faces2) => {
- Faces2["Shrug"] = "\xAF\\_(\u30C4)\\_/\xAF";
- Faces2["Tableflip"] = "(\u256F\xB0\u25A1\xB0\uFF09\u256F\uFE35 \u253B\u2501\u253B";
- Faces2["Unflip"] = "\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)";
- return Faces2;
-})(Faces || {});
+// src/index.ts
+__reExport(src_exports, require("@discordjs/formatters"), module.exports);
// src/components/Assertions.ts
var Assertions_exports2 = {};
@@ -412,29 +424,79 @@ var import_v10 = require("discord-api-types/v10");
// src/components/selectMenu/StringSelectMenuOption.ts
var StringSelectMenuOptionBuilder = class {
+ /**
+ * Creates a new string select menu option from API data.
+ *
+ * @param data - The API data to create this string select menu option with
+ * @example
+ * Creating a string select menu option from an API data object:
+ * ```ts
+ * const selectMenuOption = new SelectMenuOptionBuilder({
+ * label: 'catchy label',
+ * value: '1',
+ * });
+ * ```
+ * @example
+ * Creating a string select menu option using setters and API data:
+ * ```ts
+ * const selectMenuOption = new SelectMenuOptionBuilder({
+ * default: true,
+ * value: '1',
+ * })
+ * .setLabel('woah');
+ * ```
+ */
constructor(data = {}) {
this.data = data;
}
+ /**
+ * Sets the label for this option.
+ *
+ * @param label - The label to use
+ */
setLabel(label) {
this.data.label = labelValueDescriptionValidator.parse(label);
return this;
}
+ /**
+ * Sets the value for this option.
+ *
+ * @param value - The value to use
+ */
setValue(value) {
this.data.value = labelValueDescriptionValidator.parse(value);
return this;
}
+ /**
+ * Sets the description for this option.
+ *
+ * @param description - The description to use
+ */
setDescription(description) {
this.data.description = labelValueDescriptionValidator.parse(description);
return this;
}
+ /**
+ * Sets whether this option is selected by default.
+ *
+ * @param isDefault - Whether this option is selected by default
+ */
setDefault(isDefault = true) {
this.data.default = defaultValidator.parse(isDefault);
return this;
}
+ /**
+ * Sets the emoji to display for this option.
+ *
+ * @param emoji - The emoji to use
+ */
setEmoji(emoji) {
this.data.emoji = emojiValidator.parse(emoji);
return this;
}
+ /**
+ * {@inheritDoc BaseSelectMenuBuilder.toJSON}
+ */
toJSON() {
validateRequiredSelectMenuOptionParameters(this.data.label, this.data.value);
return {
@@ -504,7 +566,15 @@ var import_v1011 = require("discord-api-types/v10");
// src/components/Component.ts
var ComponentBuilder = class {
+ /**
+ * The API data associated with this component.
+ */
data;
+ /**
+ * Constructs a new kind of component.
+ *
+ * @param data - The data to construct a component out of
+ */
constructor(data) {
this.data = data;
}
@@ -517,33 +587,99 @@ var import_v1010 = require("discord-api-types/v10");
// src/components/button/Button.ts
var import_v102 = require("discord-api-types/v10");
var ButtonBuilder = class extends ComponentBuilder {
+ /**
+ * Creates a new button from API data.
+ *
+ * @param data - The API data to create this button with
+ * @example
+ * Creating a button from an API data object:
+ * ```ts
+ * const button = new ButtonBuilder({
+ * custom_id: 'a cool button',
+ * style: ButtonStyle.Primary,
+ * label: 'Click Me',
+ * emoji: {
+ * name: 'smile',
+ * id: '123456789012345678',
+ * },
+ * });
+ * ```
+ * @example
+ * Creating a button using setters and API data:
+ * ```ts
+ * const button = new ButtonBuilder({
+ * style: ButtonStyle.Secondary,
+ * label: 'Click Me',
+ * })
+ * .setEmoji({ name: '🙂' })
+ * .setCustomId('another cool button');
+ * ```
+ */
constructor(data) {
super({ type: import_v102.ComponentType.Button, ...data });
}
+ /**
+ * Sets the style of this button.
+ *
+ * @param style - The style to use
+ */
setStyle(style) {
this.data.style = buttonStyleValidator.parse(style);
return this;
}
+ /**
+ * Sets the URL for this button.
+ *
+ * @remarks
+ * This method is only available to buttons using the `Link` button style.
+ * Only three types of URL schemes are currently supported: `https://`, `http://`, and `discord://`.
+ * @param url - The URL to use
+ */
setURL(url) {
this.data.url = urlValidator.parse(url);
return this;
}
+ /**
+ * Sets the custom id for this button.
+ *
+ * @remarks
+ * This method is only applicable to buttons that are not using the `Link` button style.
+ * @param customId - The custom id to use
+ */
setCustomId(customId) {
this.data.custom_id = customIdValidator.parse(customId);
return this;
}
+ /**
+ * Sets the emoji to display on this button.
+ *
+ * @param emoji - The emoji to use
+ */
setEmoji(emoji) {
this.data.emoji = emojiValidator.parse(emoji);
return this;
}
+ /**
+ * Sets whether this button is disabled.
+ *
+ * @param disabled - Whether to disable this button
+ */
setDisabled(disabled = true) {
this.data.disabled = disabledValidator.parse(disabled);
return this;
}
+ /**
+ * Sets the label for this button.
+ *
+ * @param label - The label to use
+ */
setLabel(label) {
this.data.label = buttonLabelValidator.parse(label);
return this;
}
+ /**
+ * {@inheritDoc ComponentBuilder.toJSON}
+ */
toJSON() {
validateRequiredButtonParameters(
this.data.style,
@@ -564,26 +700,54 @@ var import_v103 = require("discord-api-types/v10");
// src/components/selectMenu/BaseSelectMenu.ts
var BaseSelectMenuBuilder = class extends ComponentBuilder {
+ /**
+ * Sets the placeholder for this select menu.
+ *
+ * @param placeholder - The placeholder to use
+ */
setPlaceholder(placeholder) {
this.data.placeholder = placeholderValidator.parse(placeholder);
return this;
}
+ /**
+ * Sets the minimum values that must be selected in the select menu.
+ *
+ * @param minValues - The minimum values that must be selected
+ */
setMinValues(minValues) {
this.data.min_values = minMaxValidator.parse(minValues);
return this;
}
+ /**
+ * Sets the maximum values that must be selected in the select menu.
+ *
+ * @param maxValues - The maximum values that must be selected
+ */
setMaxValues(maxValues) {
this.data.max_values = minMaxValidator.parse(maxValues);
return this;
}
+ /**
+ * Sets the custom id for this select menu.
+ *
+ * @param customId - The custom id to use
+ */
setCustomId(customId) {
this.data.custom_id = customIdValidator.parse(customId);
return this;
}
+ /**
+ * Sets whether this select menu is disabled.
+ *
+ * @param disabled - Whether this select menu is disabled
+ */
setDisabled(disabled = true) {
this.data.disabled = disabledValidator.parse(disabled);
return this;
}
+ /**
+ * {@inheritDoc ComponentBuilder.toJSON}
+ */
toJSON() {
customIdValidator.parse(this.data.custom_id);
return {
@@ -595,21 +759,57 @@ __name(BaseSelectMenuBuilder, "BaseSelectMenuBuilder");
// src/components/selectMenu/ChannelSelectMenu.ts
var ChannelSelectMenuBuilder = class extends BaseSelectMenuBuilder {
+ /**
+ * Creates a new select menu from API data.
+ *
+ * @param data - The API data to create this select menu with
+ * @example
+ * Creating a select menu from an API data object:
+ * ```ts
+ * const selectMenu = new ChannelSelectMenuBuilder({
+ * custom_id: 'a cool select menu',
+ * placeholder: 'select an option',
+ * max_values: 2,
+ * });
+ * ```
+ * @example
+ * Creating a select menu using setters and API data:
+ * ```ts
+ * const selectMenu = new ChannelSelectMenuBuilder({
+ * custom_id: 'a cool select menu',
+ * })
+ * .addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)
+ * .setMinValues(2);
+ * ```
+ */
constructor(data) {
super({ ...data, type: import_v103.ComponentType.ChannelSelect });
}
+ /**
+ * Adds channel types to this select menu.
+ *
+ * @param types - The channel types to use
+ */
addChannelTypes(...types) {
- types = normalizeArray(types);
+ const normalizedTypes = normalizeArray(types);
this.data.channel_types ??= [];
- this.data.channel_types.push(...channelTypesValidator.parse(types));
+ this.data.channel_types.push(...channelTypesValidator.parse(normalizedTypes));
return this;
}
+ /**
+ * Sets channel types for this select menu.
+ *
+ * @param types - The channel types to use
+ */
setChannelTypes(...types) {
- types = normalizeArray(types);
+ const normalizedTypes = normalizeArray(types);
this.data.channel_types ??= [];
- this.data.channel_types.splice(0, this.data.channel_types.length, ...channelTypesValidator.parse(types));
+ this.data.channel_types.splice(0, this.data.channel_types.length, ...channelTypesValidator.parse(normalizedTypes));
return this;
}
+ /**
+ * {@inheritDoc BaseSelectMenuBuilder.toJSON}
+ */
toJSON() {
customIdValidator.parse(this.data.custom_id);
return {
@@ -622,6 +822,28 @@ __name(ChannelSelectMenuBuilder, "ChannelSelectMenuBuilder");
// src/components/selectMenu/MentionableSelectMenu.ts
var import_v104 = require("discord-api-types/v10");
var MentionableSelectMenuBuilder = class extends BaseSelectMenuBuilder {
+ /**
+ * Creates a new select menu from API data.
+ *
+ * @param data - The API data to create this select menu with
+ * @example
+ * Creating a select menu from an API data object:
+ * ```ts
+ * const selectMenu = new MentionableSelectMenuBuilder({
+ * custom_id: 'a cool select menu',
+ * placeholder: 'select an option',
+ * max_values: 2,
+ * });
+ * ```
+ * @example
+ * Creating a select menu using setters and API data:
+ * ```ts
+ * const selectMenu = new MentionableSelectMenuBuilder({
+ * custom_id: 'a cool select menu',
+ * })
+ * .setMinValues(1);
+ * ```
+ */
constructor(data) {
super({ ...data, type: import_v104.ComponentType.MentionableSelect });
}
@@ -631,6 +853,28 @@ __name(MentionableSelectMenuBuilder, "MentionableSelectMenuBuilder");
// src/components/selectMenu/RoleSelectMenu.ts
var import_v105 = require("discord-api-types/v10");
var RoleSelectMenuBuilder = class extends BaseSelectMenuBuilder {
+ /**
+ * Creates a new select menu from API data.
+ *
+ * @param data - The API data to create this select menu with
+ * @example
+ * Creating a select menu from an API data object:
+ * ```ts
+ * const selectMenu = new RoleSelectMenuBuilder({
+ * custom_id: 'a cool select menu',
+ * placeholder: 'select an option',
+ * max_values: 2,
+ * });
+ * ```
+ * @example
+ * Creating a select menu using setters and API data:
+ * ```ts
+ * const selectMenu = new RoleSelectMenuBuilder({
+ * custom_id: 'a cool select menu',
+ * })
+ * .setMinValues(1);
+ * ```
+ */
constructor(data) {
super({ ...data, type: import_v105.ComponentType.RoleSelect });
}
@@ -640,34 +884,113 @@ __name(RoleSelectMenuBuilder, "RoleSelectMenuBuilder");
// src/components/selectMenu/StringSelectMenu.ts
var import_v106 = require("discord-api-types/v10");
var StringSelectMenuBuilder = class extends BaseSelectMenuBuilder {
+ /**
+ * The options within this select menu.
+ */
options;
+ /**
+ * Creates a new select menu from API data.
+ *
+ * @param data - The API data to create this select menu with
+ * @example
+ * Creating a select menu from an API data object:
+ * ```ts
+ * const selectMenu = new StringSelectMenuBuilder({
+ * custom_id: 'a cool select menu',
+ * placeholder: 'select an option',
+ * max_values: 2,
+ * options: [
+ * { label: 'option 1', value: '1' },
+ * { label: 'option 2', value: '2' },
+ * { label: 'option 3', value: '3' },
+ * ],
+ * });
+ * ```
+ * @example
+ * Creating a select menu using setters and API data:
+ * ```ts
+ * const selectMenu = new StringSelectMenuBuilder({
+ * custom_id: 'a cool select menu',
+ * })
+ * .setMinValues(1)
+ * .addOptions({
+ * label: 'Catchy',
+ * value: 'catch',
+ * });
+ * ```
+ */
constructor(data) {
const { options, ...initData } = data ?? {};
super({ ...initData, type: import_v106.ComponentType.StringSelect });
this.options = options?.map((option) => new StringSelectMenuOptionBuilder(option)) ?? [];
}
+ /**
+ * Adds options to this select menu.
+ *
+ * @param options - The options to add
+ */
addOptions(...options) {
- options = normalizeArray(options);
- optionsLengthValidator.parse(this.options.length + options.length);
+ const normalizedOptions = normalizeArray(options);
+ optionsLengthValidator.parse(this.options.length + normalizedOptions.length);
this.options.push(
- ...options.map(
- (option) => option instanceof StringSelectMenuOptionBuilder ? option : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(option))
+ ...normalizedOptions.map(
+ (normalizedOption) => normalizedOption instanceof StringSelectMenuOptionBuilder ? normalizedOption : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(normalizedOption))
)
);
return this;
}
+ /**
+ * Sets the options for this select menu.
+ *
+ * @param options - The options to set
+ */
setOptions(...options) {
- options = normalizeArray(options);
- optionsLengthValidator.parse(options.length);
- this.options.splice(
- 0,
- this.options.length,
- ...options.map(
- (option) => option instanceof StringSelectMenuOptionBuilder ? option : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(option))
+ return this.spliceOptions(0, this.options.length, ...options);
+ }
+ /**
+ * Removes, replaces, or inserts options for this select menu.
+ *
+ * @remarks
+ * This method behaves similarly
+ * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice()}.
+ * It's useful for modifying and adjusting the order of existing options.
+ * @example
+ * Remove the first option:
+ * ```ts
+ * selectMenu.spliceOptions(0, 1);
+ * ```
+ * @example
+ * Remove the first n option:
+ * ```ts
+ * const n = 4;
+ * selectMenu.spliceOptions(0, n);
+ * ```
+ * @example
+ * Remove the last option:
+ * ```ts
+ * selectMenu.spliceOptions(-1, 1);
+ * ```
+ * @param index - The index to start at
+ * @param deleteCount - The number of options to remove
+ * @param options - The replacing option objects or builders
+ */
+ spliceOptions(index, deleteCount, ...options) {
+ const normalizedOptions = normalizeArray(options);
+ const clone = [...this.options];
+ clone.splice(
+ index,
+ deleteCount,
+ ...normalizedOptions.map(
+ (normalizedOption) => normalizedOption instanceof StringSelectMenuOptionBuilder ? normalizedOption : new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(normalizedOption))
)
);
+ optionsLengthValidator.parse(clone.length);
+ this.options.splice(0, this.options.length, ...clone);
return this;
}
+ /**
+ * {@inheritDoc BaseSelectMenuBuilder.toJSON}
+ */
toJSON() {
validateRequiredSelectMenuParameters(this.options, this.data.custom_id);
return {
@@ -681,6 +1004,28 @@ __name(StringSelectMenuBuilder, "StringSelectMenuBuilder");
// src/components/selectMenu/UserSelectMenu.ts
var import_v107 = require("discord-api-types/v10");
var UserSelectMenuBuilder = class extends BaseSelectMenuBuilder {
+ /**
+ * Creates a new select menu from API data.
+ *
+ * @param data - The API data to create this select menu with
+ * @example
+ * Creating a select menu from an API data object:
+ * ```ts
+ * const selectMenu = new UserSelectMenuBuilder({
+ * custom_id: 'a cool select menu',
+ * placeholder: 'select an option',
+ * max_values: 2,
+ * });
+ * ```
+ * @example
+ * Creating a select menu using setters and API data:
+ * ```ts
+ * const selectMenu = new UserSelectMenuBuilder({
+ * custom_id: 'a cool select menu',
+ * })
+ * .setMinValues(1);
+ * ```
+ */
constructor(data) {
super({ ...data, type: import_v107.ComponentType.UserSelect });
}
@@ -722,47 +1067,116 @@ __name(validateRequiredParameters, "validateRequiredParameters");
// src/components/textInput/TextInput.ts
var TextInputBuilder = class extends ComponentBuilder {
+ /**
+ * Creates a new text input from API data.
+ *
+ * @param data - The API data to create this text input with
+ * @example
+ * Creating a select menu option from an API data object:
+ * ```ts
+ * const textInput = new TextInputBuilder({
+ * custom_id: 'a cool select menu',
+ * label: 'Type something',
+ * style: TextInputStyle.Short,
+ * });
+ * ```
+ * @example
+ * Creating a select menu option using setters and API data:
+ * ```ts
+ * const textInput = new TextInputBuilder({
+ * label: 'Type something else',
+ * })
+ * .setCustomId('woah')
+ * .setStyle(TextInputStyle.Paragraph);
+ * ```
+ */
constructor(data) {
super({ type: import_v109.ComponentType.TextInput, ...data });
}
+ /**
+ * Sets the custom id for this text input.
+ *
+ * @param customId - The custom id to use
+ */
setCustomId(customId) {
this.data.custom_id = customIdValidator.parse(customId);
return this;
}
+ /**
+ * Sets the label for this text input.
+ *
+ * @param label - The label to use
+ */
setLabel(label) {
this.data.label = labelValidator.parse(label);
return this;
}
+ /**
+ * Sets the style for this text input.
+ *
+ * @param style - The style to use
+ */
setStyle(style) {
this.data.style = textInputStyleValidator.parse(style);
return this;
}
+ /**
+ * Sets the minimum length of text for this text input.
+ *
+ * @param minLength - The minimum length of text for this text input
+ */
setMinLength(minLength) {
this.data.min_length = minLengthValidator.parse(minLength);
return this;
}
+ /**
+ * Sets the maximum length of text for this text input.
+ *
+ * @param maxLength - The maximum length of text for this text input
+ */
setMaxLength(maxLength) {
this.data.max_length = maxLengthValidator.parse(maxLength);
return this;
}
+ /**
+ * Sets the placeholder for this text input.
+ *
+ * @param placeholder - The placeholder to use
+ */
setPlaceholder(placeholder) {
this.data.placeholder = placeholderValidator2.parse(placeholder);
return this;
}
+ /**
+ * Sets the value for this text input.
+ *
+ * @param value - The value to use
+ */
setValue(value) {
this.data.value = valueValidator.parse(value);
return this;
}
+ /**
+ * Sets whether this text input is required.
+ *
+ * @param required - Whether this text input is required
+ */
setRequired(required = true) {
this.data.required = requiredValidator.parse(required);
return this;
}
+ /**
+ * {@inheritDoc ComponentBuilder.toJSON}
+ */
toJSON() {
validateRequiredParameters(this.data.custom_id, this.data.style, this.data.label);
return {
...this.data
};
}
+ /**
+ * {@inheritDoc Equatable.equals}
+ */
equals(other) {
if ((0, import_util.isJSONEncodable)(other)) {
return (0, import_fast_deep_equal.default)(other.toJSON(), this.data);
@@ -802,19 +1216,69 @@ __name(createComponentBuilder, "createComponentBuilder");
// src/components/ActionRow.ts
var ActionRowBuilder = class extends ComponentBuilder {
+ /**
+ * The components within this action row.
+ */
components;
+ /**
+ * Creates a new action row from API data.
+ *
+ * @param data - The API data to create this action row with
+ * @example
+ * Creating an action row from an API data object:
+ * ```ts
+ * const actionRow = new ActionRowBuilder({
+ * components: [
+ * {
+ * custom_id: "custom id",
+ * label: "Type something",
+ * style: TextInputStyle.Short,
+ * type: ComponentType.TextInput,
+ * },
+ * ],
+ * });
+ * ```
+ * @example
+ * Creating an action row using setters and API data:
+ * ```ts
+ * const actionRow = new ActionRowBuilder({
+ * components: [
+ * {
+ * custom_id: "custom id",
+ * label: "Click me",
+ * style: ButtonStyle.Primary,
+ * type: ComponentType.Button,
+ * },
+ * ],
+ * })
+ * .addComponents(button2, button3);
+ * ```
+ */
constructor({ components, ...data } = {}) {
super({ type: import_v1011.ComponentType.ActionRow, ...data });
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
}
+ /**
+ * Adds components to this action row.
+ *
+ * @param components - The components to add
+ */
addComponents(...components) {
this.components.push(...normalizeArray(components));
return this;
}
+ /**
+ * Sets components for this action row.
+ *
+ * @param components - The components to set
+ */
setComponents(...components) {
this.components.splice(0, this.components.length, ...normalizeArray(components));
return this;
}
+ /**
+ * {@inheritDoc ComponentBuilder.toJSON}
+ */
toJSON() {
return {
...this.data,
@@ -843,20 +1307,46 @@ __name(validateRequiredParameters2, "validateRequiredParameters");
// src/interactions/modals/Modal.ts
var ModalBuilder = class {
+ /**
+ * The API data associated with this modal.
+ */
data;
+ /**
+ * The components within this modal.
+ */
components = [];
+ /**
+ * Creates a new modal from API data.
+ *
+ * @param data - The API data to create this modal with
+ */
constructor({ components, ...data } = {}) {
this.data = { ...data };
this.components = components?.map((component) => createComponentBuilder(component)) ?? [];
}
+ /**
+ * Sets the title of this modal.
+ *
+ * @param title - The title to use
+ */
setTitle(title) {
this.data.title = titleValidator.parse(title);
return this;
}
+ /**
+ * Sets the custom id of this modal.
+ *
+ * @param customId - The custom id to use
+ */
setCustomId(customId) {
this.data.custom_id = customIdValidator.parse(customId);
return this;
}
+ /**
+ * Adds components to this modal.
+ *
+ * @param components - The components to add
+ */
addComponents(...components) {
this.components.push(
...normalizeArray(components).map(
@@ -865,10 +1355,18 @@ var ModalBuilder = class {
);
return this;
}
+ /**
+ * Sets components for this modal.
+ *
+ * @param components - The components to set
+ */
setComponents(...components) {
this.components.splice(0, this.components.length, ...normalizeArray(components));
return this;
}
+ /**
+ * {@inheritDoc ComponentBuilder.toJSON}
+ */
toJSON() {
validateRequiredParameters2(this.data.custom_id, this.data.title, this.components);
return {
@@ -892,6 +1390,7 @@ __export(Assertions_exports5, {
validateLocale: () => validateLocale,
validateLocalizationMap: () => validateLocalizationMap,
validateMaxOptionsLength: () => validateMaxOptionsLength,
+ validateNSFW: () => validateNSFW,
validateName: () => validateName,
validateRequired: () => validateRequired,
validateRequiredParameters: () => validateRequiredParameters3
@@ -961,6 +1460,10 @@ function validateDefaultMemberPermissions(permissions) {
return memberPermissionPredicate.parse(permissions);
}
__name(validateDefaultMemberPermissions, "validateDefaultMemberPermissions");
+function validateNSFW(value) {
+ booleanPredicate.parse(value);
+}
+__name(validateNSFW, "validateNSFW");
// src/interactions/slashCommands/SlashCommandBuilder.ts
var import_ts_mixer6 = require("ts-mixer");
@@ -971,20 +1474,48 @@ var import_ts_mixer5 = require("ts-mixer");
// src/interactions/slashCommands/mixins/NameAndDescription.ts
var SharedNameAndDescription = class {
+ /**
+ * The name of this command.
+ */
name;
+ /**
+ * The name localizations of this command.
+ */
name_localizations;
+ /**
+ * The description of this command.
+ */
description;
+ /**
+ * The description localizations of this command.
+ */
description_localizations;
+ /**
+ * Sets the name of this command.
+ *
+ * @param name - The name to use
+ */
setName(name) {
validateName(name);
Reflect.set(this, "name", name);
return this;
}
+ /**
+ * Sets the description of this command.
+ *
+ * @param description - The description to use
+ */
setDescription(description) {
validateDescription(description);
Reflect.set(this, "description", description);
return this;
}
+ /**
+ * SSets a name localization for this command.
+ *
+ * @param locale - The locale to set
+ * @param localizedName - The localized name for the given `locale`
+ */
setNameLocalization(locale, localizedName) {
if (!this.name_localizations) {
Reflect.set(this, "name_localizations", {});
@@ -998,6 +1529,11 @@ var SharedNameAndDescription = class {
this.name_localizations[parsedLocale] = localizedName;
return this;
}
+ /**
+ * Sets the name localizations for this command.
+ *
+ * @param localizedNames - The object of localized names to set
+ */
setNameLocalizations(localizedNames) {
if (localizedNames === null) {
Reflect.set(this, "name_localizations", null);
@@ -1009,6 +1545,12 @@ var SharedNameAndDescription = class {
}
return this;
}
+ /**
+ * Sets a description localization for this command.
+ *
+ * @param locale - The locale to set
+ * @param localizedDescription - The localized description for the given locale
+ */
setDescriptionLocalization(locale, localizedDescription) {
if (!this.description_localizations) {
Reflect.set(this, "description_localizations", {});
@@ -1022,6 +1564,11 @@ var SharedNameAndDescription = class {
this.description_localizations[parsedLocale] = localizedDescription;
return this;
}
+ /**
+ * Sets the description localizations for this command.
+ *
+ * @param localizedDescriptions - The object of localized descriptions to set
+ */
setDescriptionLocalizations(localizedDescriptions) {
if (localizedDescriptions === null) {
Reflect.set(this, "description_localizations", null);
@@ -1041,12 +1588,25 @@ var import_v1013 = require("discord-api-types/v10");
// src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts
var ApplicationCommandOptionBase = class extends SharedNameAndDescription {
+ /**
+ * Whether this option is required.
+ *
+ * @defaultValue `false`
+ */
required = false;
+ /**
+ * Sets whether this option is required.
+ *
+ * @param required - Whether this option should be required
+ */
setRequired(required) {
validateRequired(required);
Reflect.set(this, "required", required);
return this;
}
+ /**
+ * This method runs required validators on this builder.
+ */
runRequiredValidations() {
validateRequiredParameters3(this.name, this.description, []);
validateLocalizationMap(this.name_localizations);
@@ -1058,7 +1618,13 @@ __name(ApplicationCommandOptionBase, "ApplicationCommandOptionBase");
// src/interactions/slashCommands/options/attachment.ts
var SlashCommandAttachmentOption = class extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
type = import_v1013.ApplicationCommandOptionType.Attachment;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON() {
this.runRequiredValidations();
return { ...this };
@@ -1069,7 +1635,13 @@ __name(SlashCommandAttachmentOption, "SlashCommandAttachmentOption");
// src/interactions/slashCommands/options/boolean.ts
var import_v1014 = require("discord-api-types/v10");
var SlashCommandBooleanOption = class extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
type = import_v1014.ApplicationCommandOptionType.Boolean;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON() {
this.runRequiredValidations();
return { ...this };
@@ -1097,7 +1669,15 @@ var allowedChannelTypes = [
];
var channelTypesPredicate = import_shapeshift6.s.array(import_shapeshift6.s.union(...allowedChannelTypes.map((type) => import_shapeshift6.s.literal(type))));
var ApplicationCommandOptionChannelTypesMixin = class {
+ /**
+ * The channel types of this option.
+ */
channel_types;
+ /**
+ * Adds channel types to this option.
+ *
+ * @param channelTypes - The channel types
+ */
addChannelTypes(...channelTypes) {
if (this.channel_types === void 0) {
Reflect.set(this, "channel_types", []);
@@ -1110,7 +1690,13 @@ __name(ApplicationCommandOptionChannelTypesMixin, "ApplicationCommandOptionChann
// src/interactions/slashCommands/options/channel.ts
var SlashCommandChannelOption = class extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
type = import_v1016.ApplicationCommandOptionType.Channel;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON() {
this.runRequiredValidations();
return { ...this };
@@ -1128,7 +1714,13 @@ var import_ts_mixer2 = require("ts-mixer");
// src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts
var ApplicationCommandNumericOptionMinMaxValueMixin = class {
+ /**
+ * The maximum value of this option.
+ */
max_value;
+ /**
+ * The minimum value of this option.
+ */
min_value;
};
__name(ApplicationCommandNumericOptionMinMaxValueMixin, "ApplicationCommandNumericOptionMinMaxValueMixin");
@@ -1145,9 +1737,25 @@ var choicesPredicate = import_shapeshift7.s.object({
}).array;
var booleanPredicate2 = import_shapeshift7.s.boolean;
var ApplicationCommandOptionWithChoicesAndAutocompleteMixin = class {
+ /**
+ * The choices of this option.
+ */
choices;
+ /**
+ * Whether this option utilizes autocomplete.
+ */
autocomplete;
+ /**
+ * The type of this option.
+ *
+ * @privateRemarks Since this is present and this is a mixin, this is needed.
+ */
type;
+ /**
+ * Adds multiple choices to this option.
+ *
+ * @param choices - The choices to add
+ */
addChoices(...choices) {
if (choices.length > 0 && this.autocomplete) {
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
@@ -1167,6 +1775,11 @@ var ApplicationCommandOptionWithChoicesAndAutocompleteMixin = class {
}
return this;
}
+ /**
+ * Sets multiple choices for this option.
+ *
+ * @param choices - The choices to set
+ */
setChoices(...choices) {
if (choices.length > 0 && this.autocomplete) {
throw new RangeError("Autocomplete and choices are mutually exclusive to each other.");
@@ -1176,6 +1789,11 @@ var ApplicationCommandOptionWithChoicesAndAutocompleteMixin = class {
this.addChoices(...choices);
return this;
}
+ /**
+ * Whether this option uses autocomplete.
+ *
+ * @param autocomplete - Whether this option should use autocomplete
+ */
setAutocomplete(autocomplete) {
booleanPredicate2.parse(autocomplete);
if (autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
@@ -1190,17 +1808,29 @@ __name(ApplicationCommandOptionWithChoicesAndAutocompleteMixin, "ApplicationComm
// src/interactions/slashCommands/options/integer.ts
var numberValidator = import_shapeshift8.s.number.int;
var SlashCommandIntegerOption = class extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
type = import_v1018.ApplicationCommandOptionType.Integer;
+ /**
+ * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
+ */
setMaxValue(max) {
numberValidator.parse(max);
Reflect.set(this, "max_value", max);
return this;
}
+ /**
+ * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
+ */
setMinValue(min) {
numberValidator.parse(min);
Reflect.set(this, "min_value", min);
return this;
}
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON() {
this.runRequiredValidations();
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
@@ -1217,7 +1847,13 @@ SlashCommandIntegerOption = __decorateClass([
// src/interactions/slashCommands/options/mentionable.ts
var import_v1019 = require("discord-api-types/v10");
var SlashCommandMentionableOption = class extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
type = import_v1019.ApplicationCommandOptionType.Mentionable;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON() {
this.runRequiredValidations();
return { ...this };
@@ -1231,17 +1867,29 @@ var import_v1020 = require("discord-api-types/v10");
var import_ts_mixer3 = require("ts-mixer");
var numberValidator2 = import_shapeshift9.s.number;
var SlashCommandNumberOption = class extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
type = import_v1020.ApplicationCommandOptionType.Number;
+ /**
+ * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMaxValue}
+ */
setMaxValue(max) {
numberValidator2.parse(max);
Reflect.set(this, "max_value", max);
return this;
}
+ /**
+ * {@inheritDoc ApplicationCommandNumericOptionMinMaxValueMixin.setMinValue}
+ */
setMinValue(min) {
numberValidator2.parse(min);
Reflect.set(this, "min_value", min);
return this;
}
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON() {
this.runRequiredValidations();
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
@@ -1258,7 +1906,13 @@ SlashCommandNumberOption = __decorateClass([
// src/interactions/slashCommands/options/role.ts
var import_v1021 = require("discord-api-types/v10");
var SlashCommandRoleOption = class extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
type = import_v1021.ApplicationCommandOptionType.Role;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON() {
this.runRequiredValidations();
return { ...this };
@@ -1273,19 +1927,41 @@ var import_ts_mixer4 = require("ts-mixer");
var minLengthValidator2 = import_shapeshift10.s.number.greaterThanOrEqual(0).lessThanOrEqual(6e3);
var maxLengthValidator2 = import_shapeshift10.s.number.greaterThanOrEqual(1).lessThanOrEqual(6e3);
var SlashCommandStringOption = class extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
type = import_v1022.ApplicationCommandOptionType.String;
+ /**
+ * The maximum length of this option.
+ */
max_length;
+ /**
+ * The minimum length of this option.
+ */
min_length;
+ /**
+ * Sets the maximum length of this string option.
+ *
+ * @param max - The maximum length this option can be
+ */
setMaxLength(max) {
maxLengthValidator2.parse(max);
Reflect.set(this, "max_length", max);
return this;
}
+ /**
+ * Sets the minimum length of this string option.
+ *
+ * @param min - The minimum length this option can be
+ */
setMinLength(min) {
minLengthValidator2.parse(min);
Reflect.set(this, "min_length", min);
return this;
}
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON() {
this.runRequiredValidations();
if (this.autocomplete && Array.isArray(this.choices) && this.choices.length > 0) {
@@ -1302,7 +1978,13 @@ SlashCommandStringOption = __decorateClass([
// src/interactions/slashCommands/options/user.ts
var import_v1023 = require("discord-api-types/v10");
var SlashCommandUserOption = class extends ApplicationCommandOptionBase {
+ /**
+ * The type of this option.
+ */
type = import_v1023.ApplicationCommandOptionType.User;
+ /**
+ * {@inheritDoc ApplicationCommandOptionBase.toJSON}
+ */
toJSON() {
this.runRequiredValidations();
return { ...this };
@@ -1313,33 +1995,85 @@ __name(SlashCommandUserOption, "SlashCommandUserOption");
// src/interactions/slashCommands/mixins/SharedSlashCommandOptions.ts
var SharedSlashCommandOptions = class {
options;
+ /**
+ * Adds a boolean option.
+ *
+ * @param input - A function that returns an option builder or an already built builder
+ */
addBooleanOption(input) {
return this._sharedAddOptionMethod(input, SlashCommandBooleanOption);
}
+ /**
+ * Adds a user option.
+ *
+ * @param input - A function that returns an option builder or an already built builder
+ */
addUserOption(input) {
return this._sharedAddOptionMethod(input, SlashCommandUserOption);
}
+ /**
+ * Adds a channel option.
+ *
+ * @param input - A function that returns an option builder or an already built builder
+ */
addChannelOption(input) {
return this._sharedAddOptionMethod(input, SlashCommandChannelOption);
}
+ /**
+ * Adds a role option.
+ *
+ * @param input - A function that returns an option builder or an already built builder
+ */
addRoleOption(input) {
return this._sharedAddOptionMethod(input, SlashCommandRoleOption);
}
+ /**
+ * Adds an attachment option.
+ *
+ * @param input - A function that returns an option builder or an already built builder
+ */
addAttachmentOption(input) {
return this._sharedAddOptionMethod(input, SlashCommandAttachmentOption);
}
+ /**
+ * Adds a mentionable option.
+ *
+ * @param input - A function that returns an option builder or an already built builder
+ */
addMentionableOption(input) {
return this._sharedAddOptionMethod(input, SlashCommandMentionableOption);
}
+ /**
+ * Adds a string option.
+ *
+ * @param input - A function that returns an option builder or an already built builder
+ */
addStringOption(input) {
return this._sharedAddOptionMethod(input, SlashCommandStringOption);
}
+ /**
+ * Adds an integer option.
+ *
+ * @param input - A function that returns an option builder or an already built builder
+ */
addIntegerOption(input) {
return this._sharedAddOptionMethod(input, SlashCommandIntegerOption);
}
+ /**
+ * Adds a number option.
+ *
+ * @param input - A function that returns an option builder or an already built builder
+ */
addNumberOption(input) {
return this._sharedAddOptionMethod(input, SlashCommandNumberOption);
}
+ /**
+ * Where the actual adding magic happens. ✨
+ *
+ * @param input - The input. What else?
+ * @param Instance - The instance of whatever is being added
+ * @internal
+ */
_sharedAddOptionMethod(input, Instance) {
const { options } = this;
validateMaxOptionsLength(options);
@@ -1353,9 +2087,23 @@ __name(SharedSlashCommandOptions, "SharedSlashCommandOptions");
// src/interactions/slashCommands/SlashCommandSubcommands.ts
var SlashCommandSubcommandGroupBuilder = class {
+ /**
+ * The name of this subcommand group.
+ */
name = void 0;
+ /**
+ * The description of this subcommand group.
+ */
description = void 0;
+ /**
+ * The subcommands within this subcommand group.
+ */
options = [];
+ /**
+ * Adds a new subcommand to this group.
+ *
+ * @param input - A function that returns a subcommand builder or an already built builder
+ */
addSubcommand(input) {
const { options } = this;
validateMaxOptionsLength(options);
@@ -1364,6 +2112,13 @@ var SlashCommandSubcommandGroupBuilder = class {
options.push(result);
return this;
}
+ /**
+ * Serializes this builder to API-compatible JSON data.
+ *
+ * @remarks
+ * This method runs validations on the data before serializing it.
+ * As such, it may throw an error if the data is invalid.
+ */
toJSON() {
validateRequiredParameters3(this.name, this.description, this.options);
return {
@@ -1381,9 +2136,25 @@ SlashCommandSubcommandGroupBuilder = __decorateClass([
(0, import_ts_mixer5.mix)(SharedNameAndDescription)
], SlashCommandSubcommandGroupBuilder);
var SlashCommandSubcommandBuilder = class {
+ /**
+ * The name of this subcommand.
+ */
name = void 0;
+ /**
+ * The description of this subcommand.
+ */
description = void 0;
+ /**
+ * The options within this subcommand.
+ */
options = [];
+ /**
+ * Serializes this builder to API-compatible JSON data.
+ *
+ * @remarks
+ * This method runs validations on the data before serializing it.
+ * As such, it may throw an error if the data is invalid.
+ */
toJSON() {
validateRequiredParameters3(this.name, this.description, this.options);
return {
@@ -1403,38 +2174,102 @@ SlashCommandSubcommandBuilder = __decorateClass([
// src/interactions/slashCommands/SlashCommandBuilder.ts
var SlashCommandBuilder = class {
+ /**
+ * The name of this command.
+ */
name = void 0;
+ /**
+ * The name localizations of this command.
+ */
name_localizations;
+ /**
+ * The description of this command.
+ */
description = void 0;
+ /**
+ * The description localizations of this command.
+ */
description_localizations;
+ /**
+ * The options of this command.
+ */
options = [];
+ /**
+ * Whether this command is enabled by default when the application is added to a guild.
+ *
+ * @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
+ */
default_permission = void 0;
+ /**
+ * The set of permissions represented as a bit set for the command.
+ */
default_member_permissions = void 0;
+ /**
+ * Indicates whether the command is available in direct messages with the application.
+ *
+ * @remarks
+ * By default, commands are visible. This property is only for global commands.
+ */
dm_permission = void 0;
- toJSON() {
- validateRequiredParameters3(this.name, this.description, this.options);
- validateLocalizationMap(this.name_localizations);
- validateLocalizationMap(this.description_localizations);
- return {
- ...this,
- options: this.options.map((option) => option.toJSON())
- };
- }
+ /**
+ * Whether this command is NSFW.
+ */
+ nsfw = void 0;
+ /**
+ * Sets whether the command is enabled by default when the application is added to a guild.
+ *
+ * @remarks
+ * If set to `false`, you will have to later `PUT` the permissions for this command.
+ * @param value - Whether or not to enable this command by default
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ * @deprecated Use {@link SlashCommandBuilder.setDefaultMemberPermissions} or {@link SlashCommandBuilder.setDMPermission} instead.
+ */
setDefaultPermission(value) {
validateDefaultPermission(value);
Reflect.set(this, "default_permission", value);
return this;
}
+ /**
+ * Sets the default permissions a member should have in order to run the command.
+ *
+ * @remarks
+ * You can set this to `'0'` to disable the command by default.
+ * @param permissions - The permissions bit field to set
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ */
setDefaultMemberPermissions(permissions) {
const permissionValue = validateDefaultMemberPermissions(permissions);
Reflect.set(this, "default_member_permissions", permissionValue);
return this;
}
+ /**
+ * Sets if the command is available in direct messages with the application.
+ *
+ * @remarks
+ * By default, commands are visible. This method is only for global commands.
+ * @param enabled - Whether the command should be enabled in direct messages
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ */
setDMPermission(enabled) {
validateDMPermission(enabled);
Reflect.set(this, "dm_permission", enabled);
return this;
}
+ /**
+ * Sets whether this command is NSFW.
+ *
+ * @param nsfw - Whether this command is NSFW
+ */
+ setNSFW(nsfw = true) {
+ validateNSFW(nsfw);
+ Reflect.set(this, "nsfw", nsfw);
+ return this;
+ }
+ /**
+ * Adds a new subcommand group to this command.
+ *
+ * @param input - A function that returns a subcommand group builder or an already built builder
+ */
addSubcommandGroup(input) {
const { options } = this;
validateMaxOptionsLength(options);
@@ -1443,6 +2278,11 @@ var SlashCommandBuilder = class {
options.push(result);
return this;
}
+ /**
+ * Adds a new subcommand to this command.
+ *
+ * @param input - A function that returns a subcommand builder or an already built builder
+ */
addSubcommand(input) {
const { options } = this;
validateMaxOptionsLength(options);
@@ -1451,6 +2291,22 @@ var SlashCommandBuilder = class {
options.push(result);
return this;
}
+ /**
+ * Serializes this builder to API-compatible JSON data.
+ *
+ * @remarks
+ * This method runs validations on the data before serializing it.
+ * As such, it may throw an error if the data is invalid.
+ */
+ toJSON() {
+ validateRequiredParameters3(this.name, this.description, this.options);
+ validateLocalizationMap(this.name_localizations);
+ validateLocalizationMap(this.description_localizations);
+ return {
+ ...this,
+ options: this.options.map((option) => option.toJSON())
+ };
+ }
};
__name(SlashCommandBuilder, "SlashCommandBuilder");
SlashCommandBuilder = __decorateClass([
@@ -1506,37 +2362,101 @@ __name(validateDefaultMemberPermissions2, "validateDefaultMemberPermissions");
// src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts
var ContextMenuCommandBuilder = class {
+ /**
+ * The name of this command.
+ */
name = void 0;
+ /**
+ * The name localizations of this command.
+ */
name_localizations;
+ /**
+ * The type of this command.
+ */
type = void 0;
+ /**
+ * Whether this command is enabled by default when the application is added to a guild.
+ *
+ * @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
+ */
default_permission = void 0;
+ /**
+ * The set of permissions represented as a bit set for the command.
+ */
default_member_permissions = void 0;
+ /**
+ * Indicates whether the command is available in direct messages with the application.
+ *
+ * @remarks
+ * By default, commands are visible. This property is only for global commands.
+ */
dm_permission = void 0;
+ /**
+ * Sets the name of this command.
+ *
+ * @param name - The name to use
+ */
setName(name) {
validateName2(name);
Reflect.set(this, "name", name);
return this;
}
+ /**
+ * Sets the type of this command.
+ *
+ * @param type - The type to use
+ */
setType(type) {
validateType(type);
Reflect.set(this, "type", type);
return this;
}
+ /**
+ * Sets whether the command is enabled by default when the application is added to a guild.
+ *
+ * @remarks
+ * If set to `false`, you will have to later `PUT` the permissions for this command.
+ * @param value - Whether to enable this command by default
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ * @deprecated Use {@link ContextMenuCommandBuilder.setDefaultMemberPermissions} or {@link ContextMenuCommandBuilder.setDMPermission} instead.
+ */
setDefaultPermission(value) {
validateDefaultPermission2(value);
Reflect.set(this, "default_permission", value);
return this;
}
+ /**
+ * Sets the default permissions a member should have in order to run this command.
+ *
+ * @remarks
+ * You can set this to `'0'` to disable the command by default.
+ * @param permissions - The permissions bit field to set
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ */
setDefaultMemberPermissions(permissions) {
const permissionValue = validateDefaultMemberPermissions2(permissions);
Reflect.set(this, "default_member_permissions", permissionValue);
return this;
}
+ /**
+ * Sets if the command is available in direct messages with the application.
+ *
+ * @remarks
+ * By default, commands are visible. This method is only for global commands.
+ * @param enabled - Whether the command should be enabled in direct messages
+ * @see {@link https://discord.com/developers/docs/interactions/application-commands#permissions}
+ */
setDMPermission(enabled) {
validateDMPermission2(enabled);
Reflect.set(this, "dm_permission", enabled);
return this;
}
+ /**
+ * Sets a name localization for this command.
+ *
+ * @param locale - The locale to set
+ * @param localizedName - The localized name for the given `locale`
+ */
setNameLocalization(locale, localizedName) {
if (!this.name_localizations) {
Reflect.set(this, "name_localizations", {});
@@ -1550,6 +2470,11 @@ var ContextMenuCommandBuilder = class {
this.name_localizations[parsedLocale] = localizedName;
return this;
}
+ /**
+ * Sets the name localizations for this command.
+ *
+ * @param localizedNames - The object of localized names to set
+ */
setNameLocalizations(localizedNames) {
if (localizedNames === null) {
Reflect.set(this, "name_localizations", null);
@@ -1560,6 +2485,13 @@ var ContextMenuCommandBuilder = class {
this.setNameLocalization(...args);
return this;
}
+ /**
+ * Serializes this builder to API-compatible JSON data.
+ *
+ * @remarks
+ * This method runs validations on the data before serializing it.
+ * As such, it may throw an error if the data is invalid.
+ */
toJSON() {
validateRequiredParameters4(this.name, this.type);
validateLocalizationMap(this.name_localizations);
@@ -1575,8 +2507,7 @@ function embedLength(data) {
__name(embedLength, "embedLength");
// src/index.ts
-__reExport(src_exports, require("@discordjs/util"), module.exports);
-var version = "1.4.0";
+var version = "1.6.3";
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
ActionRowBuilder,
@@ -1593,7 +2524,6 @@ var version = "1.4.0";
ContextMenuCommandBuilder,
EmbedAssertions,
EmbedBuilder,
- Faces,
MentionableSelectMenuBuilder,
ModalAssertions,
ModalBuilder,
@@ -1619,33 +2549,14 @@ var version = "1.4.0";
StringSelectMenuOptionBuilder,
TextInputAssertions,
TextInputBuilder,
- TimestampStyles,
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
+ version,
+ ...require("@discordjs/formatters")
});
//# sourceMappingURL=index.js.map
\ No newline at end of file
diff --git a/node_modules/@discordjs/builders/dist/index.js.map b/node_modules/@discordjs/builders/dist/index.js.map
index 0e76328..11b933a 100644
--- a/node_modules/@discordjs/builders/dist/index.js.map
+++ b/node_modules/@discordjs/builders/dist/index.js.map
@@ -1 +1 @@
-{"version":3,"sources":["../src/index.ts","../src/messages/embed/Assertions.ts","../src/util/validation.ts","../src/util/normalizeArray.ts","../src/messages/embed/Embed.ts","../src/messages/formatters.ts","../src/components/Assertions.ts","../src/components/selectMenu/StringSelectMenuOption.ts","../src/components/ActionRow.ts","../src/components/Component.ts","../src/components/Components.ts","../src/components/button/Button.ts","../src/components/selectMenu/ChannelSelectMenu.ts","../src/components/selectMenu/BaseSelectMenu.ts","../src/components/selectMenu/MentionableSelectMenu.ts","../src/components/selectMenu/RoleSelectMenu.ts","../src/components/selectMenu/StringSelectMenu.ts","../src/components/selectMenu/UserSelectMenu.ts","../src/components/textInput/TextInput.ts","../src/components/textInput/Assertions.ts","../src/interactions/modals/Assertions.ts","../src/interactions/modals/Modal.ts","../src/interactions/slashCommands/Assertions.ts","../src/interactions/slashCommands/SlashCommandBuilder.ts","../src/interactions/slashCommands/SlashCommandSubcommands.ts","../src/interactions/slashCommands/mixins/NameAndDescription.ts","../src/interactions/slashCommands/options/attachment.ts","../src/interactions/slashCommands/mixins/ApplicationCommandOptionBase.ts","../src/interactions/slashCommands/options/boolean.ts","../src/interactions/slashCommands/options/channel.ts","../src/interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.ts","../src/interactions/slashCommands/options/integer.ts","../src/interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.ts","../src/interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.ts","../src/interactions/slashCommands/options/mentionable.ts","../src/interactions/slashCommands/options/number.ts","../src/interactions/slashCommands/options/role.ts","../src/interactions/slashCommands/options/string.ts","../src/interactions/slashCommands/options/user.ts","../src/interactions/slashCommands/mixins/SharedSlashCommandOptions.ts","../src/interactions/contextMenuCommands/Assertions.ts","../src/interactions/contextMenuCommands/ContextMenuCommandBuilder.ts","../src/util/componentUtil.ts"],"sourcesContent":["export * as EmbedAssertions from './messages/embed/Assertions.js';\nexport * from './messages/embed/Embed.js';\nexport * from './messages/formatters.js';\n\nexport * as ComponentAssertions from './components/Assertions.js';\nexport * from './components/ActionRow.js';\nexport * from './components/button/Button.js';\nexport * from './components/Component.js';\nexport * from './components/Components.js';\nexport * from './components/textInput/TextInput.js';\nexport * as TextInputAssertions from './components/textInput/Assertions.js';\nexport * from './interactions/modals/Modal.js';\nexport * as ModalAssertions from './interactions/modals/Assertions.js';\n\nexport * from './components/selectMenu/BaseSelectMenu.js';\nexport * from './components/selectMenu/ChannelSelectMenu.js';\nexport * from './components/selectMenu/MentionableSelectMenu.js';\nexport * from './components/selectMenu/RoleSelectMenu.js';\nexport * from './components/selectMenu/StringSelectMenu.js';\n// TODO: Remove those aliases in v2\nexport {\n\t/**\n\t * @deprecated Will be removed in the next major version, use {@link StringSelectMenuBuilder} instead.\n\t */\n\tStringSelectMenuBuilder as SelectMenuBuilder,\n} from './components/selectMenu/StringSelectMenu.js';\nexport {\n\t/**\n\t * @deprecated Will be removed in the next major version, use {@link StringSelectMenuOptionBuilder} instead.\n\t */\n\tStringSelectMenuOptionBuilder as SelectMenuOptionBuilder,\n} from './components/selectMenu/StringSelectMenuOption.js';\nexport * from './components/selectMenu/StringSelectMenuOption.js';\nexport * from './components/selectMenu/UserSelectMenu.js';\n\nexport * as SlashCommandAssertions from './interactions/slashCommands/Assertions.js';\nexport * from './interactions/slashCommands/SlashCommandBuilder.js';\nexport * from './interactions/slashCommands/SlashCommandSubcommands.js';\nexport * from './interactions/slashCommands/options/boolean.js';\nexport * from './interactions/slashCommands/options/channel.js';\nexport * from './interactions/slashCommands/options/integer.js';\nexport * from './interactions/slashCommands/options/mentionable.js';\nexport * from './interactions/slashCommands/options/number.js';\nexport * from './interactions/slashCommands/options/role.js';\nexport * from './interactions/slashCommands/options/attachment.js';\nexport * from './interactions/slashCommands/options/string.js';\nexport * from './interactions/slashCommands/options/user.js';\nexport * from './interactions/slashCommands/mixins/ApplicationCommandNumericOptionMinMaxValueMixin.js';\nexport * from './interactions/slashCommands/mixins/ApplicationCommandOptionBase.js';\nexport * from './interactions/slashCommands/mixins/ApplicationCommandOptionChannelTypesMixin.js';\nexport * from './interactions/slashCommands/mixins/ApplicationCommandOptionWithChoicesAndAutocompleteMixin.js';\nexport * from './interactions/slashCommands/mixins/NameAndDescription.js';\nexport * from './interactions/slashCommands/mixins/SharedSlashCommandOptions.js';\n\nexport * as ContextMenuCommandAssertions from './interactions/contextMenuCommands/Assertions.js';\nexport * from './interactions/contextMenuCommands/ContextMenuCommandBuilder.js';\n\nexport * from './util/componentUtil.js';\nexport * from './util/normalizeArray.js';\nexport * from './util/validation.js';\nexport * from '@discordjs/util';\n\n/**\n * The {@link https://github.com/discordjs/discord.js/blob/main/packages/builders/#readme | @discordjs/builders} version\n * that you are currently using.\n */\n// This needs to explicitly be `string` so it is not typed as a \"const string\" that gets injected by esbuild\n// eslint-disable-next-line @typescript-eslint/no-inferrable-types\nexport const version: string = '1.4.0';\n","import { s } from '@sapphire/shapeshift';\nimport type { APIEmbedField } from 'discord-api-types/v10';\nimport { isValidationEnabled } from '../../util/validation.js';\n\nexport const fieldNamePredicate = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(256)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const fieldValuePredicate = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(1_024)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const fieldInlinePredicate = s.boolean.optional;\n\nexport const embedFieldPredicate = s\n\t.object({\n\t\tname: fieldNamePredicate,\n\t\tvalue: fieldValuePredicate,\n\t\tinline: fieldInlinePredicate,\n\t})\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const embedFieldsArrayPredicate = embedFieldPredicate.array.setValidationEnabled(isValidationEnabled);\n\nexport const fieldLengthPredicate = s.number.lessThanOrEqual(25).setValidationEnabled(isValidationEnabled);\n\nexport function validateFieldLength(amountAdding: number, fields?: APIEmbedField[]): void {\n\tfieldLengthPredicate.parse((fields?.length ?? 0) + amountAdding);\n}\n\nexport const authorNamePredicate = fieldNamePredicate.nullable.setValidationEnabled(isValidationEnabled);\n\nexport const imageURLPredicate = s.string\n\t.url({\n\t\tallowedProtocols: ['http:', 'https:', 'attachment:'],\n\t})\n\t.nullish.setValidationEnabled(isValidationEnabled);\n\nexport const urlPredicate = s.string\n\t.url({\n\t\tallowedProtocols: ['http:', 'https:'],\n\t})\n\t.nullish.setValidationEnabled(isValidationEnabled);\n\nexport const embedAuthorPredicate = s\n\t.object({\n\t\tname: authorNamePredicate,\n\t\ticonURL: imageURLPredicate,\n\t\turl: urlPredicate,\n\t})\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const RGBPredicate = s.number.int\n\t.greaterThanOrEqual(0)\n\t.lessThanOrEqual(255)\n\t.setValidationEnabled(isValidationEnabled);\nexport const colorPredicate = s.number.int\n\t.greaterThanOrEqual(0)\n\t.lessThanOrEqual(0xffffff)\n\t.or(s.tuple([RGBPredicate, RGBPredicate, RGBPredicate]))\n\t.nullable.setValidationEnabled(isValidationEnabled);\n\nexport const descriptionPredicate = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(4_096)\n\t.nullable.setValidationEnabled(isValidationEnabled);\n\nexport const footerTextPredicate = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(2_048)\n\t.nullable.setValidationEnabled(isValidationEnabled);\n\nexport const embedFooterPredicate = s\n\t.object({\n\t\ttext: footerTextPredicate,\n\t\ticonURL: imageURLPredicate,\n\t})\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const timestampPredicate = s.union(s.number, s.date).nullable.setValidationEnabled(isValidationEnabled);\n\nexport const titlePredicate = fieldNamePredicate.nullable.setValidationEnabled(isValidationEnabled);\n","let validate = true;\n\nexport const enableValidators = () => (validate = true);\nexport const disableValidators = () => (validate = false);\nexport const isValidationEnabled = () => validate;\n","export function normalizeArray(arr: RestOrArray): T[] {\n\tif (Array.isArray(arr[0])) return arr[0];\n\treturn arr as T[];\n}\n\nexport type RestOrArray = T[] | [T[]];\n","import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage } from 'discord-api-types/v10';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray.js';\nimport {\n\tcolorPredicate,\n\tdescriptionPredicate,\n\tembedAuthorPredicate,\n\tembedFieldsArrayPredicate,\n\tembedFooterPredicate,\n\timageURLPredicate,\n\ttimestampPredicate,\n\ttitlePredicate,\n\turlPredicate,\n\tvalidateFieldLength,\n} from './Assertions.js';\n\nexport type RGBTuple = [red: number, green: number, blue: number];\n\nexport interface IconData {\n\t/**\n\t * The URL of the icon\n\t */\n\ticonURL?: string;\n\t/**\n\t * The proxy URL of the icon\n\t */\n\tproxyIconURL?: string;\n}\n\nexport type EmbedAuthorData = IconData & Omit;\n\nexport type EmbedAuthorOptions = Omit;\n\nexport type EmbedFooterData = IconData & Omit;\n\nexport type EmbedFooterOptions = Omit;\n\nexport interface EmbedImageData extends Omit {\n\t/**\n\t * The proxy URL for the image\n\t */\n\tproxyURL?: string;\n}\n/**\n * Represents a embed in a message (image/video preview, rich embed, etc.)\n */\nexport class EmbedBuilder {\n\tpublic readonly data: APIEmbed;\n\n\tpublic constructor(data: APIEmbed = {}) {\n\t\tthis.data = { ...data };\n\t\tif (data.timestamp) this.data.timestamp = new Date(data.timestamp).toISOString();\n\t}\n\n\t/**\n\t * Appends fields to the embed\n\t *\n\t * @remarks\n\t * This method accepts either an array of fields or a variable number of field parameters.\n\t * The maximum amount of fields that can be added is 25.\n\t * @example\n\t * Using an array\n\t * ```ts\n\t * const fields: APIEmbedField[] = ...;\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(fields);\n\t * ```\n\t * @example\n\t * Using rest parameters (variadic)\n\t * ```ts\n\t * const embed = new EmbedBuilder()\n\t * \t.addFields(\n\t * \t\t{ name: 'Field 1', value: 'Value 1' },\n\t * \t\t{ name: 'Field 2', value: 'Value 2' },\n\t * \t);\n\t * ```\n\t * @param fields - The fields to add\n\t */\n\tpublic addFields(...fields: RestOrArray): this {\n\t\t// eslint-disable-next-line no-param-reassign\n\t\tfields = normalizeArray(fields);\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\n\t\tif (this.data.fields) this.data.fields.push(...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Removes, replaces, or inserts fields in the embed.\n\t *\n\t * @remarks\n\t * This method behaves similarly\n\t * to {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice | Array.prototype.splice}.\n\t * The maximum amount of fields that can be added is 25.\n\t *\n\t * It's useful for modifying and adjusting order of the already-existing fields of an embed.\n\t * @example\n\t * Remove the first field\n\t * ```ts\n\t * embed.spliceFields(0, 1);\n\t * ```\n\t * @example\n\t * Remove the first n fields\n\t * ```ts\n\t * const n = 4\n\t * embed.spliceFields(0, n);\n\t * ```\n\t * @example\n\t * Remove the last field\n\t * ```ts\n\t * embed.spliceFields(-1, 1);\n\t * ```\n\t * @param index - The index to start at\n\t * @param deleteCount - The number of fields to remove\n\t * @param fields - The replacing field objects\n\t */\n\tpublic spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this {\n\t\t// Ensure adding these fields won't exceed the 25 field limit\n\t\tvalidateFieldLength(fields.length - deleteCount, this.data.fields);\n\n\t\t// Data assertions\n\t\tembedFieldsArrayPredicate.parse(fields);\n\t\tif (this.data.fields) this.data.fields.splice(index, deleteCount, ...fields);\n\t\telse this.data.fields = fields;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the embed's fields\n\t *\n\t * @remarks\n\t * This method is an alias for {@link EmbedBuilder.spliceFields}. More specifically,\n\t * it splices the entire array of fields, replacing them with the provided fields.\n\t *\n\t * You can set a maximum of 25 fields.\n\t * @param fields - The fields to set\n\t */\n\tpublic setFields(...fields: RestOrArray) {\n\t\tthis.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the author of this embed\n\t *\n\t * @param options - The options for the author\n\t */\n\n\tpublic setAuthor(options: EmbedAuthorOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.author = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedAuthorPredicate.parse(options);\n\n\t\tthis.data.author = { name: options.name, url: options.url, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the color of this embed\n\t *\n\t * @param color - The color of the embed\n\t */\n\tpublic setColor(color: RGBTuple | number | null): this {\n\t\t// Data assertions\n\t\tcolorPredicate.parse(color);\n\n\t\tif (Array.isArray(color)) {\n\t\t\tconst [red, green, blue] = color;\n\t\t\tthis.data.color = (red << 16) + (green << 8) + blue;\n\t\t\treturn this;\n\t\t}\n\n\t\tthis.data.color = color ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this embed\n\t *\n\t * @param description - The description\n\t */\n\tpublic setDescription(description: string | null): this {\n\t\t// Data assertions\n\t\tdescriptionPredicate.parse(description);\n\n\t\tthis.data.description = description ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the footer of this embed\n\t *\n\t * @param options - The options for the footer\n\t */\n\tpublic setFooter(options: EmbedFooterOptions | null): this {\n\t\tif (options === null) {\n\t\t\tthis.data.footer = undefined;\n\t\t\treturn this;\n\t\t}\n\n\t\t// Data assertions\n\t\tembedFooterPredicate.parse(options);\n\n\t\tthis.data.footer = { text: options.text, icon_url: options.iconURL };\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the image of this embed\n\t *\n\t * @param url - The URL of the image\n\t */\n\tpublic setImage(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.image = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the thumbnail of this embed\n\t *\n\t * @param url - The URL of the thumbnail\n\t */\n\tpublic setThumbnail(url: string | null): this {\n\t\t// Data assertions\n\t\timageURLPredicate.parse(url);\n\n\t\tthis.data.thumbnail = url ? { url } : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the timestamp of this embed\n\t *\n\t * @param timestamp - The timestamp or date\n\t */\n\tpublic setTimestamp(timestamp: Date | number | null = Date.now()): this {\n\t\t// Data assertions\n\t\ttimestampPredicate.parse(timestamp);\n\n\t\tthis.data.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the title of this embed\n\t *\n\t * @param title - The title\n\t */\n\tpublic setTitle(title: string | null): this {\n\t\t// Data assertions\n\t\ttitlePredicate.parse(title);\n\n\t\tthis.data.title = title ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL of this embed\n\t *\n\t * @param url - The URL\n\t */\n\tpublic setURL(url: string | null): this {\n\t\t// Data assertions\n\t\turlPredicate.parse(url);\n\n\t\tthis.data.url = url ?? undefined;\n\t\treturn this;\n\t}\n\n\t/**\n\t * Transforms the embed to a plain object\n\t */\n\tpublic toJSON(): APIEmbed {\n\t\treturn { ...this.data };\n\t}\n}\n","import type { URL } from 'node:url';\nimport type { Snowflake } from 'discord-api-types/globals';\n\n/**\n * Wraps the content inside a codeblock with no language\n *\n * @param content - The content to wrap\n */\nexport function codeBlock(content: C): `\\`\\`\\`\\n${C}\\n\\`\\`\\``;\n\n/**\n * Wraps the content inside a codeblock with the specified language\n *\n * @param language - The language for the codeblock\n * @param content - The content to wrap\n */\nexport function codeBlock(language: L, content: C): `\\`\\`\\`${L}\\n${C}\\n\\`\\`\\``;\nexport function codeBlock(language: string, content?: string): string {\n\treturn typeof content === 'undefined' ? `\\`\\`\\`\\n${language}\\n\\`\\`\\`` : `\\`\\`\\`${language}\\n${content}\\n\\`\\`\\``;\n}\n\n/**\n * Wraps the content inside \\`backticks\\`, which formats it as inline code\n *\n * @param content - The content to wrap\n */\nexport function inlineCode(content: C): `\\`${C}\\`` {\n\treturn `\\`${content}\\``;\n}\n\n/**\n * Formats the content into italic text\n *\n * @param content - The content to wrap\n */\nexport function italic(content: C): `_${C}_` {\n\treturn `_${content}_`;\n}\n\n/**\n * Formats the content into bold text\n *\n * @param content - The content to wrap\n */\nexport function bold(content: C): `**${C}**` {\n\treturn `**${content}**`;\n}\n\n/**\n * Formats the content into underscored text\n *\n * @param content - The content to wrap\n */\nexport function underscore(content: C): `__${C}__` {\n\treturn `__${content}__`;\n}\n\n/**\n * Formats the content into strike-through text\n *\n * @param content - The content to wrap\n */\nexport function strikethrough(content: C): `~~${C}~~` {\n\treturn `~~${content}~~`;\n}\n\n/**\n * Formats the content into a quote. This needs to be at the start of the line for Discord to format it\n *\n * @param content - The content to wrap\n */\nexport function quote(content: C): `> ${C}` {\n\treturn `> ${content}`;\n}\n\n/**\n * Formats the content into a block quote. This needs to be at the start of the line for Discord to format it\n *\n * @param content - The content to wrap\n */\nexport function blockQuote(content: C): `>>> ${C}` {\n\treturn `>>> ${content}`;\n}\n\n/**\n * Wraps the URL into `<>`, which stops it from embedding\n *\n * @param url - The URL to wrap\n */\nexport function hideLinkEmbed(url: C): `<${C}>`;\n\n/**\n * Wraps the URL into `<>`, which stops it from embedding\n *\n * @param url - The URL to wrap\n */\nexport function hideLinkEmbed(url: URL): `<${string}>`;\nexport function hideLinkEmbed(url: URL | string) {\n\treturn `<${url}>`;\n}\n\n/**\n * Formats the content and the URL into a masked URL\n *\n * @param content - The content to display\n * @param url - The URL the content links to\n */\nexport function hyperlink(content: C, url: URL): `[${C}](${string})`;\n\n/**\n * Formats the content and the URL into a masked URL\n *\n * @param content - The content to display\n * @param url - The URL the content links to\n */\nexport function hyperlink(content: C, url: U): `[${C}](${U})`;\n\n/**\n * Formats the content and the URL into a masked URL\n *\n * @param content - The content to display\n * @param url - The URL the content links to\n * @param title - The title shown when hovering on the masked link\n */\nexport function hyperlink(\n\tcontent: C,\n\turl: URL,\n\ttitle: T,\n): `[${C}](${string} \"${T}\")`;\n\n/**\n * Formats the content and the URL into a masked URL\n *\n * @param content - The content to display\n * @param url - The URL the content links to\n * @param title - The title shown when hovering on the masked link\n */\nexport function hyperlink(\n\tcontent: C,\n\turl: U,\n\ttitle: T,\n): `[${C}](${U} \"${T}\")`;\nexport function hyperlink(content: string, url: URL | string, title?: string) {\n\treturn title ? `[${content}](${url} \"${title}\")` : `[${content}](${url})`;\n}\n\n/**\n * Wraps the content inside spoiler (hidden text)\n *\n * @param content - The content to wrap\n */\nexport function spoiler(content: C): `||${C}||` {\n\treturn `||${content}||`;\n}\n\n/**\n * Formats a user ID into a user mention\n *\n * @param userId - The user ID to format\n */\nexport function userMention(userId: C): `<@${C}>` {\n\treturn `<@${userId}>`;\n}\n\n/**\n * Formats a channel ID into a channel mention\n *\n * @param channelId - The channel ID to format\n */\nexport function channelMention(channelId: C): `<#${C}>` {\n\treturn `<#${channelId}>`;\n}\n\n/**\n * Formats a role ID into a role mention\n *\n * @param roleId - The role ID to format\n */\nexport function roleMention(roleId: C): `<@&${C}>` {\n\treturn `<@&${roleId}>`;\n}\n\n/**\n * Formats an application command name, subcommand group name, subcommand name, and ID into an application command mention\n *\n * @param commandName - The application command name to format\n * @param subcommandGroupName - The subcommand group name to format\n * @param subcommandName - The subcommand name to format\n * @param commandId - The application command ID to format\n */\nexport function chatInputApplicationCommandMention<\n\tN extends string,\n\tG extends string,\n\tS extends string,\n\tI extends Snowflake,\n>(commandName: N, subcommandGroupName: G, subcommandName: S, commandId: I): `${N} ${G} ${S}:${I}>`;\n\n/**\n * Formats an application command name, subcommand name, and ID into an application command mention\n *\n * @param commandName - The application command name to format\n * @param subcommandName - The subcommand name to format\n * @param commandId - The application command ID to format\n */\nexport function chatInputApplicationCommandMention(\n\tcommandName: N,\n\tsubcommandName: S,\n\tcommandId: I,\n): `${N} ${S}:${I}>`;\n\n/**\n * Formats an application command name and ID into an application command mention\n *\n * @param commandName - The application command name to format\n * @param commandId - The application command ID to format\n */\nexport function chatInputApplicationCommandMention(\n\tcommandName: N,\n\tcommandId: I,\n): `${N}:${I}>`;\n\n/**\n * Formats an application command name, subcommand group name, subcommand name, and ID into an application command mention\n *\n * @param commandName - The application command name to format\n * @param subcommandGroupName - The subcommand group name to format\n * @param subcommandName - The subcommand name to format\n * @param commandId - The application command ID to format\n */\nexport function chatInputApplicationCommandMention<\n\tN extends string,\n\tG extends Snowflake | string,\n\tS extends Snowflake | string,\n\tI extends Snowflake,\n>(\n\tcommandName: N,\n\tsubcommandGroupName: G,\n\tsubcommandName?: S,\n\tcommandId?: I,\n): `${N} ${G} ${S}:${I}>` | `${N} ${G}:${S}>` | `${N}:${G}>` {\n\tif (typeof commandId !== 'undefined') {\n\t\treturn `${commandName} ${subcommandGroupName} ${subcommandName!}:${commandId}>`;\n\t}\n\n\tif (typeof subcommandName !== 'undefined') {\n\t\treturn `${commandName} ${subcommandGroupName}:${subcommandName}>`;\n\t}\n\n\treturn `${commandName}:${subcommandGroupName}>`;\n}\n\n/**\n * Formats an emoji ID into a fully qualified emoji identifier\n *\n * @param emojiId - The emoji ID to format\n */\nexport function formatEmoji(emojiId: C, animated?: false): `<:_:${C}>`;\n\n/**\n * Formats an emoji ID into a fully qualified emoji identifier\n *\n * @param emojiId - The emoji ID to format\n * @param animated - Whether the emoji is animated or not. Defaults to `false`\n */\nexport function formatEmoji(emojiId: C, animated?: true): ``;\n\n/**\n * Formats an emoji ID into a fully qualified emoji identifier\n *\n * @param emojiId - The emoji ID to format\n * @param animated - Whether the emoji is animated or not. Defaults to `false`\n */\nexport function formatEmoji(emojiId: C, animated?: boolean): `<:_:${C}>` | ``;\n\n/**\n * Formats an emoji ID into a fully qualified emoji identifier\n *\n * @param emojiId - The emoji ID to format\n * @param animated - Whether the emoji is animated or not. Defaults to `false`\n */\nexport function formatEmoji(emojiId: C, animated = false): `<:_:${C}>` | `` {\n\treturn `<${animated ? 'a' : ''}:_:${emojiId}>`;\n}\n\n/**\n * Formats a channel link for a direct message channel.\n *\n * @param channelId - The channel's id\n */\nexport function channelLink(channelId: C): `https://discord.com/channels/@me/${C}`;\n\n/**\n * Formats a channel link for a guild channel.\n *\n * @param channelId - The channel's id\n * @param guildId - The guild's id\n */\nexport function channelLink(\n\tchannelId: C,\n\tguildId: G,\n): `https://discord.com/channels/${G}/${C}`;\n\nexport function channelLink(\n\tchannelId: C,\n\tguildId?: G,\n): `https://discord.com/channels/@me/${C}` | `https://discord.com/channels/${G}/${C}` {\n\treturn `https://discord.com/channels/${guildId ?? '@me'}/${channelId}`;\n}\n\n/**\n * Formats a message link for a direct message channel.\n *\n * @param channelId - The channel's id\n * @param messageId - The message's id\n */\nexport function messageLink(\n\tchannelId: C,\n\tmessageId: M,\n): `https://discord.com/channels/@me/${C}/${M}`;\n\n/**\n * Formats a message link for a guild channel.\n *\n * @param channelId - The channel's id\n * @param messageId - The message's id\n * @param guildId - The guild's id\n */\nexport function messageLink(\n\tchannelId: C,\n\tmessageId: M,\n\tguildId: G,\n): `https://discord.com/channels/${G}/${C}/${M}`;\n\nexport function messageLink(\n\tchannelId: C,\n\tmessageId: M,\n\tguildId?: G,\n): `https://discord.com/channels/@me/${C}/${M}` | `https://discord.com/channels/${G}/${C}/${M}` {\n\treturn `${typeof guildId === 'undefined' ? channelLink(channelId) : channelLink(channelId, guildId)}/${messageId}`;\n}\n\n/**\n * Formats a date into a short date-time string\n *\n * @param date - The date to format, defaults to the current time\n */\nexport function time(date?: Date): ``;\n\n/**\n * Formats a date given a format style\n *\n * @param date - The date to format\n * @param style - The style to use\n */\nexport function time(date: Date, style: S): ``;\n\n/**\n * Formats the given timestamp into a short date-time string\n *\n * @param seconds - The time to format, represents an UNIX timestamp in seconds\n */\nexport function time(seconds: C): ``;\n\n/**\n * Formats the given timestamp into a short date-time string\n *\n * @param seconds - The time to format, represents an UNIX timestamp in seconds\n * @param style - The style to use\n */\nexport function time(seconds: C, style: S): ``;\nexport function time(timeOrSeconds?: Date | number, style?: TimestampStylesString): string {\n\tif (typeof timeOrSeconds !== 'number') {\n\t\t// eslint-disable-next-line no-param-reassign\n\t\ttimeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1_000);\n\t}\n\n\treturn typeof style === 'string' ? `` : ``;\n}\n\n/**\n * The {@link https://discord.com/developers/docs/reference#message-formatting-timestamp-styles | message formatting timestamp styles} supported by Discord\n */\nexport const TimestampStyles = {\n\t/**\n\t * Short time format, consisting of hours and minutes, e.g. 16:20\n\t */\n\tShortTime: 't',\n\n\t/**\n\t * Long time format, consisting of hours, minutes, and seconds, e.g. 16:20:30\n\t */\n\tLongTime: 'T',\n\n\t/**\n\t * Short date format, consisting of day, month, and year, e.g. 20/04/2021\n\t */\n\tShortDate: 'd',\n\n\t/**\n\t * Long date format, consisting of day, month, and year, e.g. 20 April 2021\n\t */\n\tLongDate: 'D',\n\n\t/**\n\t * Short date-time format, consisting of short date and short time formats, e.g. 20 April 2021 16:20\n\t */\n\tShortDateTime: 'f',\n\n\t/**\n\t * Long date-time format, consisting of long date and short time formats, e.g. Tuesday, 20 April 2021 16:20\n\t */\n\tLongDateTime: 'F',\n\n\t/**\n\t * Relative time format, consisting of a relative duration format, e.g. 2 months ago\n\t */\n\tRelativeTime: 'R',\n} as const;\n\n/**\n * The possible values, see {@link TimestampStyles} for more information\n */\nexport type TimestampStylesString = typeof TimestampStyles[keyof typeof TimestampStyles];\n\n/**\n * An enum with all the available faces from Discord's native slash commands\n */\nexport enum Faces {\n\t/**\n\t * ¯\\\\_(ツ)\\\\_/¯\n\t */\n\tShrug = '¯\\\\_(ツ)\\\\_/¯',\n\n\t/**\n\t * (╯°□°)╯︵ ┻━┻\n\t */\n\tTableflip = '(╯°□°)╯︵ ┻━┻',\n\n\t/**\n\t * ┬─┬ ノ( ゜-゜ノ)\n\t */\n\tUnflip = '┬─┬ ノ( ゜-゜ノ)',\n}\n","import { s } from '@sapphire/shapeshift';\nimport { ButtonStyle, ChannelType, type APIMessageComponentEmoji } from 'discord-api-types/v10';\nimport { isValidationEnabled } from '../util/validation.js';\nimport { StringSelectMenuOptionBuilder } from './selectMenu/StringSelectMenuOption.js';\n\nexport const customIdValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(100)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const emojiValidator = s\n\t.object({\n\t\tid: s.string,\n\t\tname: s.string,\n\t\tanimated: s.boolean,\n\t})\n\t.partial.strict.setValidationEnabled(isValidationEnabled);\n\nexport const disabledValidator = s.boolean;\n\nexport const buttonLabelValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(80)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const buttonStyleValidator = s.nativeEnum(ButtonStyle);\n\nexport const placeholderValidator = s.string.lengthLessThanOrEqual(150).setValidationEnabled(isValidationEnabled);\nexport const minMaxValidator = s.number.int\n\t.greaterThanOrEqual(0)\n\t.lessThanOrEqual(25)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const labelValueDescriptionValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(100)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const jsonOptionValidator = s\n\t.object({\n\t\tlabel: labelValueDescriptionValidator,\n\t\tvalue: labelValueDescriptionValidator,\n\t\tdescription: labelValueDescriptionValidator.optional,\n\t\temoji: emojiValidator.optional,\n\t\tdefault: s.boolean.optional,\n\t})\n\t.setValidationEnabled(isValidationEnabled);\n\nexport const optionValidator = s.instance(StringSelectMenuOptionBuilder).setValidationEnabled(isValidationEnabled);\n\nexport const optionsValidator = optionValidator.array\n\t.lengthGreaterThanOrEqual(0)\n\t.setValidationEnabled(isValidationEnabled);\nexport const optionsLengthValidator = s.number.int\n\t.greaterThanOrEqual(0)\n\t.lessThanOrEqual(25)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredSelectMenuParameters(options: StringSelectMenuOptionBuilder[], customId?: string) {\n\tcustomIdValidator.parse(customId);\n\toptionsValidator.parse(options);\n}\n\nexport const defaultValidator = s.boolean;\n\nexport function validateRequiredSelectMenuOptionParameters(label?: string, value?: string) {\n\tlabelValueDescriptionValidator.parse(label);\n\tlabelValueDescriptionValidator.parse(value);\n}\n\nexport const channelTypesValidator = s.nativeEnum(ChannelType).array.setValidationEnabled(isValidationEnabled);\n\nexport const urlValidator = s.string\n\t.url({\n\t\tallowedProtocols: ['http:', 'https:', 'discord:'],\n\t})\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredButtonParameters(\n\tstyle?: ButtonStyle,\n\tlabel?: string,\n\temoji?: APIMessageComponentEmoji,\n\tcustomId?: string,\n\turl?: string,\n) {\n\tif (url && customId) {\n\t\tthrow new RangeError('URL and custom id are mutually exclusive');\n\t}\n\n\tif (!label && !emoji) {\n\t\tthrow new RangeError('Buttons must have a label and/or an emoji');\n\t}\n\n\tif (style === ButtonStyle.Link) {\n\t\tif (!url) {\n\t\t\tthrow new RangeError('Link buttons must have a url');\n\t\t}\n\t} else if (url) {\n\t\tthrow new RangeError('Non-link buttons cannot have a url');\n\t}\n}\n","import type { JSONEncodable } from '@discordjs/util';\nimport type { APIMessageComponentEmoji, APISelectMenuOption } from 'discord-api-types/v10';\nimport {\n\tdefaultValidator,\n\temojiValidator,\n\tlabelValueDescriptionValidator,\n\tvalidateRequiredSelectMenuOptionParameters,\n} from '../Assertions.js';\n\n/**\n * Represents an option within a string select menu component\n */\nexport class StringSelectMenuOptionBuilder implements JSONEncodable {\n\t/**\n\t * Creates a new string select menu option from API data\n\t *\n\t * @param data - The API data to create this string select menu option with\n\t * @example\n\t * Creating a string select menu option from an API data object\n\t * ```ts\n\t * const selectMenuOption = new SelectMenuOptionBuilder({\n\t * \tlabel: 'catchy label',\n\t * \tvalue: '1',\n\t * });\n\t * ```\n\t * @example\n\t * Creating a string select menu option using setters and API data\n\t * ```ts\n\t * const selectMenuOption = new SelectMenuOptionBuilder({\n\t * \tdefault: true,\n\t * \tvalue: '1',\n\t * })\n\t * \t.setLabel('woah')\n\t * ```\n\t */\n\tpublic constructor(public data: Partial = {}) {}\n\n\t/**\n\t * Sets the label of this option\n\t *\n\t * @param label - The label to show on this option\n\t */\n\tpublic setLabel(label: string) {\n\t\tthis.data.label = labelValueDescriptionValidator.parse(label);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the value of this option\n\t *\n\t * @param value - The value of this option\n\t */\n\tpublic setValue(value: string) {\n\t\tthis.data.value = labelValueDescriptionValidator.parse(value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the description of this option\n\t *\n\t * @param description - The description of this option\n\t */\n\tpublic setDescription(description: string) {\n\t\tthis.data.description = labelValueDescriptionValidator.parse(description);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether this option is selected by default\n\t *\n\t * @param isDefault - Whether this option is selected by default\n\t */\n\tpublic setDefault(isDefault = true) {\n\t\tthis.data.default = defaultValidator.parse(isDefault);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the emoji to display on this option\n\t *\n\t * @param emoji - The emoji to display on this option\n\t */\n\tpublic setEmoji(emoji: APIMessageComponentEmoji) {\n\t\tthis.data.emoji = emojiValidator.parse(emoji);\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\n\tpublic toJSON(): APISelectMenuOption {\n\t\tvalidateRequiredSelectMenuOptionParameters(this.data.label, this.data.value);\n\n\t\treturn {\n\t\t\t...this.data,\n\t\t} as APISelectMenuOption;\n\t}\n}\n","/* eslint-disable jsdoc/check-param-names */\n\nimport {\n\ttype APIActionRowComponent,\n\tComponentType,\n\ttype APIMessageActionRowComponent,\n\ttype APIModalActionRowComponent,\n\ttype APIActionRowComponentTypes,\n} from 'discord-api-types/v10';\nimport { normalizeArray, type RestOrArray } from '../util/normalizeArray.js';\nimport { ComponentBuilder } from './Component.js';\nimport { createComponentBuilder } from './Components.js';\nimport type { ButtonBuilder } from './button/Button.js';\nimport type { ChannelSelectMenuBuilder } from './selectMenu/ChannelSelectMenu.js';\nimport type { MentionableSelectMenuBuilder } from './selectMenu/MentionableSelectMenu.js';\nimport type { RoleSelectMenuBuilder } from './selectMenu/RoleSelectMenu.js';\nimport type { StringSelectMenuBuilder } from './selectMenu/StringSelectMenu.js';\nimport type { UserSelectMenuBuilder } from './selectMenu/UserSelectMenu.js';\nimport type { TextInputBuilder } from './textInput/TextInput.js';\n\nexport type MessageComponentBuilder =\n\t| ActionRowBuilder\n\t| MessageActionRowComponentBuilder;\nexport type ModalComponentBuilder = ActionRowBuilder | ModalActionRowComponentBuilder;\nexport type MessageActionRowComponentBuilder =\n\t| ButtonBuilder\n\t| ChannelSelectMenuBuilder\n\t| MentionableSelectMenuBuilder\n\t| RoleSelectMenuBuilder\n\t| StringSelectMenuBuilder\n\t| UserSelectMenuBuilder;\nexport type ModalActionRowComponentBuilder = TextInputBuilder;\nexport type AnyComponentBuilder = MessageActionRowComponentBuilder | ModalActionRowComponentBuilder;\n\n/**\n * Represents an action row component\n *\n * @typeParam T - The types of components this action row holds\n */\nexport class ActionRowBuilder extends ComponentBuilder<\n\tAPIActionRowComponent\n> {\n\t/**\n\t * The components within this action row\n\t */\n\tpublic readonly components: T[];\n\n\t/**\n\t * Creates a new action row from API data\n\t *\n\t * @param data - The API data to create this action row with\n\t * @example\n\t * Creating an action row from an API data object\n\t * ```ts\n\t * const actionRow = new ActionRowBuilder({\n\t * \tcomponents: [\n\t * \t\t{\n\t * \t\t\tcustom_id: \"custom id\",\n\t * \t\t\tlabel: \"Type something\",\n\t * \t\t\tstyle: TextInputStyle.Short,\n\t * \t\t\ttype: ComponentType.TextInput,\n\t * \t\t},\n\t * \t],\n\t * });\n\t * ```\n\t * @example\n\t * Creating an action row using setters and API data\n\t * ```ts\n\t * const actionRow = new ActionRowBuilder({\n\t * \tcomponents: [\n\t * \t\t{\n\t * \t\t\tcustom_id: \"custom id\",\n\t * \t\t\tlabel: \"Click me\",\n\t * \t\t\tstyle: ButtonStyle.Primary,\n\t * \t\t\ttype: ComponentType.Button,\n\t * \t\t},\n\t * \t],\n\t * })\n\t * \t.addComponents(button2, button3);\n\t * ```\n\t */\n\tpublic constructor({ components, ...data }: Partial> = {}) {\n\t\tsuper({ type: ComponentType.ActionRow, ...data });\n\t\tthis.components = (components?.map((component) => createComponentBuilder(component)) ?? []) as T[];\n\t}\n\n\t/**\n\t * Adds components to this action row.\n\t *\n\t * @param components - The components to add to this action row.\n\t */\n\tpublic addComponents(...components: RestOrArray) {\n\t\tthis.components.push(...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the components in this action row\n\t *\n\t * @param components - The components to set this row to\n\t */\n\tpublic setComponents(...components: RestOrArray) {\n\t\tthis.components.splice(0, this.components.length, ...normalizeArray(components));\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\n\tpublic toJSON(): APIActionRowComponent> {\n\t\treturn {\n\t\t\t...this.data,\n\t\t\tcomponents: this.components.map((component) => component.toJSON()),\n\t\t} as APIActionRowComponent>;\n\t}\n}\n","import type { JSONEncodable } from '@discordjs/util';\nimport type {\n\tAPIActionRowComponent,\n\tAPIActionRowComponentTypes,\n\tAPIBaseComponent,\n\tComponentType,\n} from 'discord-api-types/v10';\n\nexport type AnyAPIActionRowComponent = APIActionRowComponent | APIActionRowComponentTypes;\n\n/**\n * Represents a discord component\n *\n * @typeParam DataType - The type of internal API data that is stored within the component\n */\nexport abstract class ComponentBuilder<\n\tDataType extends Partial> = APIBaseComponent,\n> implements JSONEncodable\n{\n\t/**\n\t * The API data associated with this component\n\t */\n\tpublic readonly data: Partial;\n\n\t/**\n\t * Serializes this component to an API-compatible JSON object\n\t *\n\t * @remarks\n\t * This method runs validations on the data before serializing it.\n\t * As such, it may throw an error if the data is invalid.\n\t */\n\tpublic abstract toJSON(): AnyAPIActionRowComponent;\n\n\tpublic constructor(data: Partial) {\n\t\tthis.data = data;\n\t}\n}\n","import { ComponentType, type APIMessageComponent, type APIModalComponent } from 'discord-api-types/v10';\nimport {\n\tActionRowBuilder,\n\ttype AnyComponentBuilder,\n\ttype MessageComponentBuilder,\n\ttype ModalComponentBuilder,\n} from './ActionRow.js';\nimport { ComponentBuilder } from './Component.js';\nimport { ButtonBuilder } from './button/Button.js';\nimport { ChannelSelectMenuBuilder } from './selectMenu/ChannelSelectMenu.js';\nimport { MentionableSelectMenuBuilder } from './selectMenu/MentionableSelectMenu.js';\nimport { RoleSelectMenuBuilder } from './selectMenu/RoleSelectMenu.js';\nimport { StringSelectMenuBuilder } from './selectMenu/StringSelectMenu.js';\nimport { UserSelectMenuBuilder } from './selectMenu/UserSelectMenu.js';\nimport { TextInputBuilder } from './textInput/TextInput.js';\n\nexport interface MappedComponentTypes {\n\t[ComponentType.ActionRow]: ActionRowBuilder;\n\t[ComponentType.Button]: ButtonBuilder;\n\t[ComponentType.StringSelect]: StringSelectMenuBuilder;\n\t[ComponentType.TextInput]: TextInputBuilder;\n\t[ComponentType.UserSelect]: UserSelectMenuBuilder;\n\t[ComponentType.RoleSelect]: RoleSelectMenuBuilder;\n\t[ComponentType.MentionableSelect]: MentionableSelectMenuBuilder;\n\t[ComponentType.ChannelSelect]: ChannelSelectMenuBuilder;\n}\n\n/**\n * Factory for creating components from API data\n *\n * @param data - The api data to transform to a component class\n */\nexport function createComponentBuilder(\n\t// eslint-disable-next-line @typescript-eslint/sort-type-union-intersection-members\n\tdata: (APIModalComponent | APIMessageComponent) & { type: T },\n): MappedComponentTypes[T];\nexport function createComponentBuilder(data: C): C;\nexport function createComponentBuilder(\n\tdata: APIMessageComponent | APIModalComponent | MessageComponentBuilder,\n): ComponentBuilder {\n\tif (data instanceof ComponentBuilder) {\n\t\treturn data;\n\t}\n\n\tswitch (data.type) {\n\t\tcase ComponentType.ActionRow:\n\t\t\treturn new ActionRowBuilder(data);\n\t\tcase ComponentType.Button:\n\t\t\treturn new ButtonBuilder(data);\n\t\tcase ComponentType.StringSelect:\n\t\t\treturn new StringSelectMenuBuilder(data);\n\t\tcase ComponentType.TextInput:\n\t\t\treturn new TextInputBuilder(data);\n\t\tcase ComponentType.UserSelect:\n\t\t\treturn new UserSelectMenuBuilder(data);\n\t\tcase ComponentType.RoleSelect:\n\t\t\treturn new RoleSelectMenuBuilder(data);\n\t\tcase ComponentType.MentionableSelect:\n\t\t\treturn new MentionableSelectMenuBuilder(data);\n\t\tcase ComponentType.ChannelSelect:\n\t\t\treturn new ChannelSelectMenuBuilder(data);\n\t\tdefault:\n\t\t\t// @ts-expect-error: This case can still occur if we get a newer unsupported component type\n\t\t\tthrow new Error(`Cannot properly serialize component type: ${data.type}`);\n\t}\n}\n","import {\n\tComponentType,\n\ttype APIMessageComponentEmoji,\n\ttype APIButtonComponent,\n\ttype APIButtonComponentWithURL,\n\ttype APIButtonComponentWithCustomId,\n\ttype ButtonStyle,\n} from 'discord-api-types/v10';\nimport {\n\tbuttonLabelValidator,\n\tbuttonStyleValidator,\n\tcustomIdValidator,\n\tdisabledValidator,\n\temojiValidator,\n\turlValidator,\n\tvalidateRequiredButtonParameters,\n} from '../Assertions.js';\nimport { ComponentBuilder } from '../Component.js';\n\n/**\n * Represents a button component\n */\nexport class ButtonBuilder extends ComponentBuilder {\n\t/**\n\t * Creates a new button from API data\n\t *\n\t * @param data - The API data to create this button with\n\t * @example\n\t * Creating a button from an API data object\n\t * ```ts\n\t * const button = new ButtonBuilder({\n\t * \tcustom_id: 'a cool button',\n\t * \tstyle: ButtonStyle.Primary,\n\t * \tlabel: 'Click Me',\n\t * \temoji: {\n\t * \t\tname: 'smile',\n\t * \t\tid: '123456789012345678',\n\t * \t},\n\t * });\n\t * ```\n\t * @example\n\t * Creating a button using setters and API data\n\t * ```ts\n\t * const button = new ButtonBuilder({\n\t * \tstyle: ButtonStyle.Secondary,\n\t * \tlabel: 'Click Me',\n\t * })\n\t * \t.setEmoji({ name: '🙂' })\n\t * \t.setCustomId('another cool button');\n\t * ```\n\t */\n\tpublic constructor(data?: Partial) {\n\t\tsuper({ type: ComponentType.Button, ...data });\n\t}\n\n\t/**\n\t * Sets the style of this button\n\t *\n\t * @param style - The style of the button\n\t */\n\tpublic setStyle(style: ButtonStyle) {\n\t\tthis.data.style = buttonStyleValidator.parse(style);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the URL for this button\n\t *\n\t * @remarks\n\t * This method is only available to buttons using the `Link` button style.\n\t * Only three types of URL schemes are currently supported: `https://`, `http://` and `discord://`\n\t * @param url - The URL to open when this button is clicked\n\t */\n\tpublic setURL(url: string) {\n\t\t(this.data as APIButtonComponentWithURL).url = urlValidator.parse(url);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id for this button\n\t *\n\t * @remarks\n\t * This method is only applicable to buttons that are not using the `Link` button style.\n\t * @param customId - The custom id to use for this button\n\t */\n\tpublic setCustomId(customId: string) {\n\t\t(this.data as APIButtonComponentWithCustomId).custom_id = customIdValidator.parse(customId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the emoji to display on this button\n\t *\n\t * @param emoji - The emoji to display on this button\n\t */\n\tpublic setEmoji(emoji: APIMessageComponentEmoji) {\n\t\tthis.data.emoji = emojiValidator.parse(emoji);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether this button is disabled\n\t *\n\t * @param disabled - Whether to disable this button\n\t */\n\tpublic setDisabled(disabled = true) {\n\t\tthis.data.disabled = disabledValidator.parse(disabled);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the label for this button\n\t *\n\t * @param label - The label to display on this button\n\t */\n\tpublic setLabel(label: string) {\n\t\tthis.data.label = buttonLabelValidator.parse(label);\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\n\tpublic toJSON(): APIButtonComponent {\n\t\tvalidateRequiredButtonParameters(\n\t\t\tthis.data.style,\n\t\t\tthis.data.label,\n\t\t\tthis.data.emoji,\n\t\t\t(this.data as APIButtonComponentWithCustomId).custom_id,\n\t\t\t(this.data as APIButtonComponentWithURL).url,\n\t\t);\n\n\t\treturn {\n\t\t\t...this.data,\n\t\t} as APIButtonComponent;\n\t}\n}\n","import type { APIChannelSelectComponent, ChannelType } from 'discord-api-types/v10';\nimport { ComponentType } from 'discord-api-types/v10';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray.js';\nimport { channelTypesValidator, customIdValidator } from '../Assertions.js';\nimport { BaseSelectMenuBuilder } from './BaseSelectMenu.js';\n\nexport class ChannelSelectMenuBuilder extends BaseSelectMenuBuilder {\n\t/**\n\t * Creates a new select menu from API data\n\t *\n\t * @param data - The API data to create this select menu with\n\t * @example\n\t * Creating a select menu from an API data object\n\t * ```ts\n\t * const selectMenu = new ChannelSelectMenuBuilder({\n\t * \tcustom_id: 'a cool select menu',\n\t * \tplaceholder: 'select an option',\n\t * \tmax_values: 2,\n\t * });\n\t * ```\n\t * @example\n\t * Creating a select menu using setters and API data\n\t * ```ts\n\t * const selectMenu = new ChannelSelectMenuBuilder({\n\t * \tcustom_id: 'a cool select menu',\n\t * })\n\t * \t.addChannelTypes(ChannelType.GuildText, ChannelType.GuildAnnouncement)\n\t * \t.setMinValues(2)\n\t * ```\n\t */\n\tpublic constructor(data?: Partial) {\n\t\tsuper({ ...data, type: ComponentType.ChannelSelect });\n\t}\n\n\tpublic addChannelTypes(...types: RestOrArray) {\n\t\t// eslint-disable-next-line no-param-reassign\n\t\ttypes = normalizeArray(types);\n\n\t\tthis.data.channel_types ??= [];\n\t\tthis.data.channel_types.push(...channelTypesValidator.parse(types));\n\t\treturn this;\n\t}\n\n\tpublic setChannelTypes(...types: RestOrArray) {\n\t\t// eslint-disable-next-line no-param-reassign\n\t\ttypes = normalizeArray(types);\n\n\t\tthis.data.channel_types ??= [];\n\t\tthis.data.channel_types.splice(0, this.data.channel_types.length, ...channelTypesValidator.parse(types));\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\n\tpublic override toJSON(): APIChannelSelectComponent {\n\t\tcustomIdValidator.parse(this.data.custom_id);\n\n\t\treturn {\n\t\t\t...this.data,\n\t\t} as APIChannelSelectComponent;\n\t}\n}\n","import type { APISelectMenuComponent } from 'discord-api-types/v10';\nimport { customIdValidator, disabledValidator, minMaxValidator, placeholderValidator } from '../Assertions.js';\nimport { ComponentBuilder } from '../Component.js';\n\nexport class BaseSelectMenuBuilder<\n\tSelectMenuType extends APISelectMenuComponent,\n> extends ComponentBuilder {\n\t/**\n\t * Sets the placeholder for this select menu\n\t *\n\t * @param placeholder - The placeholder to use for this select menu\n\t */\n\tpublic setPlaceholder(placeholder: string) {\n\t\tthis.data.placeholder = placeholderValidator.parse(placeholder);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the minimum values that must be selected in the select menu\n\t *\n\t * @param minValues - The minimum values that must be selected\n\t */\n\tpublic setMinValues(minValues: number) {\n\t\tthis.data.min_values = minMaxValidator.parse(minValues);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum values that must be selected in the select menu\n\t *\n\t * @param maxValues - The maximum values that must be selected\n\t */\n\tpublic setMaxValues(maxValues: number) {\n\t\tthis.data.max_values = minMaxValidator.parse(maxValues);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id for this select menu\n\t *\n\t * @param customId - The custom id to use for this select menu\n\t */\n\tpublic setCustomId(customId: string) {\n\t\tthis.data.custom_id = customIdValidator.parse(customId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether this select menu is disabled\n\t *\n\t * @param disabled - Whether this select menu is disabled\n\t */\n\tpublic setDisabled(disabled = true) {\n\t\tthis.data.disabled = disabledValidator.parse(disabled);\n\t\treturn this;\n\t}\n\n\tpublic toJSON(): SelectMenuType {\n\t\tcustomIdValidator.parse(this.data.custom_id);\n\t\treturn {\n\t\t\t...this.data,\n\t\t} as SelectMenuType;\n\t}\n}\n","import type { APIMentionableSelectComponent } from 'discord-api-types/v10';\nimport { ComponentType } from 'discord-api-types/v10';\nimport { BaseSelectMenuBuilder } from './BaseSelectMenu.js';\n\nexport class MentionableSelectMenuBuilder extends BaseSelectMenuBuilder {\n\t/**\n\t * Creates a new select menu from API data\n\t *\n\t * @param data - The API data to create this select menu with\n\t * @example\n\t * Creating a select menu from an API data object\n\t * ```ts\n\t * const selectMenu = new MentionableSelectMenuBuilder({\n\t * \tcustom_id: 'a cool select menu',\n\t * \tplaceholder: 'select an option',\n\t * \tmax_values: 2,\n\t * });\n\t * ```\n\t * @example\n\t * Creating a select menu using setters and API data\n\t * ```ts\n\t * const selectMenu = new MentionableSelectMenuBuilder({\n\t * \tcustom_id: 'a cool select menu',\n\t * })\n\t * \t.setMinValues(1)\n\t * ```\n\t */\n\tpublic constructor(data?: Partial) {\n\t\tsuper({ ...data, type: ComponentType.MentionableSelect });\n\t}\n}\n","import type { APIRoleSelectComponent } from 'discord-api-types/v10';\nimport { ComponentType } from 'discord-api-types/v10';\nimport { BaseSelectMenuBuilder } from './BaseSelectMenu.js';\n\nexport class RoleSelectMenuBuilder extends BaseSelectMenuBuilder {\n\t/**\n\t * Creates a new select menu from API data\n\t *\n\t * @param data - The API data to create this select menu with\n\t * @example\n\t * Creating a select menu from an API data object\n\t * ```ts\n\t * const selectMenu = new RoleSelectMenuBuilder({\n\t * \tcustom_id: 'a cool select menu',\n\t * \tplaceholder: 'select an option',\n\t * \tmax_values: 2,\n\t * });\n\t * ```\n\t * @example\n\t * Creating a select menu using setters and API data\n\t * ```ts\n\t * const selectMenu = new RoleSelectMenuBuilder({\n\t * \tcustom_id: 'a cool select menu',\n\t * })\n\t * \t.setMinValues(1)\n\t * ```\n\t */\n\tpublic constructor(data?: Partial) {\n\t\tsuper({ ...data, type: ComponentType.RoleSelect });\n\t}\n}\n","import type { APIStringSelectComponent } from 'discord-api-types/v10';\nimport { ComponentType, type APISelectMenuOption } from 'discord-api-types/v10';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray.js';\nimport { jsonOptionValidator, optionsLengthValidator, validateRequiredSelectMenuParameters } from '../Assertions.js';\nimport { BaseSelectMenuBuilder } from './BaseSelectMenu.js';\nimport { StringSelectMenuOptionBuilder } from './StringSelectMenuOption.js';\n\n/**\n * Represents a string select menu component\n */\nexport class StringSelectMenuBuilder extends BaseSelectMenuBuilder {\n\t/**\n\t * The options within this select menu\n\t */\n\tpublic readonly options: StringSelectMenuOptionBuilder[];\n\n\t/**\n\t * Creates a new select menu from API data\n\t *\n\t * @param data - The API data to create this select menu with\n\t * @example\n\t * Creating a select menu from an API data object\n\t * ```ts\n\t * const selectMenu = new StringSelectMenuBuilder({\n\t * \tcustom_id: 'a cool select menu',\n\t * \tplaceholder: 'select an option',\n\t * \tmax_values: 2,\n\t * \toptions: [\n\t * \t\t{ label: 'option 1', value: '1' },\n\t * \t\t{ label: 'option 2', value: '2' },\n\t * \t\t{ label: 'option 3', value: '3' },\n\t * \t],\n\t * });\n\t * ```\n\t * @example\n\t * Creating a select menu using setters and API data\n\t * ```ts\n\t * const selectMenu = new StringSelectMenuBuilder({\n\t * \tcustom_id: 'a cool select menu',\n\t * })\n\t * \t.setMinValues(1)\n\t * \t.addOptions({\n\t * \t\tlabel: 'Catchy',\n\t * \t\tvalue: 'catch',\n\t * \t});\n\t * ```\n\t */\n\tpublic constructor(data?: Partial) {\n\t\tconst { options, ...initData } = data ?? {};\n\t\tsuper({ ...initData, type: ComponentType.StringSelect });\n\t\tthis.options = options?.map((option: APISelectMenuOption) => new StringSelectMenuOptionBuilder(option)) ?? [];\n\t}\n\n\t/**\n\t * Adds options to this select menu\n\t *\n\t * @param options - The options to add to this select menu\n\t * @returns\n\t */\n\tpublic addOptions(...options: RestOrArray) {\n\t\t// eslint-disable-next-line no-param-reassign\n\t\toptions = normalizeArray(options);\n\t\toptionsLengthValidator.parse(this.options.length + options.length);\n\t\tthis.options.push(\n\t\t\t...options.map((option) =>\n\t\t\t\toption instanceof StringSelectMenuOptionBuilder\n\t\t\t\t\t? option\n\t\t\t\t\t: new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(option)),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the options on this select menu\n\t *\n\t * @param options - The options to set on this select menu\n\t */\n\tpublic setOptions(...options: RestOrArray) {\n\t\t// eslint-disable-next-line no-param-reassign\n\t\toptions = normalizeArray(options);\n\t\toptionsLengthValidator.parse(options.length);\n\t\tthis.options.splice(\n\t\t\t0,\n\t\t\tthis.options.length,\n\t\t\t...options.map((option) =>\n\t\t\t\toption instanceof StringSelectMenuOptionBuilder\n\t\t\t\t\t? option\n\t\t\t\t\t: new StringSelectMenuOptionBuilder(jsonOptionValidator.parse(option)),\n\t\t\t),\n\t\t);\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\n\tpublic override toJSON(): APIStringSelectComponent {\n\t\tvalidateRequiredSelectMenuParameters(this.options, this.data.custom_id);\n\n\t\treturn {\n\t\t\t...this.data,\n\t\t\toptions: this.options.map((option) => option.toJSON()),\n\t\t} as APIStringSelectComponent;\n\t}\n}\n","import type { APIUserSelectComponent } from 'discord-api-types/v10';\nimport { ComponentType } from 'discord-api-types/v10';\nimport { BaseSelectMenuBuilder } from './BaseSelectMenu.js';\n\nexport class UserSelectMenuBuilder extends BaseSelectMenuBuilder {\n\t/**\n\t * Creates a new select menu from API data\n\t *\n\t * @param data - The API data to create this select menu with\n\t * @example\n\t * Creating a select menu from an API data object\n\t * ```ts\n\t * const selectMenu = new UserSelectMenuBuilder({\n\t * \tcustom_id: 'a cool select menu',\n\t * \tplaceholder: 'select an option',\n\t * \tmax_values: 2,\n\t * });\n\t * ```\n\t * @example\n\t * Creating a select menu using setters and API data\n\t * ```ts\n\t * const selectMenu = new UserSelectMenuBuilder({\n\t * \tcustom_id: 'a cool select menu',\n\t * })\n\t * \t.setMinValues(1)\n\t * ```\n\t */\n\tpublic constructor(data?: Partial) {\n\t\tsuper({ ...data, type: ComponentType.UserSelect });\n\t}\n}\n","import { isJSONEncodable, type Equatable, type JSONEncodable } from '@discordjs/util';\nimport { ComponentType, type TextInputStyle, type APITextInputComponent } from 'discord-api-types/v10';\nimport isEqual from 'fast-deep-equal';\nimport { customIdValidator } from '../Assertions.js';\nimport { ComponentBuilder } from '../Component.js';\nimport {\n\tmaxLengthValidator,\n\tminLengthValidator,\n\tplaceholderValidator,\n\trequiredValidator,\n\tvalueValidator,\n\tvalidateRequiredParameters,\n\tlabelValidator,\n\ttextInputStyleValidator,\n} from './Assertions.js';\n\nexport class TextInputBuilder\n\textends ComponentBuilder\n\timplements Equatable>\n{\n\t/**\n\t * Creates a new text input from API data\n\t *\n\t * @param data - The API data to create this text input with\n\t * @example\n\t * Creating a select menu option from an API data object\n\t * ```ts\n\t * const textInput = new TextInputBuilder({\n\t * \tcustom_id: 'a cool select menu',\n\t * \tlabel: 'Type something',\n\t * \tstyle: TextInputStyle.Short,\n\t * });\n\t * ```\n\t * @example\n\t * Creating a select menu option using setters and API data\n\t * ```ts\n\t * const textInput = new TextInputBuilder({\n\t * \tlabel: 'Type something else',\n\t * })\n\t * \t.setCustomId('woah')\n\t * \t.setStyle(TextInputStyle.Paragraph);\n\t * ```\n\t */\n\tpublic constructor(data?: APITextInputComponent & { type?: ComponentType.TextInput }) {\n\t\tsuper({ type: ComponentType.TextInput, ...data });\n\t}\n\n\t/**\n\t * Sets the custom id for this text input\n\t *\n\t * @param customId - The custom id of this text input\n\t */\n\tpublic setCustomId(customId: string) {\n\t\tthis.data.custom_id = customIdValidator.parse(customId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the label for this text input\n\t *\n\t * @param label - The label for this text input\n\t */\n\tpublic setLabel(label: string) {\n\t\tthis.data.label = labelValidator.parse(label);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the style for this text input\n\t *\n\t * @param style - The style for this text input\n\t */\n\tpublic setStyle(style: TextInputStyle) {\n\t\tthis.data.style = textInputStyleValidator.parse(style);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the minimum length of text for this text input\n\t *\n\t * @param minLength - The minimum length of text for this text input\n\t */\n\tpublic setMinLength(minLength: number) {\n\t\tthis.data.min_length = minLengthValidator.parse(minLength);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the maximum length of text for this text input\n\t *\n\t * @param maxLength - The maximum length of text for this text input\n\t */\n\tpublic setMaxLength(maxLength: number) {\n\t\tthis.data.max_length = maxLengthValidator.parse(maxLength);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the placeholder of this text input\n\t *\n\t * @param placeholder - The placeholder of this text input\n\t */\n\tpublic setPlaceholder(placeholder: string) {\n\t\tthis.data.placeholder = placeholderValidator.parse(placeholder);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the value of this text input\n\t *\n\t * @param value - The value for this text input\n\t */\n\tpublic setValue(value: string) {\n\t\tthis.data.value = valueValidator.parse(value);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets whether this text input is required\n\t *\n\t * @param required - Whether this text input is required\n\t */\n\tpublic setRequired(required = true) {\n\t\tthis.data.required = requiredValidator.parse(required);\n\t\treturn this;\n\t}\n\n\t/**\n\t * {@inheritDoc ComponentBuilder.toJSON}\n\t */\n\tpublic toJSON(): APITextInputComponent {\n\t\tvalidateRequiredParameters(this.data.custom_id, this.data.style, this.data.label);\n\n\t\treturn {\n\t\t\t...this.data,\n\t\t} as APITextInputComponent;\n\t}\n\n\t/**\n\t * {@inheritDoc Equatable.equals}\n\t */\n\tpublic equals(other: APITextInputComponent | JSONEncodable): boolean {\n\t\tif (isJSONEncodable(other)) {\n\t\t\treturn isEqual(other.toJSON(), this.data);\n\t\t}\n\n\t\treturn isEqual(other, this.data);\n\t}\n}\n","import { s } from '@sapphire/shapeshift';\nimport { TextInputStyle } from 'discord-api-types/v10';\nimport { isValidationEnabled } from '../../util/validation.js';\nimport { customIdValidator } from '../Assertions.js';\n\nexport const textInputStyleValidator = s.nativeEnum(TextInputStyle);\nexport const minLengthValidator = s.number.int\n\t.greaterThanOrEqual(0)\n\t.lessThanOrEqual(4_000)\n\t.setValidationEnabled(isValidationEnabled);\nexport const maxLengthValidator = s.number.int\n\t.greaterThanOrEqual(1)\n\t.lessThanOrEqual(4_000)\n\t.setValidationEnabled(isValidationEnabled);\nexport const requiredValidator = s.boolean;\nexport const valueValidator = s.string.lengthLessThanOrEqual(4_000).setValidationEnabled(isValidationEnabled);\nexport const placeholderValidator = s.string.lengthLessThanOrEqual(100).setValidationEnabled(isValidationEnabled);\nexport const labelValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(45)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredParameters(customId?: string, style?: TextInputStyle, label?: string) {\n\tcustomIdValidator.parse(customId);\n\ttextInputStyleValidator.parse(style);\n\tlabelValidator.parse(label);\n}\n","import { s } from '@sapphire/shapeshift';\nimport { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow.js';\nimport { customIdValidator } from '../../components/Assertions.js';\nimport { isValidationEnabled } from '../../util/validation.js';\n\nexport const titleValidator = s.string\n\t.lengthGreaterThanOrEqual(1)\n\t.lengthLessThanOrEqual(45)\n\t.setValidationEnabled(isValidationEnabled);\nexport const componentsValidator = s\n\t.instance(ActionRowBuilder)\n\t.array.lengthGreaterThanOrEqual(1)\n\t.setValidationEnabled(isValidationEnabled);\n\nexport function validateRequiredParameters(\n\tcustomId?: string,\n\ttitle?: string,\n\tcomponents?: ActionRowBuilder[],\n) {\n\tcustomIdValidator.parse(customId);\n\ttitleValidator.parse(title);\n\tcomponentsValidator.parse(components);\n}\n","import type { JSONEncodable } from '@discordjs/util';\nimport type {\n\tAPIActionRowComponent,\n\tAPIModalActionRowComponent,\n\tAPIModalInteractionResponseCallbackData,\n} from 'discord-api-types/v10';\nimport { ActionRowBuilder, type ModalActionRowComponentBuilder } from '../../components/ActionRow.js';\nimport { customIdValidator } from '../../components/Assertions.js';\nimport { createComponentBuilder } from '../../components/Components.js';\nimport { normalizeArray, type RestOrArray } from '../../util/normalizeArray.js';\nimport { titleValidator, validateRequiredParameters } from './Assertions.js';\n\nexport class ModalBuilder implements JSONEncodable {\n\tpublic readonly data: Partial;\n\n\tpublic readonly components: ActionRowBuilder[] = [];\n\n\tpublic constructor({ components, ...data }: Partial = {}) {\n\t\tthis.data = { ...data };\n\t\tthis.components = (components?.map((component) => createComponentBuilder(component)) ??\n\t\t\t[]) as ActionRowBuilder[];\n\t}\n\n\t/**\n\t * Sets the title of the modal\n\t *\n\t * @param title - The title of the modal\n\t */\n\tpublic setTitle(title: string) {\n\t\tthis.data.title = titleValidator.parse(title);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Sets the custom id of the modal\n\t *\n\t * @param customId - The custom id of this modal\n\t */\n\tpublic setCustomId(customId: string) {\n\t\tthis.data.custom_id = customIdValidator.parse(customId);\n\t\treturn this;\n\t}\n\n\t/**\n\t * Adds components to this modal\n\t *\n\t * @param components - The components to add to this modal\n\t */\n\tpublic addComponents(\n\t\t...components: RestOrArray<\n\t\t\tActionRowBuilder | APIActionRowComponent