当我为不和谐的bot输入命令时,它说它两次确认了该命令,有人知道如何解决此问题吗?

时间:2020-10-04 15:20:29

标签: visual-studio-code discord discord.js

因此,当我使用不和谐的机器人kick命令时,它会说两次。我尝试过重新启动Visual Studio Code,但仍然无法正常工作。我没有重复我的代码或任何东西,所以我对可能是什么问题感到很困惑

 const Discord = require('discord.js');

    const client = new Discord.Client();

   const prefix = '!';


    const fs = require('fs');

     client.commands = new Discord.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);
 }

 client.once('ready', () => {

console.log('KeyBot在线!'); });

 client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;

   const args = message.content.slice(prefix.length).split(/ +/);
   const command = args.shift().toLowerCase();

   if (command === 'ping') {
     message.channel.send('pong!');
   }
 });



 client.on('message', (message) => {
  if (!message.guild) return;

  if (message.content.startsWith('!kick')) {
   const user = message.mentions.users.first();

   if (user) {
    const member = message.guild.member(user);

   if (member) {
   member
  .kick('Optional reason that will display in the audit logs')
  .then(() => {
   message.reply(`Successfully kicked ${user.tag}`);
  })
  .catch((err) => {
   message.reply('I was unable to kick the member');

   console.error(err);
  });
   } else {
 message.reply("That user isn't in this guild!");
 }
  } else {
message.reply("You didn't mention the user to kick!");
 }
 }


 });

0 个答案:

没有答案