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

263
Vistas
How do I make my bot send a message after user has replied to a question

I'm trying to make a system where a user is given a question by the bot and after the user replies it clears these 2 messages and asks another question and repeats until all the questions are complete.

I can't make it to wait for the user to input their answer before asking another question, any help?

const { MessageEmbed } = require("discord.js");
const clearMessages = require("./clearMessages");

const askEventQuestions = async (client, channelId) => {
  const edonoChannel = client.channels.cache.get(channelId);
  let q1Answer = ""

  //event questions embeds
  const q1 = new MessageEmbed()
    .setColor("AQUA")
    .setDescription("What Type of Event would you like to donate for?");

  const q2 = new MessageEmbed()
    .setColor("AQUA")
    .setDescription("What are the amounts of DMC/Items that you are donating?");


  //send and set answer for questions

  await edonoChannel.send({ embeds: [q1] });
  client.on("messageCreate", async (message) => {
    q1Answer = message.content;
    if (q1Answer !== "") {
      await clearMessages(2, message);
      console.log(q1Answer);
    }
  });

  await edonoChannel.send({ embeds: [q2] });
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You should use Collectors and I think awaitMessages : https://discordjs.guide/popular-topics/collectors.html#await-messages

Its a totally different way to do it but simpler

Something like that :

const isValid = response => response.content == ''
const question = await edonoChannel.send({ embeds: [q1] })

const stepper = await question.channel.awaitMessages({isValid, your options ?})

const answer = stepper.first().content 
// this is your answer content, the data is necessarily the unique valid response, thanks to isValid function

await question.delete()
await stepper.delete()

...

That is returning the first message (or messages) that contain(s) the valid answer to your question. After that you can run your treatement!

about 4 years ago · Juan Pablo Isaza 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