From fb50dd984178b21375928431fb106f3ba5ed91ee Mon Sep 17 00:00:00 2001 From: Rodry <38259440+ImRodry@users.noreply.github.com> Date: Tue, 24 Aug 2021 21:20:03 +0100 Subject: [PATCH] feat: set methods for MessageActionRow and MessageSelectMenu (#6490) --- src/structures/MessageActionRow.js | 10 ++++++++++ src/structures/MessageSelectMenu.js | 10 ++++++++++ typings/index.d.ts | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/src/structures/MessageActionRow.js b/src/structures/MessageActionRow.js index 50384ad14..c44b32a60 100644 --- a/src/structures/MessageActionRow.js +++ b/src/structures/MessageActionRow.js @@ -59,6 +59,16 @@ class MessageActionRow extends BaseMessageComponent { return this; } + /** + * Sets the components of the action row. + * @param {...MessageActionRowComponentResolvable[]} components The components to set + * @returns {MessageActionRow} + */ + 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 diff --git a/src/structures/MessageSelectMenu.js b/src/structures/MessageSelectMenu.js index 327ee1d87..32d790519 100644 --- a/src/structures/MessageSelectMenu.js +++ b/src/structures/MessageSelectMenu.js @@ -145,6 +145,16 @@ class MessageSelectMenu extends BaseMessageComponent { return this; } + /** + * Sets the options of the select menu. + * @param {...MessageSelectOptionData|MessageSelectOptionData[]} options The options to set + * @returns {MessageSelectMenu} + */ + setOptions(...options) { + this.spliceOptions(0, this.options.length, options); + return this; + } + /** * Removes, replaces, and inserts options in the select menu. * @param {number} index The index to start at diff --git a/typings/index.d.ts b/typings/index.d.ts index b2cfae294..cc5e1fd79 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1183,6 +1183,9 @@ export class MessageActionRow extends BaseMessageComponent { public addComponents( ...components: MessageActionRowComponentResolvable[] | MessageActionRowComponentResolvable[][] ): this; + public setComponents( + ...components: MessageActionRowComponentResolvable[] | MessageActionRowComponentResolvable[][] + ): this; public spliceComponents( index: number, deleteCount: number, @@ -1392,6 +1395,7 @@ export class MessageSelectMenu extends BaseMessageComponent { public placeholder: string | null; public type: 'SELECT_MENU'; public addOptions(...options: MessageSelectOptionData[] | MessageSelectOptionData[][]): this; + public setOptions(...options: MessageSelectOptionData[] | MessageSelectOptionData[][]): this; public setCustomId(customId: string): this; public setDisabled(disabled?: boolean): this; public setMaxValues(maxValues: number): this;