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

181
Views
How to detect if a message is not blank

I've been trying to create a modmail system where you can send images to the support team, but I get MessageEmbed field value may not be blank (this is for the Embed where the message is). How can I detect if there is or is not any text to go along with their image?

This is my code

const Embed = new Discord.MessageEmbed()
            .setAuthor("Message from recipient", message.author.displayAvatarURL())
            .setDescription(`A message has been recieved from ${message.author.tag}`)
          if (message.attachments.size < 0) {
            Embed.addField("Message:", message.content)
          } else {
            if (message.attachments.every(attachIsImage)) {
              
              Embed.setImage(message.attachments.first())
            }
          }

          function attachIsImage(msgAttach) {
            var url = msgAttach.url;
            //True if this url is a png image.
            return url.indexOf("png", url.length - "png".length /*or 3*/) !== -1;
          }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Assuming the rest of the code works as expected just change this line

Embed.addField("Message:", message.content || 'No message')
// this adds a message if none is present
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!