[英]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)
The state
variable has to be declared before you use it.必须在使用state
变量之前声明它。 The jugadores
variable cannot be const
if you want it to change.如果你想改变jugadores
变量,它不能是const
。
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.