【发布时间】:2020-07-20 14:39:11
【问题描述】:
我最近试图制作一个不和谐的机器人(使用节点),但我一直遇到“无法读取未定义的属性 'toLowerCase'”。我尝试将“toLowerCase”更改为“toUpperCase”,但没有解决问题。
client.on('ready', () => {
console.log("The bot is online!");
client.user.setActivity('Servers', { type: 'WATCHING' });
});
const isCommand = (message, cmdName) => message.content.toLowerCase().startsWith(PREFIX + cmdName);
const rollDice = () => Math.floor(Math.random() * 6) + 1;
client.on('message', function (message){
if(message.author.bot) return;
if(isCommand(message + "hello"))
message.reply(" Hi! I didn't want to make you feel lonely so I wanted to say hi.");
if(isCommand(message , "rolldice")) {
message.reply("You rolled a "+ rollDice());
}
});
【问题讨论】:
-
这个
if(isCommand(message + "hello"))不应该是if(isCommand(message ,"hello"))
标签: javascript node.js discord.js