diff --git a/src/modules/misc/mcserver.js b/src/modules/misc/mcserver.js index 32ed814..bea08f1 100644 --- a/src/modules/misc/mcserver.js +++ b/src/modules/misc/mcserver.js @@ -134,7 +134,7 @@ function queryServer(ip, port, HANDSHAKE_PACKET) { return reject(err); } const dataAsString = totalData.toString().trim(); - console.log(dataAsString); + logger.verbose("mcserver", "data as string", dataAsString); const json = JSON.parse(dataAsString.slice(dataAsString.indexOf("{"), dataAsString.lastIndexOf("}") + 1)); logger.verbose("mcserver", "close", json); clearTimeout(timeout); @@ -196,14 +196,24 @@ mcserver.callback = async function (msg, line) { await msg.addReaction("\uD83C\uDFD3"); - let data = await queryServerIdent(ip, port); + let data; + try { + data = await queryServerIdent(ip, port); + } catch { + try { + data = await queryServerNoIdent(ip, port); + } catch (err) { + await msg.removeReaction("\uD83C\uDFD3"); + return `Failed to query:\n\`\`\`\n${data.error.message}\n\`\`\``; + } + } if (data == "timeout") { await msg.removeReaction("\uD83C\uDFD3"); return "Timed out trying to query."; } else if (data?.error) { await msg.removeReaction("\uD83C\uDFD3"); - return `Failed to query:\n\`\`\`\n${data.error}\n\`\`\``; + return `Failed to query:\n\`\`\`\n${data.error.message}\n\`\`\``; } else { if (data.version.name == "TCPShield.com") data = await queryServerNoIdent(ip, port);