【发布时间】:2021-09-30 06:48:32
【问题描述】:
您好,我在 discord.js 中遇到了别名问题,别名不起作用,我不知道为什么?
client.on('message', message =>{
// Exit when the message from the bot
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).trim().split(/ +/);
const commandName = args.shift().toLowerCase();
if (!client.commands.has(commandName)) return;
const command = client.commands.get(commandName) || client.commands.find(cmd => cmd.aliases && cmd.aliases.includes(commandName));
try {
command.execute(message, args, commandName, client, Discord);
} catch (error) {
console.error(error);
message.reply('there was an error trying to execute that command!');
}
});
【问题讨论】:
-
如何分配别名?我个人的做法与 discord.js 的“推荐”方式不同
标签: javascript discord.js