Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Discord js v12 Send message if someone reacts to embed

I’m currently making a discord bot using discord.js v12 (yes 12 not 13), I made a command that the bot sends an embed and reacts to it, in the filter I set the max to 2 (max: 2, …). I want that every time someone reacts with this embed that like his name will be send in the channel. My current concept is this(it’s in a function because I don’t want to but everything in the switch):

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 => {
                    
  })
}

Right before the last }) should be the code for the answer (I guess).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Use Message#createReactionCollector instead, and listen for the collect event

const reactionMessage2p = await message.channel.send(embed2p);
const filter2p = (reaction, user) => user.id !== bot

await reactionMessage2p.react('🍻')

const collector = message.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`)
})

You can change the message to whatever you want

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading