(discord.js) 如何提及对机器人消息做出反应的用户?

时间:2021-04-06 13:06:13

标签: node.js reactjs discord discord.js mention

我如何提及对我的机器人消息做出反应的用户?
我想发送诸如“@user 对我的消息做出反应!”之类的消息,这是我的代码:

msg.awaitReactions((reaction, user) => user.id == user.id && (reaction.emoji.name == '?'), { max: 1, time: 30000 }).then(collected => {
    if (collected.first().emoji.name == '?') {
        //here I want to send the message with the mention
    } else {
        //I added it for case that I going to use yes or no react question
    }
}).catch(() => {
    //maybe I will add here message that says the time passed.
});

1 个答案:

答案 0 :(得分:2)

阅读文章和故障排除后,我想出了以下解决方案:

msg.awaitReactions((reaction, user) => user.id == user.id && (reaction.emoji.name == '?'),
{ max: 1, time: 30000 }).then(collected => {
    const reaction = collected.first();
    if (collected.first().emoji.name == '?') {
        const member = reaction.users.cache.find((user) => !user.bot);
        message.channel.send(`test is ${member}`)
    } else
        //I added it for case that I gonna use yes or no react question
}).catch(() => {
    //maybe I will add here message that says the time passed.
});