hola, soy nuevo en js, hice un bot de discordia y ahora estaba haciendo un comando de información del servidor mc pero recibí este error const json = esperar respuesta.json (); ^
RangeError [EMBED_FIELD_VALUE]: los valores del campo MessageEmbed no deben ser cadenas vacías. en Function.verifyString (/home/runner/js-try3/node_modules/discord.js/src/util/Util.js:416:41) en Function.normalizeField (/home/runner/js-try3/node_modules/discord. js/src/structures/MessageEmbed.js:544:19) en /home/runner/js-try3/node_modules/discord.js/src/structures/MessageEmbed.js:565:14 en Array.map () en Función. normalizeFields (/home/runner/js-try3/node_modules/discord.js/src/structures/MessageEmbed.js:564:8) en MessageEmbed.addFields (/home/runner/js-try3/node_modules/discord.js/src /structures/MessageEmbed.js:328:42) en MessageEmbed.addField (/home/runner/js-try3/node_modules/discord.js/src/structures/MessageEmbed.js:319:17) en Object.module.exports. ejecutar (/home/runner/js-try3/commands/minecraft/mcserverinfo.js:21:6) { [Símbolo (código)]: 'EMBED_FIELD_VALUE'
const fetch = require('node-fetch') const { MessageEmbed } = require('discord.js'); module.exports.run = async (Client, message, args, prefix) => { const Ip = args[0]; if(!Ip) return message.reply('Please provide an Ip of a Minecraft java edition server'); const response = fetch(`https://api.mcsrvstat.us/2/${Ip}`); const json = await response.json(); if (!json.online) return message.reply('Hmm that dint work I guess you entered wrong ip or the server is offline'); const info = new MessageEmbed() .setColor('RANDOM') .setTitle((json.hostname || Ip) + "Information") .setThumbnail(`https://eu.mc-api.net/v3/server/favicon/${Ip.toLowerCase()}`) .addField("Ip:", json.ip || "Unknown", false) .addField("Status:", json.online ? "Online": "Offline", false) .addField("port:", json.port || "Default", false) .addField('Version:', json.version || "Unknown", false) .addField("Players online:", json.players ? json.players.online : "Unknown", false) .addField("Max players allowed tto join at once:", json.players ? json.player.max: "Unknown", false) if(json.motd && json.motd.clean && json.motd.clean.length > 1) info.addField("Description:", json.motd.length >200? `${json.motd.clean.slice(0, 200)}...` : json.motd.clean); message.reply( { embeds:[info] } ) } module.exports.help = { name: 'mcserverinfo', aliases: [] }¿Hay algún método para arreglar este o cualquier otro método en lugar de .json? ¿Podemos usar algo más?
fetch devuelve una promesa, resuelva la promesa usando await
const fetch = require('node-fetch'); const response = await fetch(`https://api.mcsrvstat.us/2/${Ip}`); const json = await response.json();