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

402
Views
Error: Message content must be a non-empty string. || if (typeof data !== 'string') throw new error(errorMessage);

Hi i have problem with using guild on my discord bot. Whenever i want to return the amount of the users on my server i recive this error

if (typeof data !== 'string') throw new error(errorMessage);

RangeError [MESSAGE_CONTENT_TYPE]: Message content must be a non-empty string.

if (cmd === `name`) { //This is working when used on discord text-channel
        msg.reply(msg.guild.name)
    }
    if (cmd === `users`) {  //This is not working when used on discord text-channel
        msg.reply(msg.guild.memberCount)
    }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The memberCount property returns a number which you are trying to send in a channel. The problem is that sending a number is not allowed. Your message content must always be a string.

You can solve this problem by using the String function to send a number. Your command will look like this:

if(cmd === `users`){
    msg.reply(String(msg.guild.memberCount));
}
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!