From 7c2f0dcdbc7d89e80eabe6a6b77349924a69ad67 Mon Sep 17 00:00:00 2001 From: Cynthia Foxwell Date: Fri, 2 Aug 2024 12:09:46 -0600 Subject: [PATCH] misc.mcserver: try to fallback to no ident on error --- src/modules/misc/mcserver.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/modules/misc/mcserver.js b/src/modules/misc/mcserver.js index edba8d2..55a7066 100644 --- a/src/modules/misc/mcserver.js +++ b/src/modules/misc/mcserver.js @@ -205,10 +205,12 @@ mcserver.callback = async function (msg, line) { await msg.addReaction("\uD83C\uDFD3"); let data; + let tried = false; try { data = await queryServerIdent(ip, port); } catch { try { + tried = true; data = await queryServerNoIdent(ip, port); } catch (err) { await msg.removeReaction("\uD83C\uDFD3"); @@ -220,6 +222,16 @@ mcserver.callback = async function (msg, line) { await msg.removeReaction("\uD83C\uDFD3"); return "Timed out trying to query."; } else if (data?.error) { + if (!tried) { + try { + tried = true; + data = await queryServerNoIdent(ip, port); + } catch (err) { + await msg.removeReaction("\uD83C\uDFD3"); + return `Failed to query:\n\`\`\`\n${data.error.message}\n\`\`\``; + } + } + await msg.removeReaction("\uD83C\uDFD3"); return `Failed to query:\n\`\`\`\n${data.error.message}\n\`\`\``; } else {