我最近开始对使用Javascript和node.js制作不和谐的机器人感兴趣。我正在尝试发出旋转虚拟“彩票”的命令,并发送一条消息告诉用户他们是否收到了任何东西。 (这是我的代码:)
`
function lotteryCommand(arguments, receivedMessage){
/*note: receivedMessage is defined as the command (for my bot, it's e!spin)
and arguments is the part following the command (for this particular bit of code,
it's merits, so the user sends "e!spin merits")*/
if (arguments == "merits"){
setTimeout(randomlottery1, 1000);
}
else{receivedMessage.channel.send("Message here")}
}
这是另一个功能。 这是它停止工作的地方
function randomlottery1(arguments, receivedMessage){
let respond;
let responses = [
//some random phrases here
]
respond = responses[Math.floor(Math.random() * responses.length)]
receivedMessage.channel.send(respond)
}
由于某种原因,我无法理解,它无法在channel
函数的{em>秒时间里receivedMessage.channel.send
识别randomlottery1
,但是它识别出了在代码前面命令。我在这里做错什么吗?谢谢。