fix: EndCommand while cloop running deadlocks the executor causing the bot to not reconnect and bricks (absolute cinema)

This commit is contained in:
ChomeNS
2025-06-08 09:08:53 +07:00
parent 3d6f1193e6
commit 313c4389a1
3 changed files with 7 additions and 5 deletions

View File

@@ -1 +1 @@
3439
3444

View File

@@ -379,9 +379,9 @@ public class Bot extends SessionAdapter {
final String stringMessage = ComponentUtilities.stringify(disconnectedEvent.getReason());
if (
stringMessage.equals("Wait 5 seconds before connecting, thanks! :)") ||
stringMessage.equals("You are logging in too fast, try again later.") ||
stringMessage.equals("Connection throttled! Please wait before reconnecting.")
stringMessage.equals("Wait 5 seconds before connecting, thanks! :)")
|| stringMessage.equals("You are logging in too fast, try again later.")
|| stringMessage.equals("Connection throttled! Please wait before reconnecting.")
) reconnectDelay = 1000 * (5 + 2); // 2 seconds extra delay just in case
executor.schedule(this::reconnect, reconnectDelay, TimeUnit.MILLISECONDS);

View File

@@ -24,7 +24,9 @@ public class EndCommand extends Command {
final Bot bot = context.bot;
bot.session.disconnect(I18nUtilities.get("commands.end.disconnect_reason"));
bot.executorService.execute(
() -> bot.session.disconnect(I18nUtilities.get("commands.end.disconnect_reason"))
);
return null;
}