我如何制作也会扫描文件夹的命令处理程序?

时间:2019-10-20 09:28:01

标签: discord.js

我正在制造一个不和谐的机器人,所以,我已经做了太多的命令,现在我需要将它们放在自己的文件夹中,例如审核,杂项等。

const commandFlies = fs.readdirSync('./ commands')。filter(file => file.endsWith('。js'));

for(commandFlies的常量文件){     const command = require(./commands/misc/${file});

// set a new item in the Collection
// with the key as the command name and the value as the exported value
client.commands.set(command.name, command);

}

const cooldowns = new Discord.Collection();
client.commands = new Discord.Collection();
const commandFlies = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));


for (const file of commandFlies) {
    const command = require(`./commands/${file}`);

    // set a new item in the Collection
    // with the key as the command name and the value as the exported value
    client.commands.set(command.name, command);
}

它不断告诉我它已经定义了。

0 个答案:

没有答案