我试图用 discord.js 做一个 afk 命令 我不断收到 command.execute 不是一个函数,我不知道如何修复它。请帮忙!
client.on("message", async message => {
if (message.author.client) return;
if (message.channel.type === "dm") return;
let prefix = config.prefix;
let messageArray = message.content.split(" ");
let command = messageArray[0].toLowerCase();
let args = messageArray.slice(1);
if (message.content.includes(message.mentions.members.first())) {
let mentioned = client.afk.get(message.mentions.users.first().id);
if (mentioned) message.channel.send(`**${mentioned.usertag}** is currently afk. Reason: ${mentioned.reason}`);
}
let afkcheck = client.afk.get(message.author.id);
if (afkcheck) return [client.afk.delete(message.author.id), message.reply(`you have been removed from the afk list!`).then(msg => msg.delete(5000))];
if (!command.startsWith(prefix)) return;
let cmd = client.commands.get(command.slice(prefix.length));
if (cmd) cmd.run(client, message, args);
});```
答案 0 :(得分:0)
在您的函数范围内,$ export PATH="$PATH:$(go env GOPATH)/bin"
是等于 command
的变量,它是一个字符串并且没有 messageArray[0].toLowerCase();
方法。
我猜您正在尝试调用您称为 command 的对象的 execute
方法,请尝试更改变量的命名以避免覆盖您需要的变量。