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

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

I'm working on a serverinfo command in discord.js v13 and I don't know how to fix this error

ERROR:

[Photo Error]: https://i.stack.imgur.com/tcEem.png

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

RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.

[Symbol(code)]: 'EMBED_FIELD_VALUE'


const { Client, MessageEmbed, Message } = require(`discord.js`);
const moment = require(`moment`)

module.exports = {
  name: "serverinfo",
  description: "Get server information",
  /**
  *
  * @param {Client} client 
  * @param {Message} message
  * @param {String[]} args
  */
  run: async (client, message, args) => {
    const guild = message.guild;
    let embed = new MessageEmbed()
      .setTitle(message.guild.name)
      .setThumbnail(message.guild.iconURL())
      .setColor("RANDOM")
      .addField(`General Info`, [
        `ID: ${guild.id}`,
        `Name: ${guild.name}`,
        `Owner: ${guild.owner}`,
      ])
      .addField("Counts", [
        `Role: ${guild.roles.cache.size} roles`,
        `Channel: ${guild.channel.cache.size
        } total (Text: ${guild.channel.cache.filter(
          (ch) => ch.type === "text"
        ).size}, Voice: ${guild.channel.cache.filter(
          (ch) => ch.type === "Voice"
        )})`,
        `Emojis: ${guild.emojis.cache.size} (Regular: ${guild.emojis.cache.filter((e) => !e.animated).size
}, Animated: ${
  guild.emojis.cache.filter((e) => !e.animated).size
})`,
    ])
    .addField("Additional Information", [
      `Created: ${
  moment(guild.createdTimestamp).format(
    `LT`
  )
} ${ moment(guild.createdTimestamp).format(`LL`) } ${
  moment(
    guild.createdTimestamp
  ).fromNow()
} `,
      `Region: ${ guild.region } `,
      `Boost Tier: ${
  guild.premiumTier ? `Tier ${guild.premiumTier}` : "None"
} `,
      `Boost Count: ${guild.premiumSubscribtionCount || "0"}`,
    ]);

    message.channel.send({ embed });
  },
};
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The second parameter to .addField must be a string, as your error message says:

MessageEmbed field values must be non-empty strings.

You pass an array, which is not a "non-empty string". I.e.

let embed = new MessageEmbed()
.addField('foo', 'bar')

is fine.

let embed = new MessageEmbed()
.addField('foo', ['bar', 'baz'])

is not.

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!