How to make a reaction menu Discord.js

Viewed 785

What I want to do is have a help menu, and when you react it sends a new embed (or edits the existing embed if that's easier). I have tried what seems to be every method but the right one for about a week and a half but I can't figure it out. I am very new to coding. Thank you for your time <3

This is my code...


module.exports = {
    name: 'help',
    description: "React to the emojis below",
    async execute(message, args, Discord, client) {

        let newEmbed = new Discord.MessageEmbed()
            .setColor('#FFEEA3')
            .setTitle('Help')
            .setDescription('React to the corresponding emoji below to to recieve more specific help.')
            .addFields(
                { name: 'Ban (Admin)', value: ':no_entry:' },
                { name: 'Clear (Admin)', value: ':person_with_probing_cane:' },
                { name: 'Kick (Admin)', value: ':leg:' },
                { name: 'Mute (Admin)', value: ':mute:' },
                { name: 'Unmute (Admin)', value: ':loud_sound:' },
                { name: 'Perms', value: ':lock:' },
                { name: 'Ping', value: ':ping_pong:' },
                { name: 'Rules', value: ':closed_book: ' },
            )

            .setFooter('Make sure to check out the help channel if there is one');

  let embedtwo = new Discord.MessageEmbed()
            .setColor('#FFEEA3')
            .setTitle('apple')
            .setDescription('apple');

 let embedthree = new Discord.MessageEmbed()
            .setColor('#FFEEA3')
            .setTitle('banana')
            .setDescription('banana');

        const MessageEmbed = await message.channel.send(newEmbed);
        MessageEmbed.react('⛔');
        MessageEmbed.react('‍');
        MessageEmbed.react('');
        MessageEmbed.react('');
        MessageEmbed.react('');
        MessageEmbed.react('');
        MessageEmbed.react('');
        MessageEmbed.react('');


        const filter = (reaction, user) => {
            return [banpg,clearpg].includes(reaction.emoji.name) && user.id === message.author.id;
        };
        message.awaitReactions(filter, { max: 1, time: 60000, errors: ['time'] })
        .then(collected => {
            const reaction = collected.first();

            if (reaction.emoji.name === '⛔')    
            {
            message.channel.send(embedtwo);

            } else if (reaction.emoji.name === '‍')
            message.channel.send(embedthree);
        
            
})

.catch(collected => {
    message.reply('you did not react in time');
});

}}```
1 Answers

try this code, but first type in your console npm i discord.js-collector

const { ReactionCollector } = require('discord.js-collector')

module.exports = {
    name: 'test',
    /** 
     * @param {Client} client 
     * @param {Message} message 
     * @param {String[]} args 
     */
    asyncL execute(client, message, Discord, args) {
        const pages = {
            '': {
                embed: {
                    title: 'Welcome Join Config',
                    description: `React below embed to configure channel or message of welcome settings.\n\n Channel settings\n Message settings`,
                },
                reactions: ['', ''],
                pages: {
                    '': {
                        backEmoji: '',
                        embed: {
                            description: 'Please mention or use channel id to set as welcome channel.'
                        },
                        onMessage: async (controller, message) => {
                            const channel = message.mentions.channels.first() || message.guild.channels.cache.get(message.content);
                            if (!channel)
                                return message.reply(' | You\'ve forgot mention a channel or use their id.').then((m) => m.delete({ timeout: 3000 }));
        
                            // Do what you want here, like set it on database...
                            return await message.reply(`✅ | Success! You've settled welcome channel as ${channel}.`).then(m => m.delete({ timeout: 3000 }));
                        }
                    },
                    '': {
                        backEmoji: '',
                        embed: {
                            description: 'Make the message used when a member join in the server.',
                        },
                        onMessage: async (controller, message) => {
                            // Do what you want here, like set it on database..
                            return await message.reply('✅ | Success!').then(m => m.delete({ timeout: 3000 }));
                        }
                    }
                }
            },
        };
        const embed = new MessageEmbed()
        .setTitle('Server Settings')
        .setDescription('React below to configure modules in this server.\n\n Welcome module')
    const botMessage = await message.reply(embed);
    ReactionCollector.menu({ botMessage, user: message.author, pages });
}
    }

just replace it with your needs :)

Related