feat: *console printdisconnectedcause <true|false>
very useful for debugging
This commit is contained in:
parent
597a694727
commit
3811790c93
2 changed files with 18 additions and 1 deletions
|
@ -41,6 +41,8 @@ public class Bot {
|
||||||
|
|
||||||
public Session session;
|
public Session session;
|
||||||
|
|
||||||
|
public boolean printDisconnectedCause = false;
|
||||||
|
|
||||||
public boolean loggedIn = false;
|
public boolean loggedIn = false;
|
||||||
|
|
||||||
public final ExecutorService executorService = Main.executorService;
|
public final ExecutorService executorService = Main.executorService;
|
||||||
|
@ -251,6 +253,8 @@ public class Bot {
|
||||||
|
|
||||||
final Throwable cause = disconnectedEvent.getCause();
|
final Throwable cause = disconnectedEvent.getCause();
|
||||||
|
|
||||||
|
if (printDisconnectedCause && cause != null) cause.printStackTrace();
|
||||||
|
|
||||||
// lazy fix #69420
|
// lazy fix #69420
|
||||||
if (cause instanceof OutOfMemoryError) System.exit(1);
|
if (cause instanceof OutOfMemoryError) System.exit(1);
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,8 @@ public class ConsoleCommand extends Command {
|
||||||
"Controls stuff about console",
|
"Controls stuff about console",
|
||||||
new String[] {
|
new String[] {
|
||||||
"server <server>",
|
"server <server>",
|
||||||
"logtoconsole <true|false>"
|
"logtoconsole <true|false>",
|
||||||
|
"printdisconnectedreason <true|false>"
|
||||||
},
|
},
|
||||||
new String[] {},
|
new String[] {},
|
||||||
TrustLevel.OWNER,
|
TrustLevel.OWNER,
|
||||||
|
@ -77,6 +78,18 @@ public class ConsoleCommand extends Command {
|
||||||
bool ? Component.text("enabled").color(NamedTextColor.GREEN) : Component.text("disabled").color(NamedTextColor.RED)
|
bool ? Component.text("enabled").color(NamedTextColor.GREEN) : Component.text("disabled").color(NamedTextColor.RED)
|
||||||
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||||
}
|
}
|
||||||
|
case "printdisconnectedreason" -> {
|
||||||
|
context.checkOverloadArgs(2);
|
||||||
|
|
||||||
|
final boolean bool = context.getBoolean(true);
|
||||||
|
|
||||||
|
bot.printDisconnectedCause = bool;
|
||||||
|
|
||||||
|
return Component.translatable(
|
||||||
|
"Printing the disconnected cause is now %s",
|
||||||
|
bool ? Component.text("enabled").color(NamedTextColor.GREEN) : Component.text("disabled").color(NamedTextColor.RED)
|
||||||
|
).color(ColorUtilities.getColorByString(bot.config.colorPalette.defaultColor));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue