Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

96
Views
cant use variables from gamedig onembed

im working on a status bot but can't use variables from the game state in my embed, its not showing when im try to put it on the description

here it's my code I edited the code

The whole code is like this


const Discord = require("discord.js");
const yaml = require("js-yaml");
const Gamedig = require('gamedig');
const supportbot = yaml.load(
  fs.readFileSync("./Configs/supportbot.yml", "utf8")
);
const cmdconfig = yaml.load(fs.readFileSync("./Configs/commands.yml", "utf8"));

const Command = require("../Structures/Command.js");
const { timeStamp } = require("console");
var request = require('request');


const jugadores = state.players.length;


setInterval(() => {
  // query your game server
  Gamedig.query({
    type: 'minecraft',
    host: 'mc.latinplay.net',
    port: '25565'
  })
  .then((updatedState) => {
    state = updatedState;
  });
}, 6000); 



let state = null;


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


  async run(interaction) {



      const LatinEstado = new Discord.MessageEmbed() 
    .setColor('RANDOM') ```
    .setDescription("Users:", jugadores) 

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The state variable has to be declared before you use it. The jugadores variable cannot be const if you want it to change.

let state = null;

let jugadores = 0;

setInterval(() => {
  // query your game server
  Gamedig.query({
    type: 'minecraft',
    host: 'mc.latinplay.net',
    port: '25565'
  })
  .then((updatedState) => {
    state = updatedState;
    jugadores = state.players.length;
  });
}, 6000);
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!