我的代码需要帮助。我正在构建不和谐的机器人。我不知道我的代码有什么问题,但是它给出了
TypeError:无法读取未定义的属性“发送”
if(receivedMessage.content.startsWith("!")) {
processCommand(receivedMessage)
}
function processCommand(receivedMessage) {
let fullCommand = receivedMessage.content.substr(1)
let splitCommand = fullCommand.split(" ")
let primaryCommand = splitCommand[0]
let arguments = splitCommand.slice(1)
if (primaryCommand == "help") {
helpCommand(arguments, receivedMessage)
}
}
function helpCommand(arguments, receivedMessage){
if (arguments.length == 0) {
receivedMessage.channnel.send("Im not sure what are you looking for.Try
using `!help [topic]`")
} else {
receivedMessage.channel.send("It looks like you need help with " + arguments)
}
}
答案 0 :(得分:0)
TypeError: Cannot read property 'send' of undefined
告诉您receivedMessage.channnel
是未定义的,当您在行中仔细查看时:
receivedMessage.channnel.send("Im not sure what are you looking for.Try using `!help [topic]`")
您应注意,您所做的是cha
nnn
el
而不是channel