Home > Blockchain >  How to add reactions to an embed message
How to add reactions to an embed message

Time:06-28

const { Client, Message, MessageEmbed, Intents } = require("discord.js");

module.exports = {
    name: "sbfeedback",
    /**
    * @parom {Client} client
    * @parom {Message} message
    * @parom {String[]} args
    */
     async execute(client, message, args) {
        const questions = [
            "What feedback would you like to give?",
            "Anything else you would like to add?"
        ];
          
        let collectCounter = 0;
        let endCounter = 0;
         
        const filter = (m) => m.author.id === message.author.id;
        
        const appStart = await message.author.send(questions[collectCounter  ]);
        const channel = appStart.channel;
        
        const collector = channel.createMessageCollector(filter);
        message.delete({timeout: 100})

        collector.on("collect", () => {
            if (collectCounter < questions.length) {
                channel.send(questions[collectCounter  ]);
            } else {
                channel.send("Thank you for your feedback! If you would like to suggest anything else please do so with `-sbfeedback`.");
                collector.stop("fulfilled");
            }
        });

        const appsChannel = client.channels.cache.get("886099865094983691");
        collector.on("end", (collected, reason) =>{
            if (reason === "fulfilled") {
                let index = 1;
                const mappedResponses = collected
                    .map((msg) => { 
                        return `${index  }) ${questions[endCounter  ]}\n-> ${msg.content}`;
                    })
                    .join("\n\n");
                        
                appsChannel.send(
                    new MessageEmbed()
                        .setAuthor(message.author.tag, message.author.displayAvatarURL({ dynamic: true}))
                        .setTitle("!")
                        .setDescription(mappedResponses)
                        .setColor(`RANDOM`)
                        .setTimestamp()
               
                );
                message.react('           
  • Related