Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

193
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda