From e197656225f179c82ce21e4f6245780c2095c6e0 Mon Sep 17 00:00:00 2001 From: NekoCyan Date: Fri, 2 Dec 2022 13:11:55 +0700 Subject: [PATCH] feat(Message): .clickButton() click the only one. --- src/structures/Message.js | 11 +++++++++-- typings/index.d.ts | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/structures/Message.js b/src/structures/Message.js index 11ee800..fa5f2ae 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -1060,12 +1060,19 @@ class Message extends Base { } /** - * Click specific button - * @param {MessageButton|string} button Button ID + * Click specific button or automatically if only one. + * @param {MessageButton|string|null} button Button ID * @returns {Promise} */ clickButton(button) { let buttonID; + if (!button) { + if (this.components.length == 1 && this.components[0].type == 'ACTION_ROW') { + if (this.components[0].components.length == 1) { + buttonID = this.components[0].components[0].customId; + } + } + } if (button instanceof MessageButton) button = button.customId; if (typeof button === 'string') buttonID = button; if (!buttonID) { diff --git a/typings/index.d.ts b/typings/index.d.ts index 53f24db..be66750 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1974,7 +1974,7 @@ export class Message extends Base { // Added public markUnread(): Promise; public markRead(): Promise; - public clickButton(button: MessageButton | string): Promise; + public clickButton(button: MessageButton | string | null): Promise; public selectMenu(menuID: string, options: string[]): Promise; public selectMenu(options: string[]): Promise; public contextMenu(botID: Snowflake, commandName: string): Promise;