如果有人对嵌入做出反应,则不一致js v12发送消息 [英] Discord js v12 Send message if someone reacts to embed
本文介绍了如果有人对嵌入做出反应,则不一致js v12发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前正在使用discord.jsV12(是的12不是13)制作一个不和谐的机器人,我发出了一个命令让机器人发送一个嵌入并对其做出反应,在过滤中我将最大值设置为2(最大值:2,.)。我希望每次有人用这个嵌入器做出反应时,他的名字就会被发送到频道中。我目前的概念是这样的(它在一个函数中,因为我不想这样做,但开关中的所有内容都是这样的):
async function fun_2p() {
const reactionMessage2p = await message.channel.send(embed2p);
const filter2p = (reaction, user) => user.id !== bot;
await reactionMessage2p.react('🍻')
reactionMessage2p.awaitReactions( filter2p, {max: 2, time: 20000, errors: ['time'] }).then(collected => {
})
}
紧接在最后})
之前的应该是答案的代码(我想)。
推荐答案
改用Message#createReactionCollector
,并侦听collect
事件
const reactionMessage2p = await message.channel.send(embed2p);
const filter2p = (reaction, user) => user.id !== bot
await reactionMessage2p.react('🍻')
const collector = reactionMessage2p.createReactionCollector(filter2p, {max: 2, time: 20000, errors: ['time'] })
collector.on("collect", (reaction, user) => {
reaction.message.channel.send(`${user.tag} has just reacted to the message`)
})
您可以将消息更改为您想要的任何内容
这篇关于如果有人对嵌入做出反应,则不一致js v12发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文