Home > Back-end >  Discord bot not able to create the embed RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values m
Discord bot not able to create the embed RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values m

Time:10-22

const {Client, RichEmbed, Intents, MessageEmbed } = require('discord.js'); 

 
const bot = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
 
 
const token = 'token is a secret';
 
const PREFIX = '!';
 
bot.on('ready', () =>{
    console.log('Bot has come online.');
});
 
bot.on('messageCreate', message =>{
 
    
    let args = message.content.substring(PREFIX.length).split(' ')
 
    switch(args[0]){
        case 'mc':
            
            const ping = require('minecraft-server-util')
 
 
            ping.status('ip', { port: port})
             .then((response)=>{
                
                const Embed = new MessageEmbed()
                .setTitle('Server Status', )
                .addField('Server IP', response.host)
                .addField('Server Version', response.version)
                .addField('Online Players', response.onlinePlayers)
                .addField('Max Players', response.maxPlayers)
                
                message.channel.send({ embeds: [Embed] });
            })
            .catch((error)=>{console.error(error);});
        break
 
    }
 
    })
 
bot.login(token);

I am coding a discord bot that sends the status of my minecraft server when the assigned command is issued. But for some reason it is not able to create the embed. This is the error i am getting: RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings. I tried to google this error but i couldn't understand clearly. Please tell me where i have gone wrong and how should i correct it. :(

CodePudding user response:

Try this:

.setTitle('Server Status')
.addField('Server IP', `** ** ${response.host}`)
.addField('Server Version', `** ** ${response.version}`)
.addField('Online Players', `** ** ${response.onlinePlayers}`)
.addField('Max Players', `** ** ${response.maxPlayers}`)
  • Related