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

266
Visualizações
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 Respostas
Responde à pergunta

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