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

209
Views
Obtener el objeto de mensaje de respuesta de la interacción discord.js

Si tengo este comando realmente simple:

 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]})

Funciona perfectamente. Envía el mensaje con los componentes y funciona bien. El problema es que ahora quiero escuchar los botones. En un mensaje, puedo hacer

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

Eso también funciona perfectamente, puedo escuchar los mensajes y hacer algo :D Ahora el problema es que al responder el mensaje, la promesa regresa undefined

 int.reply('Replied to your message')

¿Cómo obtener la respuesta y poder escuchar sus botones? :/

EDITAR: De hecho lo encontré. Solo tenía que agregar {fetchReply: true} al enviar una respuesta de interacción. Por ejemplo:

 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

Así que lo construiría así:

 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 )

Luego, lo recopilaría en su .on(“interactionCreate”) usando este código:

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

Luego, si alguien hace clic en él (incluso entre reinicios), el clic del botón se escucha y se responde.

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!