![](/img/trans.png)
[英]How do I make discord bot have an emoji reaction after it sends its message in discord.js?
[英]How can I make Discord Bot detect emoji reaction and click(trigger) it
所以我的问题是
场景:假设我的服务器中有一个机器人发送标题为“Hello”的嵌入消息,并在其下添加一个随机反应,其作用类似于触发器。
我想要做什么:我希望我的机器人检测该嵌入消息的标题,如果它与我的 if 语句匹配,那么它还会单击/添加与嵌入机器人放在它下面的相同反应。 如果有任何困惑,请告诉我。
此代码仅适用于新消息和缓存消息,
client.on("messageReactionAdd", (reaction, user) => {
const message = reaction.message;
const embeds = message.embeds;
//return if no embeds or if another user reacted instead of the bot itself
if(!embeds.length || user.id !== message.author.id) return;
const firstEmbed = embeds[0];
//add your logic here
if(firstEmbed.title !== "Hello") {
//react same
message.react(reaction.emoji);
}
});
要过滤掉嵌入,您可能需要参考
https://discord.js.org/#/docs/main/12.2.0/class/MessageEmbed
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.