愿所有的美好和期待都能如约而至

我正在VSC中使用discord.js编码一个不一致机器人,所有命令都在响应,只有一个命令例外,这是我试图创建的票据命令

发布时间:  来源:互联网  作者:匿名  标签:discord discord.js error I'm coding a discord bot using discord.js in V  热度:37.5℃

本文介绍了我正在VSC中使用discord.js编码一个不一致机器人,所有命令都在响应,只有一个命令例外,这是我试图创建的票据命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写一个完整的AIO Discord Bot,例如您看到的&dyno Bot"或"Carl Bot",我已经完成了pingavatar等基本命令的编写。

我将转到一个更复杂的命令,如票证系统命令。我已经完成了所有代码,终端登录到机器人上很好,但由于某种原因,命令没有响应。我检查了其他命令以确保只有这个特定的命令。我相信这个解决方案很可能是个愚蠢的解决方案,但任何帮助都将不胜感激。

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('

勇敢去编程!

勇敢的热爱编程,未来的你一定会大放异彩,未来的生活一定会因编程更好!

TOP