Discord 当用户对消息作出反应时,如何将值存储到变量?

Discord 当用户对消息作出反应时,如何将值存储到变量?,discord,discord.js,Discord,Discord.js,我已经通过以下代码了解了如何使机器人对其消息作出反应: if(message.content === "!start"){ message.channel.send(serve).then(message => { message.react('764193096060764211'); }) } (serve是存储在变量中的嵌入) 我希望用户对它做出反应,机器人对这些信息进行处理,例如,将值1存储到名为star

我已经通过以下代码了解了如何使机器人对其消息作出反应:

if(message.content === "!start"){
        message.channel.send(serve).then(message => {
            message.react('764193096060764211');
        })
}
(serve是存储在变量中的嵌入)


我希望用户对它做出反应,机器人对这些信息进行处理,例如,将值1存储到名为startingservice的变量中。如果用户在5秒内没有反应,我希望机器人显示消息“Gamer Ended”。我该怎么做?期待来自这个社区的帮助!如果我还需要回答这个问题,可以提问。

使用以下方式:

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');
    });
指南页上的来源和更多信息