所以我的问题是
场景: 假设我的服务器中有一个机器人发送一条标题为“Hello”的嵌入消息,并在其下方添加一个随机 react ,其作用类似于触发器。
我想做的事: 我希望我的机器人能够检测该嵌入消息的标题,如果它与我的 if 语句匹配,那么它还会单击/添加嵌入机器人在其下方放置的相同 react 。 如果有任何困惑,请告诉我。
最佳答案
此代码仅适用于新消息和缓存消息,
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
关于javascript - 如何让 Discord Bot 检测表情符号 react 并单击(触发)它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62291369/