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

83
Visualizações
Issue with awaiting for user input

I've just started learning discord.js 3 days ago, and I'm coming across this error. I'm trying to make it so if the user says !faction it will ask them to say their faction name, then once they've sent their faction name, it asks them for more information about their faction. Here's my code:

factionEmbed = {
title : "Request to create faction.",
color : embedColor,
description : "Please reply with your faction name.",
author : {
name : message.author.username,
icon_url : message.author.displayAvatarURL()
           }
       }
message.channel.send({embeds : [factionEmbed]});

let filter = m => m.author.id === message.author.id
message.channel.send({embeds : []}).then(() => {
message.channel.awaitMessages(filter, {
max: 1,
time: 30000,
errors: ['time']
           })
           .then(message => {
const nameOfFaction = message.first();
message.channel.send("Please provide us with info about your faction.")
message.channel.awaitMessages(filter, {
max: 1,
time: 30000,
errors: ['time']
             })
             .then(message => {
const factionInfo = message.content;
message.channel.send("Submitted for review.")
             })
           })
           .catch(collected => {
message.channel.send('Timeout');
           });
       })
   }```

Edit: Error Message:

DiscordAPIError: Cannot send an empty message
    at RequestHandler.execute (C:\Users\Halcy\Desktop\BTN Bot\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async RequestHandler.push (C:\Users\Halcy\Desktop\BTN Bot\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
    at async TextChannel.send (C:\Users\Halcy\Desktop\BTN Bot\node_modules\discord.js\src\structures\interfaces\TextBasedChannel.js:175:15) {
  method: 'post',
  path: '/channels/931712816090603545/messages',
  code: 50006,
  httpStatus: 400,
  requestData: {
    json: {
      content: undefined,
      tts: false,
      nonce: undefined,
      embeds: [],
      components: undefined,
      username: undefined,
      avatar_url: undefined,
      allowed_mentions: undefined,
      flags: undefined,
      message_reference: undefined,
      attachments: undefined,
      sticker_ids: undefined
    },
    files: []
  }
}
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It looks like the error is resulting from you trying to send an empty message, or, more specifically, a message with an empty array of embeds:

message.channel.send({embeds : []}).then(() => {
...
})

You'll need to either add some content/embeds to that method call, or remove it altogether. It seems to me that you may have intended to include the function passed as a parameter to then in a call to then for the first message you sent.

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