'Why do I get the error "Empty field value even though it is not empty?
I have a problem with my bot... I get the error
RangeError [EMBED_FIELD_NAME]: MessageEmbed field names must be non-empty strings.
at Function.verifyString (C:\Users\****\Documents\r-Wof-bot\node_modules\discord.js\src\util\Util.js:413:41)
at Function.normalizeField (C:\Users\****\Documents\r-Wof-bot\node_modules\discord.js\src\structures\MessageEmbed.js:479:18)
at C:\Users\****\Documents\r-Wof-bot\node_modules\discord.js\src\structures\MessageEmbed.js:501:14
at Array.map (<anonymous>)
at Function.normalizeFields (C:\Users\****\Documents\r-Wof-bot\node_modules\discord.js\src\structures\MessageEmbed.js:500:8)
at MessageEmbed.addFields (C:\Users\****\Documents\r-Wof-bot\node_modules\discord.js\src\structures\MessageEmbed.js:322:42)
at MessageEmbed.addField (C:\Users\****\Documents\r-Wof-bot\node_modules\discord.js\src\structures\MessageEmbed.js:313:17)
at Client.<anonymous> (C:\Users\****\Documents\r-Wof-bot\bot.js:2081:7)
at Client.emit (node:events:390:28)
at InteractionCreateAction.handle (C:\Users\****\Documents\r-Wof-bot\node_modules\discord.js\src\client\actions\InteractionCreate.js:70:12) { [Symbol(code)]: 'EMBED_FIELD_NAME'
}
Even though the fields values are not empty... Can anyone help me? Here is the snippet of code where the error happens:
case 'help':
let command = interaction.options.getString('cmd', false);
if(command === null)
try{
let embed = new Discord.MessageEmbed()
.setTitle('Help')
.setColor('ORANGE')
.setFooter('Use /help cmd:<command> for more informations on that command!')
.addField({ name: 'kill', value: /*'Kills the bot. (Only available to bot-helper role)'*/'hi' }) //line 2081
.addField({ name: 'ping', value: 'Get the time delay between when you send the message and when the bot detects it.' })
.addField({ name: 'snek', value: 'snek.' })
.addField({ name: 'stalk', value: 'Get notified when the user whith the specified id logs in. Only works with this server\'s members.' })
.addField({ name: 'oc get', value: 'Get infos about an oc. Needs to have fetched the oc to the database from the message beforehand. See /help cmd:ocmessage.' })
.addField({ name: 'oc edit', value: 'Allows for the owner of the oc to edit in the database in case the data is wrong.' })
.addField({ name: 'quote', value: 'Starts a quizz about a quote. Guess the character who said that quote!' })
.addField({ name: 'fac, flip a coin', value: 'Flips a swiss coin. Warning: There is 1 in 100000000000000000 chance that the piece lands on its side. Be careful!' })
.addField({ name: 'hybridgen', value: 'A hybrid generator for you!' })
.addField({ name: 'oc message', value: 'Adds a message to the database' })
.addField({ name: 'help', valuse: 'Shows this message!' });
interaction.reply(embed);
} catch (e) {
console.warn(e);
}
}
Solution 1:[1]
I assume you just have to remove name:
and value:
in each .addField
, for example: .addField('snek', 'snek.')
, but you will get another error because you are trying to send an embed using interaction.reply(embed)
, and you have to use interaction.reply({embeds: [embed]})
to make it work
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | MegaMix_Craft |