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)
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);