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

358
Views
Any action, except send messages, doesn't work in my collector, discordjs

I have this command:

if(prefix&&comando === 'gender'||prefix&&comando === 'pronome'){
        const embed = new MessageEmbed()
            .setColor(config.embed_default_color)
            .setTitle('Altere o seu pronome!')
            .setDescription('Quando mudá-lo, eu vou te tratar pelo pronome selecionado.')
            .addField('Selecione uma opção abaixo.', '- - - - - - - -');
        const row = new MessageActionRow()
            .addComponents(
                new MessageSelectMenu()
                    .setCustomId('select')
                    .setPlaceholder('Nothing selected')
                    .addOptions([
                        {
                            label: 'Pronome masculino',
                            value: 'men',
                            emoji: '🚹'
                        },
                        {
                            label: 'Pronome feminino',
                            value: 'woman',
                            emoji: '🚺'
                        },
                        {
                            label: 'Pronome indefinido',
                            value: 'indef',
                            emoji: '🟨'
                        },
                    ]),
            );
        await message.reply({ embeds: [embed], components: [row] }).then(msg => {
            const filtro = (interaction) =>
            interaction.isSelectMenu()
            const coletor = msg.createMessageComponentCollector({
                filtro
            });
            coletor.on('collect', async (collected) => {
                let gn = collected.values[0]
                collected.deferUpdate()
                if(gn==='men'){
                    msg.delete();
                    await message.channel.send(`${mention} **| ✅ Pronome alterado!**\nPronome atualizado para o masculino, Ele/dele.`);
                    gender = 'o';
                }
                else if(gn==='woman'){
                    msg.delete();
                    await message.channel.send(`${mention} **| ✅ Pronome alterado!**\nPronome atualizado para o feminino, Ela/dela.`);
                    gender = 'a';
                }
                else if(gn==='men'){
                    msg.delete();
                    await message.channel.send(`${mention} **| ✅ Pronome alterado!**\nPronome atualizado para indefinido.`);
                    gender = 'x';
                }
            })
        })
    }

and below, in the collector(on the if blocks), i have some actions, for when the user select one option in the dropdown menu, the message is sended, but i can't change any variable value there. exists one method to do this? I really need that. Thanks!

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Try to follow this guide, it is very complete

Here is an example of how it would be:



const { MessageActionRow, MessageSelectMenu } = require('discord.js');

    client.on('interactionCreate', async interaction => {
        if (!interaction.isCommand()) return;

        if (interaction.commandName === 'MenuOptions') {
            const row = new MessageActionRow()
                .addComponents(
                    new MessageSelectMenu()
                        .setCustomId('select')
                        .setPlaceholder('Nothing selected')
                        .setMinValues(2)
                        .setMaxValues(3)
                        .addOptions([
                            {
                                label: 'Select me',
                                description: 'This is a description',
                                value: 'first_option',
                            },
                            {
                                label: 'You can select me too',
                                description: 'This is also a description',
                                value: 'second_option',
                            },
                            {
                                label: 'I am also an option',
                                description: 'This is a description as well',
                                value: 'third_option',
                            },
                        ]),
                );

            await interaction.reply({ content: 'Example!!!!!!!!', components: [row] });
        }
    });
about 4 years ago · Santiago Trujillo 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!