diff --git a/src/main/java/me/chayapak1/chomens_bot/Bot.java b/src/main/java/me/chayapak1/chomens_bot/Bot.java index 4f2958d..e9336f0 100644 --- a/src/main/java/me/chayapak1/chomens_bot/Bot.java +++ b/src/main/java/me/chayapak1/chomens_bot/Bot.java @@ -41,6 +41,8 @@ public class Bot { public Session session; + public boolean printDisconnectedCause = false; + public boolean loggedIn = false; public final ExecutorService executorService = Main.executorService; @@ -251,6 +253,8 @@ public class Bot { final Throwable cause = disconnectedEvent.getCause(); + if (printDisconnectedCause && cause != null) cause.printStackTrace(); + // lazy fix #69420 if (cause instanceof OutOfMemoryError) System.exit(1); diff --git a/src/main/java/me/chayapak1/chomens_bot/commands/ConsoleCommand.java b/src/main/java/me/chayapak1/chomens_bot/commands/ConsoleCommand.java index 4bcf19b..6c760d5 100644 --- a/src/main/java/me/chayapak1/chomens_bot/commands/ConsoleCommand.java +++ b/src/main/java/me/chayapak1/chomens_bot/commands/ConsoleCommand.java @@ -19,7 +19,8 @@ public class ConsoleCommand extends Command { "Controls stuff about console", new String[] { "server ", - "logtoconsole " + "logtoconsole ", + "printdisconnectedreason " }, new String[] {}, TrustLevel.OWNER, @@ -77,6 +78,18 @@ public class ConsoleCommand extends Command { bool ? Component.text("enabled").color(NamedTextColor.GREEN) : Component.text("disabled").color(NamedTextColor.RED) ).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;