Connection throttled! Please wait before reconnecting.

This commit is contained in:
Chayapak 2024-10-18 11:46:57 +07:00
parent 17440e1805
commit d00543593f

View file

@ -242,20 +242,18 @@ public class Bot {
final Throwable cause = disconnectedEvent.getCause(); final Throwable cause = disconnectedEvent.getCause();
if (cause != null) { // lazy fix #69420
// lazy fix (#69420)
if (cause instanceof OutOfMemoryError) System.exit(1); if (cause instanceof OutOfMemoryError) System.exit(1);
}
int reconnectDelay = options.reconnectDelay; int reconnectDelay = options.reconnectDelay;
final String stringMessage = ComponentUtilities.stringify(disconnectedEvent.getReason()); final String stringMessage = ComponentUtilities.stringify(disconnectedEvent.getReason());
// this part is ported from chomens bot js
if ( if (
stringMessage.equals("Wait 5 seconds before connecting, thanks! :)") || stringMessage.equals("Wait 5 seconds before connecting, thanks! :)") ||
stringMessage.equals("You are logging in too fast, try again later.") stringMessage.equals("You are logging in too fast, try again later.") ||
) reconnectDelay = 1000 * 7; 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); executor.schedule(() -> reconnect(), reconnectDelay, TimeUnit.MILLISECONDS);