From cb8bb6e0ec802d5c498759ea5bb5ef6f8229f8fb Mon Sep 17 00:00:00 2001 From: Qreepex <65496825+Qreepex@users.noreply.github.com> Date: Sun, 12 Jun 2022 13:18:04 +0200 Subject: [PATCH] feat(buttons): add deferupdate to commandbutton --- package.json | 2 +- src/structures/ButtonArgs.ts | 4 ++++ src/structures/CommandButton.ts | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 125ac15..f67233b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eazyautodelete/eazyautodelete-core", - "version": "1.5.1", + "version": "1.5.2", "description": "🧰 Core Package used by the EazyAutodelete Discord Bot", "main": "build/index.js", "scripts": { diff --git a/src/structures/ButtonArgs.ts b/src/structures/ButtonArgs.ts index b0cbac3..dd88093 100644 --- a/src/structures/ButtonArgs.ts +++ b/src/structures/ButtonArgs.ts @@ -9,6 +9,10 @@ export default class ButtonArgs { this.command = this.getCommand(); } + isCommand(): boolean { + return this.button.interaction.customId?.startsWith("cmd_") || false; + } + getCommand(): string { return this.button.interaction.customId.split("_")[1] as string; } diff --git a/src/structures/CommandButton.ts b/src/structures/CommandButton.ts index 8a4c1ba..ea8b4ee 100644 --- a/src/structures/CommandButton.ts +++ b/src/structures/CommandButton.ts @@ -123,9 +123,19 @@ export default class CommandButton { return this; } - async continue(): Promise { + async continue(ephemeral: boolean = true): Promise { try { - await this.interaction.deferReply().catch(this.Logger.error); + await this.interaction.deferReply({ ephemeral: ephemeral}).catch(this.Logger.error); + } catch (e) { + this.Logger.error(e as string); + } + + return this; + } + + async deferUpdate() { + try { + await this.interaction.deferUpdate().catch(this.Logger.error); } catch (e) { this.Logger.error(e as string); }