mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
refactor!: remove discord.js builders (#10529)
BREAKING CHANGE: Removed all builder extensions within discord.js
This commit is contained in:
committed by
GitHub
parent
28a945069f
commit
0f89353443
@@ -65,7 +65,7 @@
|
||||
"homepage": "https://discord.js.org",
|
||||
"funding": "https://github.com/discordjs/discord.js?sponsor",
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^1.9.0",
|
||||
"@discordjs/builders": "workspace:^",
|
||||
"@discordjs/collection": "workspace:^",
|
||||
"@discordjs/formatters": "workspace:^",
|
||||
"@discordjs/rest": "workspace:^",
|
||||
|
||||
@@ -92,7 +92,6 @@ exports.VoiceStateManager = require('./managers/VoiceStateManager.js').VoiceStat
|
||||
|
||||
// Structures
|
||||
exports.ActionRow = require('./structures/ActionRow.js').ActionRow;
|
||||
exports.ActionRowBuilder = require('./structures/ActionRowBuilder.js').ActionRowBuilder;
|
||||
exports.Activity = require('./structures/Presence.js').Activity;
|
||||
exports.AnnouncementChannel = require('./structures/AnnouncementChannel.js').AnnouncementChannel;
|
||||
exports.AnonymousGuild = require('./structures/AnonymousGuild.js').AnonymousGuild;
|
||||
@@ -115,11 +114,9 @@ exports.BaseGuildTextChannel = require('./structures/BaseGuildTextChannel.js').B
|
||||
exports.BaseGuildVoiceChannel = require('./structures/BaseGuildVoiceChannel.js').BaseGuildVoiceChannel;
|
||||
exports.BaseInteraction = require('./structures/BaseInteraction.js').BaseInteraction;
|
||||
exports.BaseSelectMenuComponent = require('./structures/BaseSelectMenuComponent.js').BaseSelectMenuComponent;
|
||||
exports.ButtonBuilder = require('./structures/ButtonBuilder.js').ButtonBuilder;
|
||||
exports.ButtonComponent = require('./structures/ButtonComponent.js').ButtonComponent;
|
||||
exports.ButtonInteraction = require('./structures/ButtonInteraction.js').ButtonInteraction;
|
||||
exports.CategoryChannel = require('./structures/CategoryChannel.js').CategoryChannel;
|
||||
exports.ChannelSelectMenuBuilder = require('./structures/ChannelSelectMenuBuilder.js').ChannelSelectMenuBuilder;
|
||||
exports.ChannelSelectMenuComponent = require('./structures/ChannelSelectMenuComponent.js').ChannelSelectMenuComponent;
|
||||
exports.ChannelSelectMenuInteraction =
|
||||
require('./structures/ChannelSelectMenuInteraction.js').ChannelSelectMenuInteraction;
|
||||
@@ -137,7 +134,6 @@ exports.ContextMenuCommandInteraction =
|
||||
require('./structures/ContextMenuCommandInteraction.js').ContextMenuCommandInteraction;
|
||||
exports.DMChannel = require('./structures/DMChannel.js').DMChannel;
|
||||
exports.Embed = require('./structures/Embed.js').Embed;
|
||||
exports.EmbedBuilder = require('./structures/EmbedBuilder.js').EmbedBuilder;
|
||||
exports.Emoji = require('./structures/Emoji.js').Emoji;
|
||||
exports.Entitlement = require('./structures/Entitlement.js').Entitlement;
|
||||
exports.ForumChannel = require('./structures/ForumChannel.js').ForumChannel;
|
||||
@@ -168,8 +164,6 @@ exports.InteractionWebhook = require('./structures/InteractionWebhook.js').Inter
|
||||
exports.Invite = require('./structures/Invite.js').Invite;
|
||||
exports.InviteGuild = require('./structures/InviteGuild.js').InviteGuild;
|
||||
exports.MediaChannel = require('./structures/MediaChannel.js').MediaChannel;
|
||||
exports.MentionableSelectMenuBuilder =
|
||||
require('./structures/MentionableSelectMenuBuilder.js').MentionableSelectMenuBuilder;
|
||||
exports.MentionableSelectMenuComponent =
|
||||
require('./structures/MentionableSelectMenuComponent.js').MentionableSelectMenuComponent;
|
||||
exports.MentionableSelectMenuInteraction =
|
||||
@@ -185,7 +179,6 @@ exports.MessageContextMenuCommandInteraction =
|
||||
exports.MessageMentions = require('./structures/MessageMentions.js').MessageMentions;
|
||||
exports.MessagePayload = require('./structures/MessagePayload.js').MessagePayload;
|
||||
exports.MessageReaction = require('./structures/MessageReaction.js').MessageReaction;
|
||||
exports.ModalBuilder = require('./structures/ModalBuilder.js').ModalBuilder;
|
||||
exports.ModalSubmitFields = require('./structures/ModalSubmitFields.js').ModalSubmitFields;
|
||||
exports.ModalSubmitInteraction = require('./structures/ModalSubmitInteraction.js').ModalSubmitInteraction;
|
||||
exports.OAuth2Guild = require('./structures/OAuth2Guild.js').OAuth2Guild;
|
||||
@@ -198,7 +191,6 @@ exports.ReactionCollector = require('./structures/ReactionCollector.js').Reactio
|
||||
exports.ReactionEmoji = require('./structures/ReactionEmoji.js').ReactionEmoji;
|
||||
exports.RichPresenceAssets = require('./structures/Presence.js').RichPresenceAssets;
|
||||
exports.Role = require('./structures/Role.js').Role;
|
||||
exports.RoleSelectMenuBuilder = require('./structures/RoleSelectMenuBuilder.js').RoleSelectMenuBuilder;
|
||||
exports.RoleSelectMenuComponent = require('./structures/RoleSelectMenuComponent.js').RoleSelectMenuComponent;
|
||||
exports.RoleSelectMenuInteraction = require('./structures/RoleSelectMenuInteraction.js').RoleSelectMenuInteraction;
|
||||
exports.SKU = require('./structures/SKU.js').SKU;
|
||||
@@ -206,17 +198,13 @@ exports.StageChannel = require('./structures/StageChannel.js').StageChannel;
|
||||
exports.StageInstance = require('./structures/StageInstance.js').StageInstance;
|
||||
exports.Sticker = require('./structures/Sticker.js').Sticker;
|
||||
exports.StickerPack = require('./structures/StickerPack.js').StickerPack;
|
||||
exports.StringSelectMenuBuilder = require('./structures/StringSelectMenuBuilder.js').StringSelectMenuBuilder;
|
||||
exports.StringSelectMenuComponent = require('./structures/StringSelectMenuComponent.js').StringSelectMenuComponent;
|
||||
exports.StringSelectMenuInteraction =
|
||||
require('./structures/StringSelectMenuInteraction.js').StringSelectMenuInteraction;
|
||||
exports.StringSelectMenuOptionBuilder =
|
||||
require('./structures/StringSelectMenuOptionBuilder.js').StringSelectMenuOptionBuilder;
|
||||
exports.Subscription = require('./structures/Subscription.js').Subscription;
|
||||
exports.Team = require('./structures/Team.js').Team;
|
||||
exports.TeamMember = require('./structures/TeamMember.js').TeamMember;
|
||||
exports.TextChannel = require('./structures/TextChannel.js').TextChannel;
|
||||
exports.TextInputBuilder = require('./structures/TextInputBuilder.js').TextInputBuilder;
|
||||
exports.TextInputComponent = require('./structures/TextInputComponent.js').TextInputComponent;
|
||||
exports.ThreadChannel = require('./structures/ThreadChannel.js').ThreadChannel;
|
||||
exports.ThreadMember = require('./structures/ThreadMember.js').ThreadMember;
|
||||
@@ -225,7 +213,6 @@ exports.Typing = require('./structures/Typing.js').Typing;
|
||||
exports.User = require('./structures/User.js').User;
|
||||
exports.UserContextMenuCommandInteraction =
|
||||
require('./structures/UserContextMenuCommandInteraction.js').UserContextMenuCommandInteraction;
|
||||
exports.UserSelectMenuBuilder = require('./structures/UserSelectMenuBuilder.js').UserSelectMenuBuilder;
|
||||
exports.UserSelectMenuComponent = require('./structures/UserSelectMenuComponent.js').UserSelectMenuComponent;
|
||||
exports.UserSelectMenuInteraction = require('./structures/UserSelectMenuInteraction.js').UserSelectMenuInteraction;
|
||||
exports.VoiceChannel = require('./structures/VoiceChannel.js').VoiceChannel;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { ActionRowBuilder: BuildersActionRow } = require('@discordjs/builders');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
|
||||
/**
|
||||
* Represents an action row builder.
|
||||
* @extends {BuildersActionRow}
|
||||
*/
|
||||
class ActionRowBuilder extends BuildersActionRow {
|
||||
constructor({ components, ...data } = {}) {
|
||||
super({
|
||||
...toSnakeCase(data),
|
||||
components: components?.map(component => createComponentBuilder(component)),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new action row builder from JSON data
|
||||
* @param {ActionRow|ActionRowBuilder|APIActionRowComponent} other The other data
|
||||
* @returns {ActionRowBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
||||
}
|
||||
}
|
||||
|
||||
exports.ActionRowBuilder = ActionRowBuilder;
|
||||
|
||||
const { createComponentBuilder } = require('../util/Components.js');
|
||||
const { toSnakeCase } = require('../util/Transformers.js');
|
||||
|
||||
/**
|
||||
* @external BuildersActionRow
|
||||
* @see {@link https://discord.js.org/docs/packages/builders/stable/ActionRowBuilder:Class}
|
||||
*/
|
||||
@@ -1,44 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { ButtonBuilder: BuildersButton } = require('@discordjs/builders');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
const { toSnakeCase } = require('../util/Transformers.js');
|
||||
const { resolvePartialEmoji } = require('../util/Util.js');
|
||||
|
||||
/**
|
||||
* Represents a button builder.
|
||||
* @extends {BuildersButton}
|
||||
*/
|
||||
class ButtonBuilder extends BuildersButton {
|
||||
constructor({ emoji, ...data } = {}) {
|
||||
super(toSnakeCase({ ...data, emoji: emoji && typeof emoji === 'string' ? resolvePartialEmoji(emoji) : emoji }));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the emoji to display on this button
|
||||
* @param {string|APIMessageComponentEmoji} emoji The emoji to display on this button
|
||||
* @returns {ButtonBuilder}
|
||||
*/
|
||||
setEmoji(emoji) {
|
||||
if (typeof emoji === 'string') {
|
||||
return super.setEmoji(resolvePartialEmoji(emoji));
|
||||
}
|
||||
return super.setEmoji(emoji);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new button builder from JSON data
|
||||
* @param {ButtonBuilder|ButtonComponent|APIButtonComponent} other The other data
|
||||
* @returns {ButtonBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
||||
}
|
||||
}
|
||||
|
||||
exports.ButtonBuilder = ButtonBuilder;
|
||||
|
||||
/**
|
||||
* @external BuildersButton
|
||||
* @see {@link https://discord.js.org/docs/packages/builders/stable/ButtonBuilder:Class}
|
||||
*/
|
||||
@@ -1,31 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { ChannelSelectMenuBuilder: BuildersChannelSelectMenu } = require('@discordjs/builders');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
const { toSnakeCase } = require('../util/Transformers.js');
|
||||
|
||||
/**
|
||||
* Class used to build select menu components to be sent through the API
|
||||
* @extends {BuildersChannelSelectMenu}
|
||||
*/
|
||||
class ChannelSelectMenuBuilder extends BuildersChannelSelectMenu {
|
||||
constructor(data = {}) {
|
||||
super(toSnakeCase(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new select menu builder from JSON data
|
||||
* @param {ChannelSelectMenuBuilder|ChannelSelectMenuComponent|APIChannelSelectComponent} other The other data
|
||||
* @returns {ChannelSelectMenuBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
||||
}
|
||||
}
|
||||
|
||||
exports.ChannelSelectMenuBuilder = ChannelSelectMenuBuilder;
|
||||
|
||||
/**
|
||||
* @external BuildersChannelSelectMenu
|
||||
* @see {@link https://discord.js.org/docs/packages/builders/stable/ChannelSelectMenuBuilder:Class}
|
||||
*/
|
||||
@@ -1,50 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { EmbedBuilder: BuildersEmbed, embedLength } = require('@discordjs/builders');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
const { toSnakeCase } = require('../util/Transformers.js');
|
||||
const { resolveColor } = require('../util/Util.js');
|
||||
|
||||
/**
|
||||
* Represents an embed builder.
|
||||
* @extends {BuildersEmbed}
|
||||
*/
|
||||
class EmbedBuilder extends BuildersEmbed {
|
||||
constructor(data) {
|
||||
super(toSnakeCase(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color of this embed
|
||||
* @param {?ColorResolvable} color The color of the embed
|
||||
* @returns {EmbedBuilder}
|
||||
*/
|
||||
setColor(color) {
|
||||
return super.setColor(color && resolveColor(color));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new embed builder from JSON data
|
||||
* @param {EmbedBuilder|Embed|APIEmbed} other The other data
|
||||
* @returns {EmbedBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
||||
}
|
||||
|
||||
/**
|
||||
* The accumulated length for the embed title, description, fields, footer text, and author name.
|
||||
* @type {number}
|
||||
* @readonly
|
||||
*/
|
||||
get length() {
|
||||
return embedLength(this.data);
|
||||
}
|
||||
}
|
||||
|
||||
exports.EmbedBuilder = EmbedBuilder;
|
||||
|
||||
/**
|
||||
* @external BuildersEmbed
|
||||
* @see {@link https://discord.js.org/docs/packages/builders/stable/EmbedBuilder:Class}
|
||||
*/
|
||||
@@ -1,32 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { MentionableSelectMenuBuilder: BuildersMentionableSelectMenu } = require('@discordjs/builders');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
const { toSnakeCase } = require('../util/Transformers.js');
|
||||
|
||||
/**
|
||||
* Class used to build select menu components to be sent through the API
|
||||
* @extends {BuildersMentionableSelectMenu}
|
||||
*/
|
||||
class MentionableSelectMenuBuilder extends BuildersMentionableSelectMenu {
|
||||
constructor(data = {}) {
|
||||
super(toSnakeCase(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new select menu builder from JSON data
|
||||
* @param {MentionableSelectMenuBuilder|MentionableSelectMenuComponent|APIMentionableSelectComponent} other
|
||||
* The other data
|
||||
* @returns {MentionableSelectMenuBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
||||
}
|
||||
}
|
||||
|
||||
exports.MentionableSelectMenuBuilder = MentionableSelectMenuBuilder;
|
||||
|
||||
/**
|
||||
* @external BuildersMentionableSelectMenu
|
||||
* @see {@link https://discord.js.org/docs/packages/builders/stable/MentionableSelectMenuBuilder:Class}
|
||||
*/
|
||||
@@ -3,7 +3,6 @@
|
||||
const { Buffer } = require('node:buffer');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
const { DiscordSnowflake } = require('@sapphire/snowflake');
|
||||
const { ActionRowBuilder } = require('./ActionRowBuilder.js');
|
||||
const { DiscordjsError, DiscordjsRangeError, ErrorCodes } = require('../errors/index.js');
|
||||
const { resolveFile } = require('../util/DataResolver.js');
|
||||
const { MessageFlagsBitField } = require('../util/MessageFlagsBitField.js');
|
||||
@@ -133,7 +132,7 @@ class MessagePayload {
|
||||
}
|
||||
|
||||
const components = this.options.components?.map(component =>
|
||||
(isJSONEncodable(component) ? component : new ActionRowBuilder(component)).toJSON(),
|
||||
isJSONEncodable(component) ? component.toJSON() : this.target.client.options.jsonTransformer(component),
|
||||
);
|
||||
|
||||
let username;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { ModalBuilder: BuildersModal, ComponentBuilder } = require('@discordjs/builders');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
const { toSnakeCase } = require('../util/Transformers.js');
|
||||
|
||||
/**
|
||||
* Represents a modal builder.
|
||||
* @extends {BuildersModal}
|
||||
*/
|
||||
class ModalBuilder extends BuildersModal {
|
||||
constructor({ components, ...data } = {}) {
|
||||
super({
|
||||
...toSnakeCase(data),
|
||||
components: components?.map(component =>
|
||||
component instanceof ComponentBuilder ? component : toSnakeCase(component),
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new modal builder from JSON data
|
||||
* @param {ModalBuilder|APIModalComponent} other The other data
|
||||
* @returns {ModalBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
||||
}
|
||||
}
|
||||
|
||||
exports.ModalBuilder = ModalBuilder;
|
||||
|
||||
/**
|
||||
* @external BuildersModal
|
||||
* @see {@link https://discord.js.org/docs/packages/builders/stable/ModalBuilder:Class}
|
||||
*/
|
||||
@@ -1,31 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { RoleSelectMenuBuilder: BuildersRoleSelectMenu } = require('@discordjs/builders');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
const { toSnakeCase } = require('../util/Transformers.js');
|
||||
|
||||
/**
|
||||
* Class used to build select menu components to be sent through the API
|
||||
* @extends {BuildersRoleSelectMenu}
|
||||
*/
|
||||
class RoleSelectMenuBuilder extends BuildersRoleSelectMenu {
|
||||
constructor(data = {}) {
|
||||
super(toSnakeCase(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new select menu builder from JSON data
|
||||
* @param {RoleSelectMenuBuilder|RoleSelectMenuComponent|APIRoleSelectComponent} other The other data
|
||||
* @returns {RoleSelectMenuBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
||||
}
|
||||
}
|
||||
|
||||
exports.RoleSelectMenuBuilder = RoleSelectMenuBuilder;
|
||||
|
||||
/**
|
||||
* @external BuildersRoleSelectMenu
|
||||
* @see {@link https://discord.js.org/docs/packages/builders/stable/RoleSelectMenuBuilder:Class}
|
||||
*/
|
||||
@@ -1,79 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { SelectMenuBuilder: BuildersSelectMenu, normalizeArray } = require('@discordjs/builders');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
const { toSnakeCase } = require('../util/Transformers.js');
|
||||
const { resolvePartialEmoji } = require('../util/Util.js');
|
||||
|
||||
/**
|
||||
* Class used to build select menu components to be sent through the API
|
||||
* @extends {BuildersSelectMenu}
|
||||
*/
|
||||
class StringSelectMenuBuilder extends BuildersSelectMenu {
|
||||
constructor({ options, ...data } = {}) {
|
||||
super(
|
||||
toSnakeCase({
|
||||
...data,
|
||||
options: options?.map(({ emoji, ...option }) => ({
|
||||
...option,
|
||||
emoji: emoji && typeof emoji === 'string' ? resolvePartialEmoji(emoji) : emoji,
|
||||
})),
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a select menu option emoji
|
||||
* @param {SelectMenuComponentOptionData|APISelectMenuOption} selectMenuOption The option to normalize
|
||||
* @returns {StringSelectMenuOptionBuilder|APISelectMenuOption}
|
||||
* @private
|
||||
*/
|
||||
static normalizeEmoji(selectMenuOption) {
|
||||
if (isJSONEncodable(selectMenuOption)) {
|
||||
return selectMenuOption;
|
||||
}
|
||||
|
||||
const { emoji, ...option } = selectMenuOption;
|
||||
return {
|
||||
...option,
|
||||
emoji: typeof emoji === 'string' ? resolvePartialEmoji(emoji) : emoji,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds options to this select menu
|
||||
* @param {RestOrArray<APISelectMenuOption>} options The options to add to this select menu
|
||||
* @returns {StringSelectMenuBuilder}
|
||||
*/
|
||||
addOptions(...options) {
|
||||
return super.addOptions(normalizeArray(options).map(option => StringSelectMenuBuilder.normalizeEmoji(option)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the options on this select menu
|
||||
* @param {RestOrArray<APISelectMenuOption>} options The options to set on this select menu
|
||||
* @returns {StringSelectMenuBuilder}
|
||||
*/
|
||||
setOptions(...options) {
|
||||
return super.setOptions(normalizeArray(options).map(option => StringSelectMenuBuilder.normalizeEmoji(option)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new select menu builder from json data
|
||||
* @param {StringSelectMenuBuilder|StringSelectMenuComponent|APIStringSelectComponent} other The other data
|
||||
* @returns {StringSelectMenuBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
if (isJSONEncodable(other)) {
|
||||
return new this(other.toJSON());
|
||||
}
|
||||
return new this(other);
|
||||
}
|
||||
}
|
||||
|
||||
exports.StringSelectMenuBuilder = StringSelectMenuBuilder;
|
||||
|
||||
/**
|
||||
* @external BuildersSelectMenu
|
||||
* @see {@link https://discord.js.org/docs/packages/builders/stable/StringSelectMenuBuilder:Class}
|
||||
*/
|
||||
@@ -1,49 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { SelectMenuOptionBuilder: BuildersSelectMenuOption } = require('@discordjs/builders');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
const { toSnakeCase } = require('../util/Transformers.js');
|
||||
const { resolvePartialEmoji } = require('../util/Util.js');
|
||||
|
||||
/**
|
||||
* Represents a select menu option builder.
|
||||
* @extends {BuildersSelectMenuOption}
|
||||
*/
|
||||
class StringSelectMenuOptionBuilder extends BuildersSelectMenuOption {
|
||||
constructor({ emoji, ...data } = {}) {
|
||||
super(
|
||||
toSnakeCase({
|
||||
...data,
|
||||
emoji: emoji && typeof emoji === 'string' ? resolvePartialEmoji(emoji) : emoji,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the emoji to display on this option
|
||||
* @param {ComponentEmojiResolvable} emoji The emoji to display on this option
|
||||
* @returns {StringSelectMenuOptionBuilder}
|
||||
*/
|
||||
setEmoji(emoji) {
|
||||
if (typeof emoji === 'string') {
|
||||
return super.setEmoji(resolvePartialEmoji(emoji));
|
||||
}
|
||||
return super.setEmoji(emoji);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new select menu option builder from JSON data
|
||||
* @param {StringSelectMenuOptionBuilder|APISelectMenuOption} other The other data
|
||||
* @returns {StringSelectMenuOptionBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
||||
}
|
||||
}
|
||||
|
||||
exports.StringSelectMenuOptionBuilder = StringSelectMenuOptionBuilder;
|
||||
|
||||
/**
|
||||
* @external BuildersSelectMenuOption
|
||||
* @see {@link https://discord.js.org/docs/packages/builders/stable/StringSelectMenuOptionBuilder:Class}
|
||||
*/
|
||||
@@ -1,31 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { TextInputBuilder: BuildersTextInput } = require('@discordjs/builders');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
const { toSnakeCase } = require('../util/Transformers.js');
|
||||
|
||||
/**
|
||||
* Represents a text input builder.
|
||||
* @extends {BuildersTextInput}
|
||||
*/
|
||||
class TextInputBuilder extends BuildersTextInput {
|
||||
constructor(data) {
|
||||
super(toSnakeCase(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new text input builder from JSON data
|
||||
* @param {TextInputBuilder|TextInputComponent|APITextInputComponent} other The other data
|
||||
* @returns {TextInputBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
||||
}
|
||||
}
|
||||
|
||||
exports.TextInputBuilder = TextInputBuilder;
|
||||
|
||||
/**
|
||||
* @external BuildersTextInput
|
||||
* @see {@link https://discord.js.org/docs/packages/builders/stable/TextInputBuilder:Class}
|
||||
*/
|
||||
@@ -1,31 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const { UserSelectMenuBuilder: BuildersUserSelectMenu } = require('@discordjs/builders');
|
||||
const { isJSONEncodable } = require('@discordjs/util');
|
||||
const { toSnakeCase } = require('../util/Transformers.js');
|
||||
|
||||
/**
|
||||
* Class used to build select menu components to be sent through the API
|
||||
* @extends {BuildersUserSelectMenu}
|
||||
*/
|
||||
class UserSelectMenuBuilder extends BuildersUserSelectMenu {
|
||||
constructor(data = {}) {
|
||||
super(toSnakeCase(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new select menu builder from JSON data
|
||||
* @param {UserSelectMenuBuilder|UserSelectMenuComponent|APIUserSelectComponent} other The other data
|
||||
* @returns {UserSelectMenuBuilder}
|
||||
*/
|
||||
static from(other) {
|
||||
return new this(isJSONEncodable(other) ? other.toJSON() : other);
|
||||
}
|
||||
}
|
||||
|
||||
exports.UserSelectMenuBuilder = UserSelectMenuBuilder;
|
||||
|
||||
/**
|
||||
* @external BuildersUserSelectMenu
|
||||
* @see {@link https://discord.js.org/docs/packages/builders/stable/UserSelectMenuBuilder:Class}
|
||||
*/
|
||||
@@ -1,6 +1,5 @@
|
||||
'use strict';
|
||||
|
||||
const { ComponentBuilder } = require('@discordjs/builders');
|
||||
const { ComponentType } = require('discord-api-types/v10');
|
||||
|
||||
/**
|
||||
@@ -62,11 +61,6 @@ const { ComponentType } = require('discord-api-types/v10');
|
||||
* @typedef {ActionRowData|ButtonComponentData|SelectMenuComponentData|TextInputComponentData} ComponentData
|
||||
*/
|
||||
|
||||
/**
|
||||
* Any emoji data that can be used within a button
|
||||
* @typedef {APIMessageComponentEmoji|string} ComponentEmojiResolvable
|
||||
*/
|
||||
|
||||
/**
|
||||
* Transforms API data into a component
|
||||
* @param {APIMessageComponent|Component} data The data to create the component from
|
||||
@@ -100,56 +94,14 @@ function createComponent(data) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms API data into a component builder
|
||||
* @param {APIMessageComponent|ComponentBuilder} data The data to create the component from
|
||||
* @returns {ComponentBuilder}
|
||||
* @ignore
|
||||
*/
|
||||
function createComponentBuilder(data) {
|
||||
if (data instanceof ComponentBuilder) {
|
||||
return data;
|
||||
}
|
||||
|
||||
switch (data.type) {
|
||||
case ComponentType.ActionRow:
|
||||
return new ActionRowBuilder(data);
|
||||
case ComponentType.Button:
|
||||
return new ButtonBuilder(data);
|
||||
case ComponentType.StringSelect:
|
||||
return new StringSelectMenuBuilder(data);
|
||||
case ComponentType.TextInput:
|
||||
return new TextInputBuilder(data);
|
||||
case ComponentType.UserSelect:
|
||||
return new UserSelectMenuBuilder(data);
|
||||
case ComponentType.RoleSelect:
|
||||
return new RoleSelectMenuBuilder(data);
|
||||
case ComponentType.MentionableSelect:
|
||||
return new MentionableSelectMenuBuilder(data);
|
||||
case ComponentType.ChannelSelect:
|
||||
return new ChannelSelectMenuBuilder(data);
|
||||
default:
|
||||
return new ComponentBuilder(data);
|
||||
}
|
||||
}
|
||||
|
||||
exports.createComponent = createComponent;
|
||||
exports.createComponentBuilder = createComponentBuilder;
|
||||
|
||||
const { ActionRow } = require('../structures/ActionRow.js');
|
||||
const { ActionRowBuilder } = require('../structures/ActionRowBuilder.js');
|
||||
const { ButtonBuilder } = require('../structures/ButtonBuilder.js');
|
||||
const { ButtonComponent } = require('../structures/ButtonComponent.js');
|
||||
const { ChannelSelectMenuBuilder } = require('../structures/ChannelSelectMenuBuilder.js');
|
||||
const { ChannelSelectMenuComponent } = require('../structures/ChannelSelectMenuComponent.js');
|
||||
const { Component } = require('../structures/Component.js');
|
||||
const { MentionableSelectMenuBuilder } = require('../structures/MentionableSelectMenuBuilder.js');
|
||||
const { MentionableSelectMenuComponent } = require('../structures/MentionableSelectMenuComponent.js');
|
||||
const { RoleSelectMenuBuilder } = require('../structures/RoleSelectMenuBuilder.js');
|
||||
const { RoleSelectMenuComponent } = require('../structures/RoleSelectMenuComponent.js');
|
||||
const { StringSelectMenuBuilder } = require('../structures/StringSelectMenuBuilder.js');
|
||||
const { StringSelectMenuComponent } = require('../structures/StringSelectMenuComponent.js');
|
||||
const { TextInputBuilder } = require('../structures/TextInputBuilder.js');
|
||||
const { TextInputComponent } = require('../structures/TextInputComponent.js');
|
||||
const { UserSelectMenuBuilder } = require('../structures/UserSelectMenuBuilder.js');
|
||||
const { UserSelectMenuComponent } = require('../structures/UserSelectMenuComponent.js');
|
||||
|
||||
@@ -112,7 +112,6 @@ function parseEmoji(text) {
|
||||
* Resolves a partial emoji object from an {@link EmojiIdentifierResolvable}, without checking a Client.
|
||||
* @param {Emoji|EmojiIdentifierResolvable} emoji Emoji identifier to resolve
|
||||
* @returns {?(PartialEmoji|PartialEmojiOnlyId)} Supplying a snowflake yields `PartialEmojiOnlyId`.
|
||||
* @private
|
||||
*/
|
||||
function resolvePartialEmoji(emoji) {
|
||||
if (!emoji) return null;
|
||||
|
||||
122
packages/discord.js/typings/index.d.ts
vendored
122
packages/discord.js/typings/index.d.ts
vendored
@@ -1,21 +1,3 @@
|
||||
import {
|
||||
ActionRowBuilder as BuilderActionRow,
|
||||
MessageActionRowComponentBuilder,
|
||||
ButtonBuilder as BuilderButtonComponent,
|
||||
EmbedBuilder as BuildersEmbed,
|
||||
ChannelSelectMenuBuilder as BuilderChannelSelectMenuComponent,
|
||||
MentionableSelectMenuBuilder as BuilderMentionableSelectMenuComponent,
|
||||
RoleSelectMenuBuilder as BuilderRoleSelectMenuComponent,
|
||||
StringSelectMenuBuilder as BuilderStringSelectMenuComponent,
|
||||
UserSelectMenuBuilder as BuilderUserSelectMenuComponent,
|
||||
TextInputBuilder as BuilderTextInputComponent,
|
||||
SelectMenuOptionBuilder as BuildersSelectMenuOption,
|
||||
ModalActionRowComponentBuilder,
|
||||
ModalBuilder as BuildersModal,
|
||||
AnyComponentBuilder,
|
||||
type RestOrArray,
|
||||
ApplicationCommandOptionAllowedChannelTypes,
|
||||
} from '@discordjs/builders';
|
||||
import { Awaitable, JSONEncodable } from '@discordjs/util';
|
||||
import { Collection, ReadonlyCollection } from '@discordjs/collection';
|
||||
import { BaseImageURLOptions, ImageURLOptions, RawFile, REST, RESTOptions } from '@discordjs/rest';
|
||||
@@ -237,6 +219,7 @@ import {
|
||||
RawWidgetData,
|
||||
RawWidgetMemberData,
|
||||
} from './rawDataTypes.js';
|
||||
import { ApplicationCommandOptionAllowedChannelTypes, MessageActionRowComponentBuilder } from '@discordjs/builders';
|
||||
|
||||
//#region Classes
|
||||
|
||||
@@ -294,22 +277,6 @@ export interface ActionRowData<ComponentType extends JSONEncodable<APIActionRowC
|
||||
components: readonly ComponentType[];
|
||||
}
|
||||
|
||||
export class ActionRowBuilder<
|
||||
ComponentType extends AnyComponentBuilder = AnyComponentBuilder,
|
||||
> extends BuilderActionRow<ComponentType> {
|
||||
public constructor(
|
||||
data?: Partial<
|
||||
| ActionRowData<ActionRowComponentData | JSONEncodable<APIActionRowComponentTypes>>
|
||||
| APIActionRowComponent<APIMessageActionRowComponent | APIModalActionRowComponent>
|
||||
>,
|
||||
);
|
||||
public static from<ComponentType extends AnyComponentBuilder = AnyComponentBuilder>(
|
||||
other:
|
||||
| JSONEncodable<APIActionRowComponent<ReturnType<ComponentType['toJSON']>>>
|
||||
| APIActionRowComponent<ReturnType<ComponentType['toJSON']>>,
|
||||
): ActionRowBuilder<ComponentType>;
|
||||
}
|
||||
|
||||
export type MessageActionRowComponent =
|
||||
| ButtonComponent
|
||||
| StringSelectMenuComponent
|
||||
@@ -751,70 +718,6 @@ export class ButtonComponent extends Component<APIButtonComponent> {
|
||||
|
||||
export type ComponentEmojiResolvable = APIMessageComponentEmoji | string;
|
||||
|
||||
export class ButtonBuilder extends BuilderButtonComponent {
|
||||
public constructor(data?: Partial<ButtonComponentData> | Partial<APIButtonComponent>);
|
||||
public static from(other: JSONEncodable<APIButtonComponent> | APIButtonComponent): ButtonBuilder;
|
||||
public override setEmoji(emoji: ComponentEmojiResolvable): this;
|
||||
}
|
||||
|
||||
export class StringSelectMenuBuilder extends BuilderStringSelectMenuComponent {
|
||||
public constructor(data?: Partial<StringSelectMenuComponentData | APIStringSelectComponent>);
|
||||
private static normalizeEmoji(
|
||||
selectMenuOption: JSONEncodable<APISelectMenuOption> | SelectMenuComponentOptionData,
|
||||
): (APISelectMenuOption | StringSelectMenuOptionBuilder)[];
|
||||
public override addOptions(
|
||||
...options: RestOrArray<BuildersSelectMenuOption | SelectMenuComponentOptionData | APISelectMenuOption>
|
||||
): this;
|
||||
public override setOptions(
|
||||
...options: RestOrArray<BuildersSelectMenuOption | SelectMenuComponentOptionData | APISelectMenuOption>
|
||||
): this;
|
||||
public static from(
|
||||
other: JSONEncodable<APIStringSelectComponent> | APIStringSelectComponent,
|
||||
): StringSelectMenuBuilder;
|
||||
}
|
||||
|
||||
export class UserSelectMenuBuilder extends BuilderUserSelectMenuComponent {
|
||||
public constructor(data?: Partial<UserSelectMenuComponentData | APIUserSelectComponent>);
|
||||
public static from(other: JSONEncodable<APIUserSelectComponent> | APIUserSelectComponent): UserSelectMenuBuilder;
|
||||
}
|
||||
|
||||
export class RoleSelectMenuBuilder extends BuilderRoleSelectMenuComponent {
|
||||
public constructor(data?: Partial<RoleSelectMenuComponentData | APIRoleSelectComponent>);
|
||||
public static from(other: JSONEncodable<APIRoleSelectComponent> | APIRoleSelectComponent): RoleSelectMenuBuilder;
|
||||
}
|
||||
|
||||
export class MentionableSelectMenuBuilder extends BuilderMentionableSelectMenuComponent {
|
||||
public constructor(data?: Partial<MentionableSelectMenuComponentData | APIMentionableSelectComponent>);
|
||||
public static from(
|
||||
other: JSONEncodable<APIMentionableSelectComponent> | APIMentionableSelectComponent,
|
||||
): MentionableSelectMenuBuilder;
|
||||
}
|
||||
|
||||
export class ChannelSelectMenuBuilder extends BuilderChannelSelectMenuComponent {
|
||||
public constructor(data?: Partial<ChannelSelectMenuComponentData | APIChannelSelectComponent>);
|
||||
public static from(
|
||||
other: JSONEncodable<APIChannelSelectComponent> | APIChannelSelectComponent,
|
||||
): ChannelSelectMenuBuilder;
|
||||
}
|
||||
|
||||
export class StringSelectMenuOptionBuilder extends BuildersSelectMenuOption {
|
||||
public constructor(data?: SelectMenuComponentOptionData | APISelectMenuOption);
|
||||
public override setEmoji(emoji: ComponentEmojiResolvable): this;
|
||||
public static from(other: JSONEncodable<APISelectMenuOption> | APISelectMenuOption): StringSelectMenuOptionBuilder;
|
||||
}
|
||||
|
||||
export class ModalBuilder extends BuildersModal {
|
||||
public constructor(data?: Partial<ModalComponentData> | Partial<APIModalInteractionResponseCallbackData>);
|
||||
public static from(
|
||||
other: JSONEncodable<APIModalInteractionResponseCallbackData> | APIModalInteractionResponseCallbackData,
|
||||
): ModalBuilder;
|
||||
}
|
||||
|
||||
export class TextInputBuilder extends BuilderTextInputComponent {
|
||||
public constructor(data?: Partial<TextInputComponentData | APITextInputComponent>);
|
||||
public static from(other: JSONEncodable<APITextInputComponent> | APITextInputComponent): TextInputBuilder;
|
||||
}
|
||||
|
||||
export class TextInputComponent extends Component<APITextInputComponent> {
|
||||
public get customId(): string;
|
||||
public get value(): string;
|
||||
@@ -872,13 +775,6 @@ export interface EmbedAssetData extends Omit<APIEmbedImage, 'proxy_url'> {
|
||||
proxyURL?: string;
|
||||
}
|
||||
|
||||
export class EmbedBuilder extends BuildersEmbed {
|
||||
public constructor(data?: EmbedData | APIEmbed);
|
||||
public override setColor(color: ColorResolvable | null): this;
|
||||
public static from(other: JSONEncodable<APIEmbed> | APIEmbed): EmbedBuilder;
|
||||
public get length(): number;
|
||||
}
|
||||
|
||||
export class Embed {
|
||||
private constructor(data: APIEmbed);
|
||||
public readonly data: Readonly<APIEmbed>;
|
||||
@@ -3508,9 +3404,7 @@ export function moveElementInArray(
|
||||
): number;
|
||||
export function parseEmoji(text: string): PartialEmoji | null;
|
||||
export function resolveColor(color: ColorResolvable): number;
|
||||
/** @internal */
|
||||
export function resolvePartialEmoji(emoji: Snowflake): PartialEmojiOnlyId;
|
||||
/** @internal */
|
||||
export function resolvePartialEmoji(emoji: Emoji | EmojiIdentifierResolvable): PartialEmoji | null;
|
||||
/** @internal */
|
||||
export function resolveGuildEmoji(client: Client, emojiId: Snowflake): GuildEmoji | null;
|
||||
@@ -6266,16 +6160,6 @@ export interface MessageCollectorOptions extends CollectorOptions<[Message, Coll
|
||||
maxProcessed?: number;
|
||||
}
|
||||
|
||||
export type MessageComponent =
|
||||
| Component
|
||||
| ActionRowBuilder<MessageActionRowComponentBuilder | ModalActionRowComponentBuilder>
|
||||
| ButtonComponent
|
||||
| StringSelectMenuComponent
|
||||
| UserSelectMenuComponent
|
||||
| RoleSelectMenuComponent
|
||||
| MentionableSelectMenuComponent
|
||||
| ChannelSelectMenuComponent;
|
||||
|
||||
export type CollectedMessageInteraction<Cached extends CacheType = CacheType> = Exclude<
|
||||
CollectedInteraction<Cached>,
|
||||
ModalSubmitInteraction
|
||||
@@ -6346,9 +6230,9 @@ export interface BaseMessageOptions {
|
||||
| AttachmentPayload
|
||||
)[];
|
||||
components?: readonly (
|
||||
| JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>>
|
||||
| JSONEncodable<APIActionRowComponent<APIActionRowComponentTypes>>
|
||||
| ActionRowData<MessageActionRowComponentData | MessageActionRowComponentBuilder>
|
||||
| APIActionRowComponent<APIMessageActionRowComponent>
|
||||
| APIActionRowComponent<APIActionRowComponentTypes>
|
||||
)[];
|
||||
}
|
||||
|
||||
|
||||
@@ -20,22 +20,15 @@ import {
|
||||
AuditLogEvent,
|
||||
ButtonStyle,
|
||||
TextInputStyle,
|
||||
APITextInputComponent,
|
||||
APIEmbed,
|
||||
ApplicationCommandType,
|
||||
APIMessage,
|
||||
APIActionRowComponent,
|
||||
APIActionRowComponentTypes,
|
||||
APIStringSelectComponent,
|
||||
APIUserSelectComponent,
|
||||
APIRoleSelectComponent,
|
||||
APIChannelSelectComponent,
|
||||
APIMentionableSelectComponent,
|
||||
APIModalInteractionResponseCallbackData,
|
||||
WebhookType,
|
||||
GuildScheduledEventRecurrenceRuleFrequency,
|
||||
GuildScheduledEventRecurrenceRuleMonth,
|
||||
GuildScheduledEventRecurrenceRuleWeekday,
|
||||
APIButtonComponentWithCustomId,
|
||||
} from 'discord-api-types/v10';
|
||||
import {
|
||||
ApplicationCommand,
|
||||
@@ -126,7 +119,6 @@ import {
|
||||
TextInputBuilder,
|
||||
TextInputComponent,
|
||||
Embed,
|
||||
MessageActionRowComponentBuilder,
|
||||
GuildBanManager,
|
||||
GuildBan,
|
||||
MessageManager,
|
||||
@@ -218,9 +210,12 @@ import {
|
||||
PartialPollAnswer,
|
||||
PollAnswer,
|
||||
PollAnswerVoterManager,
|
||||
PrimaryButtonBuilder,
|
||||
resolveColor,
|
||||
createComponentBuilder,
|
||||
} from './index.js';
|
||||
import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd';
|
||||
import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
|
||||
import type { ContextMenuCommandBuilder, ChatInputCommandBuilder } from '@discordjs/builders';
|
||||
import { ReadonlyCollection } from '@discordjs/collection';
|
||||
|
||||
// Test type transformation:
|
||||
@@ -347,17 +342,11 @@ client.on('interactionCreate', async interaction => {
|
||||
|
||||
if (interaction.type !== InteractionType.ApplicationCommand) return;
|
||||
|
||||
void new ActionRowBuilder<MessageActionRowComponentBuilder>();
|
||||
|
||||
const button = new ButtonBuilder();
|
||||
|
||||
const actionRow = new ActionRowBuilder<MessageActionRowComponentBuilder>({
|
||||
const actionRow = new ActionRowBuilder({
|
||||
type: ComponentType.ActionRow,
|
||||
components: [button.toJSON()],
|
||||
components: [{ custom_id: '123', label: 'test', style: ButtonStyle.Primary, type: ComponentType.Button }],
|
||||
});
|
||||
|
||||
actionRow.toJSON();
|
||||
|
||||
await interaction.reply({ content: 'Hi!', components: [actionRow] });
|
||||
|
||||
// @ts-expect-error
|
||||
@@ -622,7 +611,7 @@ client.on('messageCreate', async message => {
|
||||
});
|
||||
|
||||
// Check that both builders and builder data can be sent in messages
|
||||
const row = new ActionRowBuilder<MessageActionRowComponentBuilder>();
|
||||
const row = new ActionRowBuilder();
|
||||
|
||||
const rawButtonsRow: ActionRowData<ButtonComponentData> = {
|
||||
type: ComponentType.ActionRow,
|
||||
@@ -639,7 +628,7 @@ client.on('messageCreate', async message => {
|
||||
|
||||
const buttonsRow: ActionRowData<ButtonBuilder> = {
|
||||
type: ComponentType.ActionRow,
|
||||
components: [new ButtonBuilder()],
|
||||
components: [new PrimaryButtonBuilder()],
|
||||
};
|
||||
|
||||
const rawStringSelectMenuRow: ActionRowData<StringSelectMenuComponentData> = {
|
||||
@@ -754,7 +743,7 @@ client.on('presenceUpdate', (oldPresence, { client }) => {
|
||||
expectType<Client<true>>(client);
|
||||
});
|
||||
|
||||
declare const slashCommandBuilder: SlashCommandBuilder;
|
||||
declare const slashCommandBuilder: ChatInputCommandBuilder;
|
||||
declare const contextMenuCommandBuilder: ContextMenuCommandBuilder;
|
||||
|
||||
client.on('clientReady', async client => {
|
||||
@@ -1326,7 +1315,7 @@ client.on('guildCreate', async g => {
|
||||
const row: ActionRowData<MessageActionRowComponentData> = {
|
||||
type: ComponentType.ActionRow,
|
||||
components: [
|
||||
new ButtonBuilder(),
|
||||
new PrimaryButtonBuilder(),
|
||||
{ type: ComponentType.Button, style: ButtonStyle.Primary, label: 'string', customId: 'foo' },
|
||||
{ type: ComponentType.Button, style: ButtonStyle.Link, label: 'test', url: 'test' },
|
||||
{ type: ComponentType.StringSelect, customId: 'foo', options: [{ label: 'label', value: 'value' }] },
|
||||
@@ -1338,12 +1327,12 @@ client.on('guildCreate', async g => {
|
||||
],
|
||||
};
|
||||
|
||||
const row2 = new ActionRowBuilder<MessageActionRowComponentBuilder>({
|
||||
const row2 = new ActionRowBuilder({
|
||||
type: ComponentType.ActionRow,
|
||||
components: [
|
||||
{ type: ComponentType.Button, style: ButtonStyle.Primary, label: 'string', customId: 'foo' },
|
||||
{ type: ComponentType.Button, style: ButtonStyle.Primary, label: 'string', custom_id: 'foo' },
|
||||
{ type: ComponentType.Button, style: ButtonStyle.Link, label: 'test', url: 'test' },
|
||||
{ type: ComponentType.StringSelect, customId: 'foo', options: [{ label: 'label', value: 'value' }] },
|
||||
{ type: ComponentType.StringSelect, custom_id: 'foo', options: [{ label: 'label', value: 'value' }] },
|
||||
],
|
||||
});
|
||||
|
||||
@@ -2370,43 +2359,7 @@ expectType<
|
||||
>(NonThreadGuildBasedChannel);
|
||||
expectType<GuildTextBasedChannel>(GuildTextBasedChannel);
|
||||
|
||||
const button = new ButtonBuilder({
|
||||
label: 'test',
|
||||
style: ButtonStyle.Primary,
|
||||
customId: 'test',
|
||||
});
|
||||
|
||||
const selectMenu = new StringSelectMenuBuilder({
|
||||
maxValues: 10,
|
||||
minValues: 2,
|
||||
customId: 'test',
|
||||
});
|
||||
|
||||
new ActionRowBuilder({
|
||||
components: [selectMenu.toJSON(), button.toJSON()],
|
||||
});
|
||||
|
||||
new StringSelectMenuBuilder({
|
||||
customId: 'foo',
|
||||
});
|
||||
|
||||
new ButtonBuilder({
|
||||
style: ButtonStyle.Danger,
|
||||
})
|
||||
.setEmoji('<a:foo:123>')
|
||||
.setEmoji('<:foo:123>')
|
||||
.setEmoji('foobar:123')
|
||||
.setEmoji('😏')
|
||||
.setEmoji({
|
||||
name: 'test',
|
||||
id: '123',
|
||||
animated: false,
|
||||
});
|
||||
|
||||
// @ts-expect-error
|
||||
new EmbedBuilder().setColor('abc');
|
||||
|
||||
new EmbedBuilder().setColor('#ffffff');
|
||||
new EmbedBuilder().setColor(resolveColor('#ffffff'));
|
||||
|
||||
expectNotAssignable<ActionRowData<MessageActionRowComponentData>>({
|
||||
type: ComponentType.ActionRow,
|
||||
@@ -2444,74 +2397,38 @@ chatInputInteraction.showModal({
|
||||
],
|
||||
});
|
||||
|
||||
declare const stringSelectMenuData: APIStringSelectComponent;
|
||||
StringSelectMenuBuilder.from(stringSelectMenuData);
|
||||
|
||||
declare const userSelectMenuData: APIUserSelectComponent;
|
||||
UserSelectMenuBuilder.from(userSelectMenuData);
|
||||
|
||||
declare const roleSelectMenuData: APIRoleSelectComponent;
|
||||
RoleSelectMenuBuilder.from(roleSelectMenuData);
|
||||
|
||||
declare const channelSelectMenuData: APIChannelSelectComponent;
|
||||
ChannelSelectMenuBuilder.from(channelSelectMenuData);
|
||||
|
||||
declare const mentionableSelectMenuData: APIMentionableSelectComponent;
|
||||
MentionableSelectMenuBuilder.from(mentionableSelectMenuData);
|
||||
|
||||
declare const stringSelectMenuComp: StringSelectMenuComponent;
|
||||
StringSelectMenuBuilder.from(stringSelectMenuComp);
|
||||
new StringSelectMenuBuilder(stringSelectMenuComp.toJSON());
|
||||
|
||||
declare const userSelectMenuComp: UserSelectMenuComponent;
|
||||
UserSelectMenuBuilder.from(userSelectMenuComp);
|
||||
new UserSelectMenuBuilder(userSelectMenuComp.toJSON());
|
||||
|
||||
declare const roleSelectMenuComp: RoleSelectMenuComponent;
|
||||
RoleSelectMenuBuilder.from(roleSelectMenuComp);
|
||||
new RoleSelectMenuBuilder(roleSelectMenuComp.toJSON());
|
||||
|
||||
declare const channelSelectMenuComp: ChannelSelectMenuComponent;
|
||||
ChannelSelectMenuBuilder.from(channelSelectMenuComp);
|
||||
new ChannelSelectMenuBuilder(channelSelectMenuComp.toJSON());
|
||||
|
||||
declare const mentionableSelectMenuComp: MentionableSelectMenuComponent;
|
||||
MentionableSelectMenuBuilder.from(mentionableSelectMenuComp);
|
||||
new MentionableSelectMenuBuilder(mentionableSelectMenuComp.toJSON());
|
||||
|
||||
declare const buttonData: APIButtonComponent;
|
||||
ButtonBuilder.from(buttonData);
|
||||
declare const buttonData: APIButtonComponentWithCustomId;
|
||||
new PrimaryButtonBuilder(buttonData);
|
||||
|
||||
declare const buttonComp: ButtonComponent;
|
||||
ButtonBuilder.from(buttonComp);
|
||||
|
||||
declare const modalData: APIModalInteractionResponseCallbackData;
|
||||
ModalBuilder.from(modalData);
|
||||
|
||||
declare const textInputData: APITextInputComponent;
|
||||
TextInputBuilder.from(textInputData);
|
||||
createComponentBuilder(buttonComp.toJSON());
|
||||
|
||||
declare const textInputComp: TextInputComponent;
|
||||
TextInputBuilder.from(textInputComp);
|
||||
new TextInputBuilder(textInputComp);
|
||||
|
||||
declare const embedData: APIEmbed;
|
||||
EmbedBuilder.from(embedData);
|
||||
new EmbedBuilder(embedData);
|
||||
|
||||
declare const embedComp: Embed;
|
||||
EmbedBuilder.from(embedComp);
|
||||
|
||||
declare const actionRowData: APIActionRowComponent<APIActionRowComponentTypes>;
|
||||
ActionRowBuilder.from(actionRowData);
|
||||
new EmbedBuilder(embedComp.toJSON());
|
||||
|
||||
declare const actionRowComp: ActionRow<ActionRowComponent>;
|
||||
ActionRowBuilder.from(actionRowComp);
|
||||
|
||||
declare const buttonsActionRowData: APIActionRowComponent<APIButtonComponent>;
|
||||
declare const buttonsActionRowComp: ActionRow<ButtonComponent>;
|
||||
|
||||
expectType<ActionRowBuilder<ButtonBuilder>>(ActionRowBuilder.from<ButtonBuilder>(buttonsActionRowData));
|
||||
expectType<ActionRowBuilder<ButtonBuilder>>(ActionRowBuilder.from<ButtonBuilder>(buttonsActionRowComp));
|
||||
|
||||
declare const anyComponentsActionRowData: APIActionRowComponent<APIActionRowComponentTypes>;
|
||||
declare const anyComponentsActionRowComp: ActionRow<ActionRowComponent>;
|
||||
|
||||
expectType<ActionRowBuilder>(ActionRowBuilder.from(anyComponentsActionRowData));
|
||||
expectType<ActionRowBuilder>(ActionRowBuilder.from(anyComponentsActionRowComp));
|
||||
new ActionRowBuilder(actionRowComp.toJSON());
|
||||
|
||||
type UserMentionChannels = DMChannel | PartialDMChannel;
|
||||
declare const channelMentionChannels: Exclude<Channel | DirectoryChannel, UserMentionChannels>;
|
||||
|
||||
66
pnpm-lock.yaml
generated
66
pnpm-lock.yaml
generated
@@ -896,8 +896,8 @@ importers:
|
||||
packages/discord.js:
|
||||
dependencies:
|
||||
'@discordjs/builders':
|
||||
specifier: ^1.9.0
|
||||
version: 1.9.0
|
||||
specifier: workspace:^
|
||||
version: link:../builders
|
||||
'@discordjs/collection':
|
||||
specifier: workspace:^
|
||||
version: link:../collection
|
||||
@@ -2145,26 +2145,18 @@ packages:
|
||||
resolution: {integrity: sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
'@definitelytyped/header-parser@0.2.16':
|
||||
resolution: {integrity: sha512-UFsgPft5bhZn07UNGz/9ck4AhdKgLFEOmi2DNr7gXcGL89zbe3u5oVafKUT8j1HOtSBjT8ZEQsXHKlbq+wwF/Q==}
|
||||
'@definitelytyped/header-parser@0.2.17':
|
||||
resolution: {integrity: sha512-U0juKFkTOcbkSfO83WSzMEJHYDwoBFiq0tf/JszulL3+7UoSiqunpGmxXS54bm3eGqy7GWjV8AqPQHdeoEaWBQ==}
|
||||
engines: {node: '>=18.18.0'}
|
||||
|
||||
'@definitelytyped/typescript-versions@0.1.6':
|
||||
resolution: {integrity: sha512-gQpXFteIKrOw4ldmBZQfBrD3WobaIG1SwOr/3alXWkcYbkOWa2NRxQbiaYQ2IvYTGaZK26miJw0UOAFiuIs4gA==}
|
||||
'@definitelytyped/typescript-versions@0.1.7':
|
||||
resolution: {integrity: sha512-sBzBi1SBn79OkSr8V0H+FzR7QumHk23syPyRxod/VRBrSkgN9rCliIe+nqLoWRAKN8EeKbp00ketnJNLZhucdA==}
|
||||
engines: {node: '>=18.18.0'}
|
||||
|
||||
'@definitelytyped/utils@0.1.8':
|
||||
resolution: {integrity: sha512-4JINx4Rttha29f50PBsJo48xZXx/He5yaIWJRwVarhYAN947+S84YciHl+AIhQNRPAFkg8+5qFngEGtKxQDWXA==}
|
||||
engines: {node: '>=18.18.0'}
|
||||
|
||||
'@discordjs/builders@1.9.0':
|
||||
resolution: {integrity: sha512-0zx8DePNVvQibh5ly5kCEei5wtPBIUbSoE9n+91Rlladz4tgtFbJ36PZMxxZrTEOQ7AHMZ/b0crT/0fCy6FTKg==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
'@discordjs/formatters@0.5.0':
|
||||
resolution: {integrity: sha512-98b3i+Y19RFq1Xke4NkVY46x8KjJQjldHUuEbCqMvp1F5Iq9HgnGpu91jOi/Ufazhty32eRsKnnzS8n4c+L93g==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
'@discordjs/node-pre-gyp@0.4.5':
|
||||
resolution: {integrity: sha512-YJOVVZ545x24mHzANfYoy0BJX5PDyeZlpiJjDkUBM/V/Ao7TFX9lcUvCN4nr0tbr5ubeaXxtEBILUrHtTphVeQ==}
|
||||
hasBin: true
|
||||
@@ -2173,10 +2165,6 @@ packages:
|
||||
resolution: {integrity: sha512-NEE76A96FtQ5YuoAVlOlB3ryMPrkXbUCTQICHGKb8ShtjXyubGicjRMouHtP1RpuDdm16cDa+oI3aAMo1zQRUQ==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
'@discordjs/util@1.1.1':
|
||||
resolution: {integrity: sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
'@edge-runtime/format@2.2.1':
|
||||
resolution: {integrity: sha512-JQTRVuiusQLNNLe2W9tnzBlV/GvSVcozLl4XZHk5swnRZ/v6jp8TqR8P7sqmJsQqblDZ3EztcWmLDbhRje/+8g==}
|
||||
engines: {node: '>=16'}
|
||||
@@ -4773,10 +4761,6 @@ packages:
|
||||
resolution: {integrity: sha512-DJbCGmvi8UZAu/hh85auQL8bODFlpcS3cWjRJZ5/cXTLekmGvs/CrRxrIzwbA6+poyYojo5rK4qu8trmjfneog==}
|
||||
engines: {node: '>=v14.0.0', npm: '>=7.0.0'}
|
||||
|
||||
'@sapphire/shapeshift@4.0.0':
|
||||
resolution: {integrity: sha512-d9dUmWVA7MMiKobL3VpLF8P2aeanRTu6ypG2OIaEv/ZHH/SUQ2iHOVyi5wAPjQ+HmnMuL0whK9ez8I/raWbtIg==}
|
||||
engines: {node: '>=v16'}
|
||||
|
||||
'@sapphire/snowflake@3.5.5':
|
||||
resolution: {integrity: sha512-xzvBr1Q1c4lCe7i6sRnrofxeO1QTP/LKQ6A6qy0iB4x5yfiSfARMEQEghojzTNALDTcv8En04qYNIco9/K9eZQ==}
|
||||
engines: {node: '>=v14.0.0', npm: '>=7.0.0'}
|
||||
@@ -7326,9 +7310,6 @@ packages:
|
||||
discord-api-types@0.37.118:
|
||||
resolution: {integrity: sha512-MQkHHZcytmNQ3nQOBj6a0z38swsmHiROX7hdayfd0eWVrLxaQp/6tWBZ7FO2MCKKsc+W3QWnnfOJTbtyk8C4TQ==}
|
||||
|
||||
discord-api-types@0.37.97:
|
||||
resolution: {integrity: sha512-No1BXPcVkyVD4ZVmbNgDKaBoqgeQ+FJpzZ8wqHkfmBnTZig1FcH3iPPersiK1TUIAzgClh2IvOuVUYfcWLQAOA==}
|
||||
|
||||
dlv@1.1.3:
|
||||
resolution: {integrity: sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==}
|
||||
|
||||
@@ -13859,13 +13840,13 @@ snapshots:
|
||||
dependencies:
|
||||
'@jridgewell/trace-mapping': 0.3.9
|
||||
|
||||
'@definitelytyped/header-parser@0.2.16':
|
||||
'@definitelytyped/header-parser@0.2.17':
|
||||
dependencies:
|
||||
'@definitelytyped/typescript-versions': 0.1.6
|
||||
'@definitelytyped/typescript-versions': 0.1.7
|
||||
'@definitelytyped/utils': 0.1.8
|
||||
semver: 7.6.3
|
||||
|
||||
'@definitelytyped/typescript-versions@0.1.6': {}
|
||||
'@definitelytyped/typescript-versions@0.1.7': {}
|
||||
|
||||
'@definitelytyped/utils@0.1.8':
|
||||
dependencies:
|
||||
@@ -13878,20 +13859,6 @@ snapshots:
|
||||
tar-stream: 3.1.7
|
||||
which: 4.0.0
|
||||
|
||||
'@discordjs/builders@1.9.0':
|
||||
dependencies:
|
||||
'@discordjs/formatters': 0.5.0
|
||||
'@discordjs/util': 1.1.1
|
||||
'@sapphire/shapeshift': 4.0.0
|
||||
discord-api-types: 0.37.97
|
||||
fast-deep-equal: 3.1.3
|
||||
ts-mixer: 6.0.4
|
||||
tslib: 2.8.1
|
||||
|
||||
'@discordjs/formatters@0.5.0':
|
||||
dependencies:
|
||||
discord-api-types: 0.37.97
|
||||
|
||||
'@discordjs/node-pre-gyp@0.4.5(encoding@0.1.13)':
|
||||
dependencies:
|
||||
detect-libc: 2.0.3
|
||||
@@ -13915,8 +13882,6 @@ snapshots:
|
||||
- encoding
|
||||
- supports-color
|
||||
|
||||
'@discordjs/util@1.1.1': {}
|
||||
|
||||
'@edge-runtime/format@2.2.1': {}
|
||||
|
||||
'@edge-runtime/node-utils@2.3.0': {}
|
||||
@@ -16998,11 +16963,6 @@ snapshots:
|
||||
|
||||
'@sapphire/result@2.7.2': {}
|
||||
|
||||
'@sapphire/shapeshift@4.0.0':
|
||||
dependencies:
|
||||
fast-deep-equal: 3.1.3
|
||||
lodash: 4.17.21
|
||||
|
||||
'@sapphire/snowflake@3.5.5': {}
|
||||
|
||||
'@sapphire/utilities@3.17.0': {}
|
||||
@@ -20354,8 +20314,6 @@ snapshots:
|
||||
|
||||
discord-api-types@0.37.118: {}
|
||||
|
||||
discord-api-types@0.37.97: {}
|
||||
|
||||
dlv@1.1.3: {}
|
||||
|
||||
dmd@6.2.3:
|
||||
@@ -20405,7 +20363,7 @@ snapshots:
|
||||
|
||||
dts-critic@3.3.11(typescript@5.5.4):
|
||||
dependencies:
|
||||
'@definitelytyped/header-parser': 0.2.16
|
||||
'@definitelytyped/header-parser': 0.2.17
|
||||
command-exists: 1.2.9
|
||||
rimraf: 3.0.2
|
||||
semver: 6.3.1
|
||||
@@ -20415,8 +20373,8 @@ snapshots:
|
||||
|
||||
dtslint@4.2.1(typescript@5.5.4):
|
||||
dependencies:
|
||||
'@definitelytyped/header-parser': 0.2.16
|
||||
'@definitelytyped/typescript-versions': 0.1.6
|
||||
'@definitelytyped/header-parser': 0.2.17
|
||||
'@definitelytyped/typescript-versions': 0.1.7
|
||||
'@definitelytyped/utils': 0.1.8
|
||||
dts-critic: 3.3.11(typescript@5.5.4)
|
||||
fs-extra: 6.0.1
|
||||
|
||||
Reference in New Issue
Block a user