我一直在尝试制作一个不和谐机器人,每次,我的机器人在聊天中发送一些东西,我得到这个错误写在控制台的标题中。
我代码:
client.on('message', (message) => {
if (!message.content.startsWith(prefix) || message.author.bot) return
const args = message.content.slice(prefix.length).split(/ +/)
const command = args.shift().toLowerCase()
if (command === 'ping') {
message.channel.send('pong!')
} else if (command === 'turn-off') {
if (message.author.id === '000000000000000000') {
message.channel.send('Shutting down...')
let interval0 = setInterval(turnOff, 1000)
function turnOff() {
clearInterval(interval0)
console.log('Shutting down...')
client.destroy()
}
} else {
message.channel.send(
"You don't have required permissions to use this command!"
)
}
}
})
我试着替换"message";messageCreate"它在聊天中发送一些东西,甚至替换每条"消息"。与"messageCreate".
有谁知道是什么问题吗?
您应该监听messageCreate
事件而不是message
事件:
client.on('messageCreate', message => {
/* ... */
})