chunkoforanges
chunkoforanges

Reputation: 1

"MessageEmbed field values may not be empty" problem in discord.js

I'm currently making a discord bot in node.js and keep getting this problem. I'm trying to make a help command but i want to try to make sure embeds and stuff work before doing the command, and i keep getting this weird error. I put two code samples, one is the code for the command, and one is the code for what makes the commands actually work. Can someone help?

module.exports = {
name: 'command',
description: "Commands for the bot!",
execute(message, args, Discord) {
    const newEmbed = new Discord.MessageEmbed()
    .setColor('#304281')
    .setTitle('Commands')
    .setURL('https://discord.com/terms')
    .setDescription('Showing commands..')
    .addFields(
        {name: 'Rule 1', value: ''},
        {name: 'Rule 1', value: ''},
        {name: 'Rule 1', value: ''}
    )
    .setImage('https://blog.logomyway.com/wp-content/uploads/2020/12/discord-mascot.png')
    .setFooter('Bot created by John Adams#7337');

    message.channel.send(newEmbed);
}

}

client.on('message', message => {
if(!message.content.startsWith(prefix) || message.author.bot) return;

const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();

if(command === 'ping'){
    client.commands.get('ping').execute(message, args);
    
} else if (command === 'botinfo'){
    client.commands.get('botinfo').execute(message, args);

} else if (command === 'test'){
    client.commands.get('test').execute(message, args);

} else if (command === 'command'){
    client.commands.get('command').execute(message, args, Discord);
}

});

And here is the error:

C:\Users\Chunko\Desktop\DiscordBot\node_modules\discord.js\src\structures\MessageEmbed.js:432
if (!value) throw new RangeError('EMBED_FIELD_VALUE');
            ^

RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values may not be empty. at Function.normalizeField (C:\Users\Chunko\Desktop\DiscordBot\node_modules\discord.js\src\structures\MessageEmbed.js:432:23) at C:\Users\Chunko\Desktop\DiscordBot\node_modules\discord.js\src\structures\MessageEmbed.js:452:14 at Array.map () at Function.normalizeFields (C:\Users\Chunko\Desktop\DiscordBot\node_modules\discord.js\src\structures\MessageEmbed.js:451:8) at MessageEmbed.addFields (C:\Users\Chunko\Desktop\DiscordBot\node_modules\discord.js\src\structures\MessageEmbed.js:266:42) at Object.execute (C:\Users\Chunko\Desktop\DiscordBot\commands\command.js:11:10) at Client. (C:\Users\Chunko\Desktop\DiscordBot\index.js:39:40) at Client.emit (events.js:315:20) at MessageCreateAction.handle (C:\Users\Chunko\Desktop\DiscordBot\node_modules\discord.js\src\client\actions\MessageCreate.js:31:14) at Object.module.exports [as MESSAGE_CREATE] (C:\Users\Chunko\Desktop\DiscordBot\node_modules\discord.js\src\client\websocket\handlers\MESSAGE_CREATE.js:4:32) { [Symbol(code)]: 'EMBED_FIELD_VALUE' }

Upvotes: 0

Views: 1808

Answers (1)

Max
Max

Reputation: 107

It is quite simple error and you have made a very blunder mistake.

In Discord.js Embed When you are adding fields in the embed you are expected to add to parameters in a field 1. Title Or the name of the field and 2. The content or the value of the field.

But as in your case you have kept the second parameter aka the value is empty. So it remove this error instead of {name: 'Rule 1', value: ''} you should do it {name: 'Rule 1', value: 'Your rule here do not keep it empty'}.

Upvotes: 1

Related Questions