Node.js 如何使Discord bot仅忽略某些命令的设置前缀?(Discord.js)

Node.js 如何使Discord bot仅忽略某些命令的设置前缀?(Discord.js),node.js,discord.js,Node.js,Discord.js,我对Java非常陌生,正在尝试编写一个简单的机器人程序。当我第一次编写此代码时,它没有一个包含多个文件的命令处理程序,而且一切都正常。然而,虽然有些命令(如发送随机图像)仍然有效,但我无法找到一种方法使我的机器人忽略某些命令的前缀:例如,在我的机器人可以用“我在这里”响应“你在哪里?”之前,前面没有前缀“!”。当我在index.js文件中使用if语句包含此命令时,它仍然可以工作,但尝试将其放入另一个文件中却不行。如果有人能帮我,我将不胜感激 这是我的密码: index.js const disc

我对Java非常陌生,正在尝试编写一个简单的机器人程序。当我第一次编写此代码时,它没有一个包含多个文件的命令处理程序,而且一切都正常。然而,虽然有些命令(如发送随机图像)仍然有效,但我无法找到一种方法使我的机器人忽略某些命令的前缀:例如,在我的机器人可以用“我在这里”响应“你在哪里?”之前,前面没有前缀“!”。当我在index.js文件中使用if语句包含此命令时,它仍然可以工作,但尝试将其放入另一个文件中却不行。如果有人能帮我,我将不胜感激

这是我的密码:

index.js

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

const client = new discord.Client({ disableMentions: 'everyone' });

client.config = require('./config/bot');
client.commands = new discord.Collection();

fs.readdirSync('./commands').forEach(dirs => {
    const commands = fs.readdirSync(`./commands/${dirs}`).filter(files => files.endsWith('.js'));

    for (const file of commands) {
        const command = require(`./commands/${dirs}/${file}`);
        console.log(`Loading command ${file}`);
        client.commands.set(command.name.toLowerCase(), command);
    };
});

const events = fs.readdirSync('./events').filter(file => file.endsWith('.js'));

for (const file of events) {
    console.log(`Loading discord.js event ${file}`);
    const event = require(`./events/${file}`);
    client.on(file.split(".")[0], event.bind(null, client));
};

client.login(client.config.discord.token);
我的一些命令文件:

sendrand.js(这个有效)

where.js(这个没有)

我知道我可以让机器人响应“你在哪里”,但如果可能的话,我希望它不带前缀,你可以:

module.exports = {
  name: "respond",
  category: "general",
  execute(client, message) {
    if (message.content.toLowerCase().startsWith("where are you")) {
      message.reply("I am here!");
    }
  },
};

不幸的是,它仍然不起作用。。。我也试过使用前缀,但当我输入句子时,屏幕上什么也没有显示。还是谢谢你的帮助!
module.exports = {
    name: 'where',
    category: 'core',

    execute(client, message, args) {
        if(message.startsWith('where are you){
            message.channel.reply('I am here!)
    }
};
module.exports = {
  name: "respond",
  category: "general",
  execute(client, message) {
    if (message.content.toLowerCase().startsWith("where are you")) {
      message.reply("I am here!");
    }
  },
};