【发布时间】:2022-01-14 23:00:06
【问题描述】:
我正在尝试使我的命令处理程序允许在文件夹中包含文件。例如,我有一个名为 ./commands/moderation 的文件夹,或者一个名为 ./commands/fun 的文件夹,等等。我该怎么做?
我的代码看起来像这样,但它只处理我的 ./commands 文件夹中的 JavaScript 文件。
for (const file of commandFiles) {
const command = require(`./commands/${file}`)
client.commands.set(command.name, command)
}
// ...
if (!client.commands.has(command)) return;
try {
client.commands.get(command).execute(message, args);
}
// ...
【问题讨论】:
标签: javascript node.js discord discord.js bots