按钮在执行命令后工作,但在重新启动机器人并按下按钮后,它显示interaction failedHere's my ticket.js
const { MessageButton } = require('discord-buttons');
module.exports = {
name: 'ticket-setup',
aliases: ['close'],
category: 'Miscellaneous',
description: 'Makes a ticket embed',
async execute(message, args, cmd, client, Discord){
if(!message.member.permissions.has("MANAGE_CHANNELS")) return message.reply("Normies can't do this command")
if (cmd == 'close') {
if (!message.channel.name.includes('ticket-')) return message.channel.send('You cannot use that here!');
message.channel.delete();
}
let title;
let desc;
let ticketMsg;
const filter = msg => msg.author.id == message.author.id;
let options = {
max: 1
};
message.channel.send("What will the ticket title be?\nSay cancel to cancel")
let col = await message.channel.awaitMessages(filter, options)
if(col.first().content == 'cancel') return message.channel.send("Cancelled");
title = col.first().content
message.channel.send('What will the description be?\nSay cancel to cancel')
let col2 = await message.channel.awaitMessages(filter, options)
if(col2.first().content == 'cancel') return message.channel.send("Cancelled");
desc = col2.first().content
message.channel.send('What is the message that the user will see when they make a ticket?\nSay cancel to cancel')
let col3 = await message.channel.awaitMessages(filter, options)
if(col3.first().content == 'cancel') return message.channel.send("Cancelled");
ticketMsg = col3.first().content
const setupEmbed = new Discord.MessageEmbed()
.setTitle(title)
.setDescription(desc)
.setFooter(message.guild.name, message.guild.iconURL({ dynamic: true }))
.setColor('00f8ff')
const hiEmbed = new Discord.MessageEmbed()
.addField(ticketMsg, "\n\nDo a.close or press the button to close the ticket")
.setColor("RANDOM")
.setTimestamp()
const createTicketButton = new MessageButton()
.setID("ticketCreate")
.setStyle("blurple")
.setLabel("");
const closeTicketButton = new MessageButton()
.setID("ticketClose")
.setLabel("Close ticket")
.setStyle("red");
if(cmd == 'ticket-setup'){
message.channel.send({embed: setupEmbed, button: createTicketButton })
}
client.on('clickButton', async (button) => {
await button.clicker.fetch();
await button.reply.defer();
const user = button.clicker.user
if (button.id === 'ticketCreate') {
button.guild.channels.create(`ticket-${user.id}`, {
permissionOverwrites: [
{
id: user.id,
allow: ['SEND_MESSAGES', 'VIEW_CHANNEL'],
},
{
id: button.message.guild.roles.everyone,
deny: ['VIEW_CHANNEL'],
},
],
type: 'text',
}).then(async (channel) =>{
channel.send({embed: hiEmbed, button: closeTicketButton })
})
} else if(button.id == 'ticketClose'){
button.message.channel.delete()
}
});
}
}
我使用包discord-buttons 文档链接
我尝试将 clickButton 事件放在我的事件处理程序中,但它没有工作,因为我得到了很多错误。即使重新启动后,我如何仍然使按钮工作?