I recently embarked on creating my own discord bot. I successfully implemented a command with buttons, but encountered an issue with making the button functionality persist after a restart. Every time I restart, the buttons display an "interaction failed" message. I attempted to create my own interactionCreate.ts file to address this problem, but unfortunately, I couldn't get it to work properly. Any help or guidance would be greatly appreciated! Thank you in advance.
import { Interaction, MessageActionRow, MessageButton, MessageComponentInteraction } from "discord.js";
import { ICommand } from "wokcommands";
export default {
category: 'testing',
description: 'Returns a Button',
slash: true,
testOnly: true,
callback: async ({interaction:msgInt,channel}) =>{
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('Accept')
.setEmoji('👍')
.setLabel('ACCEPT')
.setStyle('SUCCESS')
)
.addComponents(
new MessageButton()
.setCustomId('Tenative')
.setEmoji('🤷♂️')
.setLabel('TENATIVE')
.setStyle('PRIMARY')
)
await msgInt.reply({
content: 'Are you sure?',
components: [row],
})
const collector = channel.createMessageComponentCollector({
max: 10,
})
collector.on('collect', (i: MessageComponentInteraction) => {
console.log(`Button with id: ${i.customId} was pressed by ${i.user.username}`)
i.reply({
content: `Button with id: ${i.customId} was pressed by ${i.user.username}`,
ephemeral: true
})
})
collector.on('end', async (collection) => {
collection.forEach((click) => {
console.log(click.user.id, click.customId)
})
})
},
} as ICommand