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

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

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