Home > Enterprise >  Discord.jsV13 MessageEmbed field values must be non-empty strings
Discord.jsV13 MessageEmbed field values must be non-empty strings

Time:06-06

Hi i trying to add a embed to a message using Distube, and i get this errors.

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

this is my command event:

client.distube
  .on('playSong', (queue, song) => {
    queue.textChannel.send({embeds: [
        new MessageEmbed()
            .setTitle('Started Playing')
            .setDescription(`[${song.name}](${song.url})`)
            .addField('**Views:**', song.views, false)
            .addField('**Duration:**', song.formattedDuration, false)
            .addField('**Status**', status(queue), false)
            .setThumbnail(song.thumbnail)
            .setColor("BLUE")
    ]})
  })

I using this packages: Discord.js@v13 [email protected]

CodePudding user response:

The error comes from the fact that there is an empty, undefined or null parameter in .addField()

Verify each second parameter, and set default value =/= ""

CodePudding user response:

Assuming that song.views, status(queue) and song.formattedDuration aren't strings, you could surround them with quotes like so:

client.distube
  .on('playSong', (queue, song) => {
    queue.textChannel.send({embeds: [
        new MessageEmbed()
            .setTitle('Started Playing')
            .setDescription(`[${song.name}](${song.url})`)
            .addField('**Views:**', `${song.views}`, false)
            .addField('**Duration:**', `${song.formattedDuration}`, false)
            .addField('**Status**', `${status(queue)}`, false)
            .setThumbnail(song.thumbnail)
            .setColor("BLUE")
    ]})
  })

An alternative would be to use .toString() instead

CodePudding user response:

This error comes if one of your embed fields value is empty, the error is pretty explanatory, if you need help share more of your code snippet like what did you define song etc.?

  • Related