我已经从以下代码中找出了如何让机器人对其消息做出反应:
if(message.content === "!start"){
message.channel.send(serve).then(message => {
message.react('764193096060764211');
})
}
(serve 是一个存储在变量中的嵌入)
我希望用户对它做出反应,而机器人可以利用该信息做一些事情,例如,将值 1 存储到一个名为startingServe 的变量中。如果用户在 5 秒内没有反应,我希望机器人发送消息“玩家结束”。我该怎么做呢?期待社区的帮助!如果还有什么需要我回答这个问题,可以问。
答案 0 :(得分:0)
使用这样的东西:
var startingServe = 0
message.awaitReactions(filter, { max: 1, time: 5000, errors: ['time'] })
.then(collected => {
const reaction = collected.first();
if (reaction.emoji.id == "764193096060764211") {
startingServe = 1
} else {
message.channel.send('Gamer Ended')
}
})
.catch(collected => {
message.channel.send('Gamer Ended');
});
this 指南页面上的来源和更多信息。