Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Commit

Permalink
feat(buttons): add deferupdate to commandbutton
Browse files Browse the repository at this point in the history
  • Loading branch information
Qreepex committed Jun 12, 2022
1 parent a7b28b9 commit cb8bb6e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions src/structures/ButtonArgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
14 changes: 12 additions & 2 deletions src/structures/CommandButton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,19 @@ export default class CommandButton {
return this;
}

async continue(): Promise<CommandButton> {
async continue(ephemeral: boolean = true): Promise<CommandButton> {
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);
}
Expand Down

0 comments on commit cb8bb6e

Please sign in to comment.