Javascript 我的discord机器人正在忽略包含大写字母的命令

Javascript 我的discord机器人正在忽略包含大写字母的命令,javascript,discord,discord.js,Javascript,Discord,Discord.js,所以我试着组装一个机器人,我发现无论出于什么原因,它都不会响应任何包含大写字母的命令。我的意思是,它已经定义了包含大写字母的命令,但是机器人实际上不会在包含大写字母的命令中运行代码。我在下面输入的开关/案例中定义了我的命令,它使用从主文件传递到命令文件的对象的属性 switch (command.call) { case 'ping': message.reply(`Pong! This message had a latency of ${latency}ms.`); cons

所以我试着组装一个机器人,我发现无论出于什么原因,它都不会响应任何包含大写字母的命令。我的意思是,它已经定义了包含大写字母的命令,但是机器人实际上不会在包含大写字母的命令中运行代码。我在下面输入的开关/案例中定义了我的命令,它使用从主文件传递到命令文件的对象的属性

switch (command.call) {
  case 'ping':
    message.reply(`Pong! This message had a latency of ${latency}ms.`);
  console.log(`Received message $ping, responded with latency of ${latency}ms.`);
    break;

  case 'help':
    message.reply('Current commands available:\n  \`$ping\`: Get the latency of the bot.\n  \`$help\`: Show this message.\n  \`$setPrefix\` \`[arg]\`: Set the prefix to a given string, \`[arg]\`');
    console.log(`Received message $help, responded with latency of ${latency}ms.`);
    break;

  case 'setPrefix':
    message.reply(`Set the new prefix to ${config.prefix}`);
    console.log(`Received message $setPrefix, responded with latency of ${latency}ms.`);
    break;

  case 'Test':
    message.reply('I got your message!');
  console.log(`Received message $test, responded with latency of ${latency}ms.`);
    break;
  }
}
因此,命令ping和help可以正常工作,但当我尝试调用setPrefix或Test时,bot不会执行任何操作

这是我将命令传递到定义命令的文件的代码:

  commandBody = message.content.slice(config.prefix.length), //Get the body of the command
  args = commandBody.split(' '), //Get the command arguments
  call = args.shift().toLowerCase() //Get the command

  const command = {
    commandBody: commandBody,
    args: args,
    call: call
  }

  commands(command, message); //Call the given command from commands.js

调用命令的最后一行引用了定义bot的命令的文件。toLowerCase

添加到您的代码中。toLowerCase

.toLowerCase您认为这是什么?我希望命令是区分大小写的文本,这就是为什么我要问的。如果我希望所有内容都是小写的,那么我就不会对thiscall=args.shift.toLowerCase//获取命令有任何问题哦,我没有看到aaaaaaa我从随机教程中获得了那么多代码,所以我没有意识到ofc。很抱歉