K
Kord4mo ago
rebok

Is there a way to make kord automatically reconnect after an error?

Each time i get the error 502 in the terminal output, the bot goes offline. Is there a way to automatically make it reconnect?
11 Replies
LustigerLurch
LustigerLurch4mo ago
console of your bot? what do you mean?
rebok
rebokOP4mo ago
i mean in the terminal output
LustigerLurch
LustigerLurch4mo ago
in what part of your code does the exception occur?
rebok
rebokOP4mo ago
it doesn't exectly pinpoint where in my code does the exception occur but i have this screenshot
No description
rebok
rebokOP4mo ago
but from what i know exceptions in kord.on<E> {} shouldn't make the bot crash
LustigerLurch
LustigerLurch4mo ago
that's right do you have some code outside of this? also how often do you get 502s? and do you have an idea why you get them?
rebok
rebokOP4mo ago
The first time it happend was today at 9 AM and after that was it happening today at around 3 PM i don't have any other code that would interact with kord outside of kord.on<E> {} expect for launching and stopping kord
LustigerLurch
LustigerLurch4mo ago
hm, then the reason your bot goes offline might be that the gateway connection dies and can't reconnect because the retry limit exceeded (this should log a warning, do you see something in the logs about this?).
rebok
rebokOP4mo ago
no, i don't see any warnings mentioning the rate limit, here's the full log:
No description
LustigerLurch
LustigerLurch4mo ago
ok, these logged errors come from DefaultGateway because the start call (coming from kord.login) was cancelled - so something leads to cancellation of the scope you call login in, which must be outside of kord.on because that should catch and log excpetions try enabling stackTraceRecovery - that way it'll be easier to see where in your code you call into kord when kord throws an exception:
val kord = Kord(token) {
stackTraceRecovery = true
}
val kord = Kord(token) {
stackTraceRecovery = true
}
rebok
rebokOP4mo ago
ok, i think i have found the cause which was a task running each few seconds and that didn't use kord.on<E> {}
Want results from more Discord servers?
Add your server