From 7655768c30778ae7384b3ea36a42b3e591d263c5 Mon Sep 17 00:00:00 2001 From: Taken Date: Mon, 9 Sep 2024 22:36:01 +0200 Subject: [PATCH] Updated buttonhandler to ignore tempbuttons --- src/commands/staff/prune.ts | 4 ++-- src/events/server/interactions/logBtnsCmds.ts | 10 +++++++++- src/utils/Events/button.ts | 5 ++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/commands/staff/prune.ts b/src/commands/staff/prune.ts index d890013..0392e09 100644 --- a/src/commands/staff/prune.ts +++ b/src/commands/staff/prune.ts @@ -35,8 +35,8 @@ export default async function prune(interaction: ChatInputCommandInteraction): P } const id = Math.random().toString(32).slice(2) - const buttonid = "button-" + id - const cancelid = "cancel-" + id + const buttonid = `tempbutton-pruneconfirm-${id}` + const cancelid = `tempbutton-prunecancel-${id}` await interaction.editReply({ embeds: [{ diff --git a/src/events/server/interactions/logBtnsCmds.ts b/src/events/server/interactions/logBtnsCmds.ts index 3074ed1..d79ff1b 100644 --- a/src/events/server/interactions/logBtnsCmds.ts +++ b/src/events/server/interactions/logBtnsCmds.ts @@ -41,11 +41,19 @@ export default { } if (interaction.isButton()) { + const customId = interaction.customId + let btnId: string = "" + + if (customId.startsWith("tempbutton-")) { + btnId = customId.split("-")[1] + btnId = btnId.split("-")[0] + } + console.log( color( interaction.user.username + "#" + interaction.user.discriminator + " clicked " + - interaction.customId, + btnId, "pink" ) ) diff --git a/src/utils/Events/button.ts b/src/utils/Events/button.ts index ba98041..d41671a 100644 --- a/src/utils/Events/button.ts +++ b/src/utils/Events/button.ts @@ -32,7 +32,10 @@ export default async function loadButtonEvents(client: Client, ft: FileType) { client.on(Events.InteractionCreate, async interaction => { if (!interaction.isButton()) return - const button = client.buttons.get(interaction.customId) + const customId = interaction.customId + if (customId.startsWith("tempbutton-")) return + + const button = client.buttons.get(customId) if (!button) { console.error(`No event matching ${interaction.customId} was found.`)