Updated buttonhandler to ignore tempbuttons

This commit is contained in:
2024-09-09 22:36:01 +02:00
parent fc50bc7a78
commit 7655768c30
3 changed files with 15 additions and 4 deletions

View File

@@ -35,8 +35,8 @@ export default async function prune(interaction: ChatInputCommandInteraction): P
} }
const id = Math.random().toString(32).slice(2) const id = Math.random().toString(32).slice(2)
const buttonid = "button-" + id const buttonid = `tempbutton-pruneconfirm-${id}`
const cancelid = "cancel-" + id const cancelid = `tempbutton-prunecancel-${id}`
await interaction.editReply({ await interaction.editReply({
embeds: [{ embeds: [{

View File

@@ -41,11 +41,19 @@ export default {
} }
if (interaction.isButton()) { if (interaction.isButton()) {
const customId = interaction.customId
let btnId: string = ""
if (customId.startsWith("tempbutton-")) {
btnId = customId.split("-")[1]
btnId = btnId.split("-")[0]
}
console.log( console.log(
color( color(
interaction.user.username + "#" + interaction.user.username + "#" +
interaction.user.discriminator + " clicked " + interaction.user.discriminator + " clicked " +
interaction.customId, btnId,
"pink" "pink"
) )
) )

View File

@@ -32,7 +32,10 @@ export default async function loadButtonEvents(client: Client, ft: FileType) {
client.on(Events.InteractionCreate, async interaction => { client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isButton()) return 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) { if (!button) {
console.error(`No event matching ${interaction.customId} was found.`) console.error(`No event matching ${interaction.customId} was found.`)