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
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 answers
Answer question

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 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!