我遇到这个问题
setInterval(function(){
var randommessage = Math.floor(Math.random() * 5) + 1;
var randomsentence = Math.floor(Math.random() * 10) + 1;
if(randommessage === 1){
console.log("Silence...")
} else {
if(randomsentence === 1){
client.channels.get('532065669718736906').send("Do you ever wonder why we were born... whats our purpose?")
} else if(randomsentence === 2){
client.channels.get('532065669718736906').send("So... you come here often?")
} else if(randomsentence === 3){
client.channels.get('532065669718736906').send("What is the point of this server?")
} else if(randomsentence === 4){
client.channels.get('532065669718736906').send("Why do i exist?")
} else if(randomsentence === 5){
client.channels.get('532065669718736906').send("Why are we still here... just to suffer..")
} else if(randomsentence === 6){
client.channels.get('532065669718736906').send("Begels are life!")
} else if(randomsentence === 7){
client.channels.get('532065669718736906').send("Banana Bros!!")
} else if(randomsentence === 8){
client.channels.get('532065669718736906').send("Is the number 3 a myth?")
} else if(randomsentence === 9){
client.channels.get('532065669718736906').send("*Shuffles through papers*")
} else if(randomsentence === 10){
client.channels.get('532065669718736906').send("In the end.. it doesnt even matter!")
} else {
client.channels.get('532065669718736906').send("randomness is gud")
}
}
}, 3000);
应该发送定期消息,但我收到错误消息
TypeError: Cannot read property 'send' of undefined
at Timeout._onTimeout (C:\Users\User\Documents\Discord Intro Bot\index.js:52:46)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7)
我已经尝试过在阳光下进行的所有操作,甚至在事先找到频道然后发送给它的情况下,都试图解决此问题,但它仍然认为该频道不存在。
我不想使用 on消息,因为我的服务器非常不活跃,我正在使用它来给机器人增加一些情感