Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

266
Visualizações
MessageEmbed field values must be non-empty strings gamedig problem

Hello i have a problem and its its if (typeof data !== 'string') throw new error(errorMessage); RangeError [EMBED_FIELD_VALUE]: MessageEmbed field values must be non-empty strings.

i trying on players to put the amount of players that the minecraft server has like:

Players Online: 79 Players

my code its:


let state = null;

let jugadores = 0;

setInterval(() => {


  Gamedig.query({
    type: 'minecraft',
    host: 'mc.latinplay.net',
    port: '25565'
  })
  .then((updatedState) => {
    state = updatedState;
    players = state.players.length;
  });
}, 6000);

module.exports = new Command({
  name: cmdconfig.EstadoCommand,
  description: cmdconfig.EstadoCommandDesc,


  async run(interaction) {

      const LatinStatus = new Discord.MessageEmbed() 
    .setColor('RANDOM') 
       .addField('**Players:**', 'players')
      .addField('**Status**', "**Online💚**", true);
      interaction.reply({
        embeds: [LatinEstado],
      });
  
    }
  },
);
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Modify your code from your recent:

let state = null;

let jugadores = 0;

setInterval(() => {


  Gamedig.query({
    type: 'minecraft',
    host: 'mc.latinplay.net',
    port: '25565'
  })
  .then((updatedState) => {
    state = updatedState;
    players = state.players.length || "0"; //adding || operator so no error will occure
  });
}, 6000);

module.exports = new Command({
  name: cmdconfig.EstadoCommand,
  description: cmdconfig.EstadoCommandDesc,


  async run(interaction) {

      const LatinStatus = new Discord.MessageEmbed() 
    .setColor('RANDOM') 
       .addField('**Players:**', 'players')
      .addField('**Status**', "**Online💚**", true);
      interaction.reply({
        embeds: [LatinEstado],
      });
  
    }
  },
);

Ive seen alot of errors in here, you can also use an operator called or in operator || to prevent error when players reached on 0 members.

module.exports = new Command({
  name: cmdconfig.EstadoCommand,
  description: cmdconfig.EstadoCommandDesc,


async run(interaction) {
let state = null;

let jugadores = 0; //I also don't understand what is these for.

setInterval(() => {
  Gamedig.query({
    type: 'minecraft',
    host: 'mc.latinplay.net',
    port: '25565'
  })
  .then((updatedState) => {
     state = updatedState;
     players = state.players.length;
     const LatinStatus = new Discord.MessageEmbed() 
    .setColor('RANDOM') 
    .addField('**Players:**', `${players}`) //also it must be `${players}`
    .addField('**Status**', "**Online💚**", true);
    interaction.reply({
      embeds: [LatinEstado],
    });
  });
}, 6000);
    }
  },
);

EDIT:

I tried your code and caught an error such as Error: Failed all 1 attempts

so you can use .catch function

setInterval(() => {
  Gamedig.query({
    type: 'minecraft',
    host: 'mc.latinplay.net',
    port: '25565'
  }).catch((err) => {
     console.log() //or
     console.log(err)
  })
  .then((updatedState) => {
     state = updatedState;
     players = state.players.length;
     const LatinStatus = new Discord.MessageEmbed() 
    .setColor('RANDOM') 
    .addField('**Players:**', `${players || "0"}`) //also it must be `${players}`
    .addField('**Status**', "**Online💚**", true);
    interaction.reply({
      embeds: [LatinEstado],
    });
  });
}, 6000);
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda