misc.mcserver: try to fallback to no ident on error
This commit is contained in:
parent
daea53ca42
commit
7c2f0dcdbc
1 changed files with 12 additions and 0 deletions
|
@ -205,10 +205,12 @@ mcserver.callback = async function (msg, line) {
|
||||||
await msg.addReaction("\uD83C\uDFD3");
|
await msg.addReaction("\uD83C\uDFD3");
|
||||||
|
|
||||||
let data;
|
let data;
|
||||||
|
let tried = false;
|
||||||
try {
|
try {
|
||||||
data = await queryServerIdent(ip, port);
|
data = await queryServerIdent(ip, port);
|
||||||
} catch {
|
} catch {
|
||||||
try {
|
try {
|
||||||
|
tried = true;
|
||||||
data = await queryServerNoIdent(ip, port);
|
data = await queryServerNoIdent(ip, port);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await msg.removeReaction("\uD83C\uDFD3");
|
await msg.removeReaction("\uD83C\uDFD3");
|
||||||
|
@ -220,6 +222,16 @@ mcserver.callback = async function (msg, line) {
|
||||||
await msg.removeReaction("\uD83C\uDFD3");
|
await msg.removeReaction("\uD83C\uDFD3");
|
||||||
return "Timed out trying to query.";
|
return "Timed out trying to query.";
|
||||||
} else if (data?.error) {
|
} 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");
|
await msg.removeReaction("\uD83C\uDFD3");
|
||||||
return `Failed to query:\n\`\`\`\n${data.error.message}\n\`\`\``;
|
return `Failed to query:\n\`\`\`\n${data.error.message}\n\`\`\``;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue