Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

349
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda