Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

527
Visualizações
How do i get the value of a select menu after pressing a button? (discord.js)

I have a message with 2 action rows. One contains a select menu, and the other contains a button. How do i get the selected item from the select menu when the button is pressed?

I have this following code so far:

if (interaction.isButton()) {
        if (interaction.customId == 'deleteTask') {
            console.log("Deleting task!")
            console.log(taskName)
            delete(taskName)
        }
 }

I need the variable taskName to be the selected option in a select menu. The select menu is in the same message as the button, and it has the custom Id 'selectTask'. This is the code for the select menu and button menu:

const row = new MessageActionRow() // Define action row
            .addComponents(
                new MessageSelectMenu() // Add task selector
                    .setCustomId('selectTask')
                    .setPlaceholder('Select an assignment..')
                    .addOptions(choices),
            );

const btnrow = new MessageActionRow() // Define action row
            .addComponents(
                new MessageButton()
                    .setCustomId('deleteTask')
                    .setLabel("Delete task")
                    .setStyle("DANGER"),
            );
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If you already have a message component collector you just need to get the first value from that collector. Docs: https://discord.js.org/#/docs/discord.js/stable/class/SelectMenuInteraction?scrollTo=values

collectorInteraction.values[0]

Change collectorInteraction to whatever you named your collector parameter

If you still need to make a component collector, maybe visit these 2 websites: https://discord.js.org/#/docs/discord.js/stable/class/InteractionCollector

https://discordjs.guide/popular-topics/collectors.html#message-collectors

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda