Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
how to set a default value for the dropdown menu with discord.js v13

I am making a help command that when you execute it, shows an embed with a dropdown menu to select a category. The code works perfectly fine but I just wanted to know how to set a default value for the dropdown menu. Can anyone help me with that?

my code is:

const helpEmbed = new Discord.MessageEmbed()
            .setColor(696969)
            .setTitle("No category selected")

        const select = new Discord.MessageSelectMenu()
            

        for (const category of categoriesFolders) {
            const len = category.length;

            if (fs.readdirSync(`./commands/${category}`).length < 1) {continue};
            select.addOptions([{
                label: uppercaseFirst(category.substring(0, len - '-commands'.length)),
                value: category.substring(0, len - '-commands'.length)
            }]);
        }
        
        const row = new Discord.MessageActionRow().addComponents(select);
        
        const filter = (interaction) =>
            interaction.isSelectMenu() &&
            interaction.user.id === message.author.id;

        const collector = message.channel.createMessageComponentCollector({
            filter
        })

        collector.on('collect', async(collected) => {
            const value = collected.values[0];

            const embed = new Discord.MessageEmbed()
                .setColor(696969)


            const fls = fs.readdirSync(`./commands/${collected.values[0]}-commands`).filter(file => file.endsWith('.js'));
            for (const cmd of fls) {
                const command = require(`../${collected.values[0]}-commands/${cmd}`)
        
                let val = `${command.name}`
                embed.addField(val, command.description);
            }

            collected.message.edit({ embeds: [embed] }).catch(() => {});
            await collected.deferUpdate();
        })

        message.channel.send({ embeds: [helpEmbed], components: [row] });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

To make one of dropdown menu values default you need to add default to one of your values and set it to true!

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!