我正在VSC中使用discord.js编码一个不一致机器人,所有命令都在响应,只有一个命令例外,这是我试图创建的票据命令
本文介绍了我正在VSC中使用discord.js编码一个不一致机器人,所有命令都在响应,只有一个命令例外,这是我试图创建的票据命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在编写一个完整的AIO Discord Bot,例如您看到的&dyno Bot";或";Carl Bot";,我已经完成了ping
、avatar
等基本命令的编写。
我将转到一个更复杂的命令,如票证系统命令。我已经完成了所有代码,终端登录到机器人上很好,但由于某种原因,命令没有响应。我检查了其他命令以确保只有这个特定的命令。我相信这个解决方案很可能是个愚蠢的解决方案,但任何帮助都将不胜感激。
index.js
:
// Require the necessary discord.js classes
const fs = require('fs');
const { Client, Collection, Intents, DiscordAPIError } = require('discord.js');
const { token } = require('./config.json');
const prefex = '/';
const memberCounter = require('./counters/member-counter');
const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MESSAGE_REACTIONS,
],
});
client.commands = new Collection();
client.events = new Collection();
const commandFiles = fs
.readdirSync('./commands')
.filter((file) => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log("You are now connected to Boombap's Cookout!");
memberCounter(client);
});
client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand()) return;
const command = client.commands.get(interaction.commandName);
if (!command) return;
try {
await command.execute(interaction);
} catch (error) {
console.error(error);
return interaction.reply({
content: 'There was an error while executing this command!',
ephemeral: true,
});
}
});
// Login to Discord with your client's token
client.login(token);
ticket.js
module.exports = {
name: 'ticket',
aliases: [],
permissions: [],
description: 'open a ticket!',
async execute(message, args, cmd, client, discord) {
const channel = await message.guild.channels.create(
`ticket: ${message.author.tag}`,
);
channel.setParent('932184344011898890');
channel.updateOverwrite(message.guild.id, {
SEND_MESSAGE: false,
VIEW_CHANNEL: false,
});
channel.updateOverwrite(message.author, {
SEND_MESSAGE: true,
VIEW_CHANNEL: true,
});
const reactionMessage = await channel.send(
'Thank you for contacting support!',
);
try {
await reactionMessage.react('