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

211
Visualizações
Get interaction's reponse message object discord.js

Si I have this really simple command :

let row = new Discord.MessageActionRow().addComponents(...) // The .. is too long so i'll just remove it for this question
int.reply({ content : 'pong', components : [row]})

It works perfectly. It sends the message with the components and works just fine. The problem is now I want to listen to the buttons. On a message, I can do

message.reply({ content : 'ok', components : [row]})
.then(msg =>{
  let collector = msg.createMessageComponentCollector({ componentType : 'BUTTON', time : 10e5 })
  // Collector thingys

})
.catch(console.error)

That also works perfectly, I can listen to the messages and do something :D Now the problem is that when replying to the message, the promise returns undefined

int.reply('Replied to your message')

How to get the reply and be able to listen to it's buttons ? :/

EDIT : I actually found it. I just had to add { fetchReply : true } when sending an interaction response For example:

const reply = await interaction.reply({ content : 'Test !', components : [row], fetchReply : true})

// Do something with "reply"..
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

So I would build it like this:

const row = new MessageActionRow()
    .addComponents(
        new MessageButton()
        .setCustomId('ButtonIdChangeThis')
        .setLabel('WhatButtonSaysChangeThis')
        .setStyle('SUCCESS')
// can use ‘SUCCESS’ for green, ‘DANGER’ for red, ‘PRIMARY’ for blurple, ‘SECONDARY’ for grey
    )

Then you would collect it under your .on(“interactionCreate”) event using this code:

client.on(“interactionCreate”, async interaction => {
    if (interaction.isButton()) {
        const buttonID = interaction.customId
        if (buttonID === 'ButtonIdChangeThis') {
//put what button does here
    }
})

Then if anyone clicks it (even between reboots) the button click is listened to and responded to.

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