module.exports.config = {
name: "av",
aliases: ["icon", "pfp"]
};
索引主文件:
bot.commands = new Discord.Collection();
bot.aliases = new Discord.Collection();
fs.readdir("./commands/general", (err, files) => {
if (err) console.log(err);
let jsfile = files.filter(f => f.split(".").pop() === "js");
if (jsfile.length <= 0) {
console.log("Couldn't find the general commands.");
return;
}
jsfile.forEach((f, i) => {
let props = require(`./commands/general/${f}`);
console.log(`${f} loaded!`);
bot.commands.set(props.config.name, props);
bot.aliases.set(props.config.name);
});
});
留言
const command = bot.commands.get(commandName) || bot.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
注意:所有命令都运行良好,但尝试使用不同方式多次修复别名。