(discord.js) 如何提及对机器人消息做出反应的用户?
Posted
技术标签:
【中文标题】(discord.js) 如何提及对机器人消息做出反应的用户?【英文标题】:(discord.js) how to mention the user who react to the bot message? 【发布时间】:2021-07-02 06:32:02 【问题描述】:如何提及对我的机器人消息做出反应的用户?我想发送类似“@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.
);
【问题讨论】:
this 对您有帮助吗? 【参考方案1】:在阅读文章和故障排除后,我想出了以下解决方案:
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.
);
【讨论】:
以上是关于(discord.js) 如何提及对机器人消息做出反应的用户?的主要内容,如果未能解决你的问题,请参考以下文章
如何让我的 Discord.JS 机器人对其自己的直接消息做出反应?
当用户对消息做出反应时,机器人会在 discord.js 中发送另一条消息
Discord.js v12 如何获取对特定消息做出反应的人的 id?