0
votes

I am in the process of creating a Would You Rather command for my bot. I have everything in place, except one feature I can't work out how to implement.

I would love to have it so that when someone reacts with their answer (????️ or ????️) the bot then edits the embed and puts the user who replied under their answer like this:

enter image description here

The code I currently have is:

case "wyr":
            embed.setColor('#fc2803')
            embed.setTitle('Would You Rather?')
            embed.setDescription(':a: **Be able to fly** \n \n :b: **Breathe underwater**')
            
            message.channel.send(embed).then(m => m.react('????️')).then(r => r.message.react('????️')); 
1

1 Answers

1
votes

You can easily implement this using the discord.js-collector package. But if you want to make it using plaine discord.js, then you will have to listen to reactions when sending the embed, and then edit it to what you want like in the example i will give.

Simple Example Using The discord.js-collector package:

Code Here And Live Preview Here

Simple Example Using Plaine Discord.js:

const Discord = require("discord.js");

const embed = new Discord.MessageEmbed()
.setTitle("Hello There!");

const embedtosend = await message.channel.send(embed).then(m => m.react('🅰️')).then(r => r.message.react('🅱️'));

const filter = (reaction, user) => {
    return ['🅰️', '🅱️'].includes(reaction.emoji.name) && user.id === message.author.id;
};


message.awaitReactions(filter, { max: 2, time: 60000, errors: ['time'] })
    .then(collected => {
    const reaction = collected.first();

if (reaction.emoji.name === '🅰️') {
const someotherembed = new Discord.MessageEmbed()
.setTitle("This Is A Different Hello There!");

    embedtosend.edit(someotherembed)

  } else if (reaction.emoji.name === '🅱️') {
const anotherembed = new Discord.MessageEmbed()
.setTitle("This Is A Different Embed!");

    embedtosend.edit(anotherrembed)
    
  }
});

I haven't tested this code, so it might not work...