diff --git a/src/structures/MessageActionRow.js b/src/structures/MessageActionRow.js index c44b32a6018a..b1f346b2d77d 100644 --- a/src/structures/MessageActionRow.js +++ b/src/structures/MessageActionRow.js @@ -12,14 +12,16 @@ class MessageActionRow extends BaseMessageComponent { * Components that can be placed in an action row * * MessageButton * * MessageSelectMenu - * @typedef {MessageButton|MessageSelectMenu} MessageActionRowComponent + * * InputTextComponent + * @typedef {MessageButton|MessageSelectMenu|InputTextComponent} MessageActionRowComponent */ /** * Options for components that can be placed in an action row * * MessageButtonOptions * * MessageSelectMenuOptions - * @typedef {MessageButtonOptions|MessageSelectMenuOptions} MessageActionRowComponentOptions + * * InputTextComponentOptions + * @typedef {MessageButtonOptions|MessageSelectMenuOptions|InputTextComponentOptions} MessageActionRowComponentOptions */ /** diff --git a/src/structures/Modal.js b/src/structures/Modal.js index fa38d94b1b0d..bbee17be462f 100644 --- a/src/structures/Modal.js +++ b/src/structures/Modal.js @@ -8,7 +8,7 @@ class Modal { * @typedef {object} ModalOptions * @property {string} [customId] A unique string to be sent in the interaction when clicked * @property {string} [title] The title to be displayed on this modal - * @property {ModalActionRow[]|ModalActionRow[]} [components] + * @property {MessageActionRow[]|MessageActionRowOptions[]} [components] * Action rows containing interactive components for the modal (input text components) */ @@ -18,8 +18,8 @@ class Modal { */ constructor(data = {}, client = null) { /** - * A list of ModalActionRows in the modal - * @type {ModalActionRow[]} + * A list of MessageActionRows in the modal + * @type {MessageActionRow[]} */ this.components = data.components?.map(c => BaseMessageComponent.create(c, client)) ?? []; @@ -38,7 +38,7 @@ class Modal { /** * Adds components to the modal. - * @param {...ModalActionRowResolvable[]} components The components to add + * @param {...MessageActionRowResolvable[]} components The components to add * @returns {Modal} */ addComponents(...components) { @@ -48,7 +48,7 @@ class Modal { /** * Sets the components of the modal. - * @param {...ModalActionRowResolvable[]} components The components to set + * @param {...MessageActionRowResolvable[]} components The components to set * @returns {Modal} */ setComponents(...components) { @@ -70,7 +70,7 @@ class Modal { * Removes, replaces, and inserts components in the modal. * @param {number} index The index to start at * @param {number} deleteCount The number of components to remove - * @param {...ModalActionRowResolvable[]} [components] The replacing components + * @param {...MessageActionRowResolvable[]} [components] The replacing components * @returns {Modal} */ spliceComponents(index, deleteCount, ...components) { diff --git a/src/structures/ModalActionRow.js b/src/structures/ModalActionRow.js deleted file mode 100644 index e2ac951010ec..000000000000 --- a/src/structures/ModalActionRow.js +++ /dev/null @@ -1,99 +0,0 @@ -'use strict'; - -const BaseMessageComponent = require('./BaseMessageComponent'); -const { MessageComponentTypes } = require('../util/Constants'); - -/** - * Represents an action row containing message components. - * @extends {BaseMessageComponent} - */ -class ModalActionRow extends BaseMessageComponent { - /** - * Components that can be placed in an action row - * * InputTextComponent - * @typedef {InputTextComponent} ModalActionRowComponent - */ - - /** - * Options for components that can be placed in an action row - * * InputTextComponentOptions - * @typedef {InputTextComponentOptions} ModalActionRowComponentOptions - */ - - /** - * Data that can be resolved into components that can be placed in an action row - * * ModalActionRowComponent - * * ModalActionRowComponentOptions - * @typedef {ModalActionRowComponent|ModalActionRowComponentOptions} ModalActionRowComponentResolvable - */ - - /** - * @typedef {BaseMessageComponentOptions} ModalActionRowOptions - * @property {ModalActionRowComponentResolvable[]} [components] - * The components to place in this action row - */ - - /** - * @param {ModalActionRow|ModalActionRowOptions} [data={}] ModalActionRow to clone or raw data - * @param {Client} [client] The client constructing this ModalActionRow, if provided - */ - constructor(data = {}, client = null) { - super({ type: 'ACTION_ROW' }); - - /** - * The components in this action row - * @type {ModalActionRowComponent[]} - */ - this.components = data.components?.map(c => BaseMessageComponent.create(c, client)) ?? []; - } - - /** - * Adds components to the action row. - * @param {...ModalActionRowComponentResolvable[]} components The components to add - * @returns {ModalActionRow} - */ - addComponents(...components) { - this.components.push(...components.flat(Infinity).map(c => BaseMessageComponent.create(c))); - return this; - } - - /** - * Sets the components of the action row. - * @param {...ModalActionRowComponentResolvable[]} components The components to set - * @returns {ModalActionRow} - */ - setComponents(...components) { - this.spliceComponents(0, this.components.length, components); - return this; - } - - /** - * Removes, replaces, and inserts components in the action row. - * @param {number} index The index to start at - * @param {number} deleteCount The number of components to remove - * @param {...ModalActionRowComponentResolvable[]} [components] The replacing components - * @returns {ModalActionRow} - */ - spliceComponents(index, deleteCount, ...components) { - this.components.splice(index, deleteCount, ...components.flat(Infinity).map(c => BaseMessageComponent.create(c))); - return this; - } - - /** - * Transforms the action row to a plain object. - * @returns {APIMessageComponent} The raw data of this action row - */ - toJSON() { - return { - components: this.components.map(c => c.toJSON()), - type: MessageComponentTypes[this.type], - }; - } -} - -module.exports = ModalActionRow; - -/** - * @external APIMessageComponent - * @see {@link https://discord.com/developers/docs/interactions/message-components#component-object} - */ diff --git a/src/structures/ModalSubmitInteraction.js b/src/structures/ModalSubmitInteraction.js index 07cfc1b17a13..0a2d42c66530 100644 --- a/src/structures/ModalSubmitInteraction.js +++ b/src/structures/ModalSubmitInteraction.js @@ -16,7 +16,7 @@ class ModalSubmitInteraction extends Interaction { /** * The inputs within the modal - * @type {Array>} + * @type {Array>} */ this.components = data.data.components?.map(c => BaseMessageComponent.create(c, this.client)) ?? []; }