我正在使用狀態機器人,但無法在我的嵌入中使用游戲狀態中的變數,當我嘗試將其放在描述中時它沒有顯示
這是我的代碼 我編輯了代碼
整個代碼是這樣的
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)
uj5u.com熱心網友回復:
state變數必須在使用前宣告。如果您希望它更改,則該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);
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/496084.html
標籤:javascript 游戏挖掘
下一篇:如何使用命令讓機器人dm我
