在我的不和谐机器人中,我有一个打乱单词的命令,第一个在聊天中做出响应的用户将获得奖励。我已经发出了等待消息响应的命令,但是如何保存响应者?到目前为止,这是我的代码
authorID = msg.author.id;
const filter = response => {
return response.author.id === authorID;
}
msg.channel.awaitMessages(filter, {
max: 1,
time: 5000
})
.then(mg2 => {
if (mg2.first().content === "1") {
msg.channel.send("you said 1");
}
});
使用过滤器,您只允许原始 msg 作者输入,您应该使其检测 msg.content 是否等于未拼写的单词。你也没有errors: ["time"]
。
const filter = m => m.content === unscrabledWord;
msg.channel.awaitMessages(filter, { max: 1, time: 5000, errors: ["time"] })
.then(collected => {
const winner = collected.first().author;
msg.channel.send(`${winner} Won!`)
})
.catch(() => msg.channel.send("Nobody guessed it"));
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句