From 52d8501d554d5858b4678d54ecd35fe6f7081073 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Susa=C3=B1a?= Date: Wed, 27 Mar 2024 15:58:03 -0400 Subject: [PATCH] fix: mentionables defaults (#162) --- src/builders/SelectMenu.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/builders/SelectMenu.ts b/src/builders/SelectMenu.ts index 7a40665..3141e99 100644 --- a/src/builders/SelectMenu.ts +++ b/src/builders/SelectMenu.ts @@ -177,6 +177,8 @@ export class RoleSelectMenu extends SelectMenu }; + /** * Represents a Select Menu for selecting mentionable entities. * @example @@ -187,6 +189,34 @@ export class MentionableSelectMenu extends SelectMenu = {}) { super({ ...data, type: ComponentType.MentionableSelect }); } + + /** + * Sets the default selected roles or users for the select menu. + * @param mentionables - Role/User id and type to be set as default. + * @returns The current MentionableSelectMenu instance. + */ + setDefaults(...mentionables: RestOrArray) { + this.data.default_values = mentionables.flat().map(mentionable => ({ + id: mentionable.id, + type: SelectMenuDefaultValueType[mentionable.type], + })); + return this; + } + + /** + * Adds default selected roles or users for the select menu. + * @param mentionables - Role/User id and type to be added as default. + * @returns The current MentionableSelectMenu instance. + */ + addDefaultMentionables(...mentionables: RestOrArray) { + this.data.default_values = (this.data.default_values ?? []).concat( + mentionables.flat().map(mentionable => ({ + id: mentionable.id, + type: SelectMenuDefaultValueType[mentionable.type], + })), + ); + return this; + } } /**