From d00543593f5c4584f0ed30f838d056aba3816768 Mon Sep 17 00:00:00 2001 From: ChomeNS <95471003+ChomeNS@users.noreply.github.com> Date: Fri, 18 Oct 2024 11:46:57 +0700 Subject: [PATCH] Connection throttled! Please wait before reconnecting. --- src/main/java/me/chayapak1/chomens_bot/Bot.java | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/chayapak1/chomens_bot/Bot.java b/src/main/java/me/chayapak1/chomens_bot/Bot.java index 6dbe3b3..0387a4b 100644 --- a/src/main/java/me/chayapak1/chomens_bot/Bot.java +++ b/src/main/java/me/chayapak1/chomens_bot/Bot.java @@ -242,20 +242,18 @@ public class Bot { final Throwable cause = disconnectedEvent.getCause(); - if (cause != null) { - // lazy fix (#69420) - if (cause instanceof OutOfMemoryError) System.exit(1); - } + // lazy fix #69420 + if (cause instanceof OutOfMemoryError) System.exit(1); int reconnectDelay = options.reconnectDelay; final String stringMessage = ComponentUtilities.stringify(disconnectedEvent.getReason()); - // this part is ported from chomens bot js if ( stringMessage.equals("Wait 5 seconds before connecting, thanks! :)") || - stringMessage.equals("You are logging in too fast, try again later.") - ) reconnectDelay = 1000 * 7; + 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(() -> reconnect(), reconnectDelay, TimeUnit.MILLISECONDS);