Search code examples
javascriptnode.jsdiscorddiscord.jsembed

MessageEmbed field values must be non-empty strings. help command


I am trying to make a help command for my discord bot, when i type .help it gives an error

 /app/node_modules/discord.js/src/util/Util.js:416
     if (typeof data !== 'string') throw new error(errorMessage);
                                   ^
 
 RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.
     at Function.verifyString (/app/node_modules/discord.js/src/util/Util.js:416:41)
     at Function.normalizeField (/app/node_modules/discord.js/src/structures/MessageEmbed.js:544:19)
     at /app/node_modules/discord.js/src/structures/MessageEmbed.js:565:14
     at Array.map (<anonymous>)
     at Function.normalizeFields (/app/node_modules/discord.js/src/structures/MessageEmbed.js:564:8)
     at MessageEmbed.addFields (/app/node_modules/discord.js/src/structures/MessageEmbed.js:328:42)
     at MessageEmbed.addField (/app/node_modules/discord.js/src/structures/MessageEmbed.js:319:17)
     at Object.execute (/app/commands/informational/help.js:12:10)
     at module.exports (/app/events/messageCreate.js:28:18)
     at Client.emit (node:events:390:28) {
   [Symbol(code)]: 'EMBED_FIELD_VALUE'
 }

The code : https://pastebin.com/eyKhB2qs


Solution

  • When you are adding a field in your embed, it takes at least three values. The first is the title of the field you are adding and the second is the value of the field. The third value is a boolean and it states whether the field is inline or not. You have only passed the title of the field and you need to pass something in as the value as well such as: .addField('title', 'description', true). You can learn more about embeds in Embeds | Discord.js