-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
(429) TOO MANY REQUESTS. #54
Comments
That's a example for sending multiple messages, but it really depends on what you're doing. You could also create a while loop and let it sleep for 1-2 seconds then message until count >= maxMessage |
If this is something that you're doing frequently, blocking the main thread with a loop is going to become a headache. You might be better kicking off a new thread and putting the loop in there. Either creating a short-lived worker thread for the immediate string of messages or a long-lived consumer thread that reads from some message queue. As well, if you don't want to rely on a blind flood limit timer (ie. sleeping for x seconds), you can put a nested loop at the end of the first that sleeps, retrieves the contents of the channel, and breaks once your latest message is in there (or fails after x cycles). It'd be more robust but potentially much slower. |
To give a bit of backstory on what it is i am trying to do. The bot i maintain is for my EVE Online alliance, we have a !pos command which can return anywhere up to 60+ lines of text, i have already created a loop to put up to the max of 2000 characters in 1 string before sending it out, but there are still times where i would have 10 ~ 15 messages. Currently i have a blind flood timer that just sleeps the thread the command runs in, for 1 second but that does not always seem to be enough. What i was hoping for, was some way to catch the error when it happens and have it wait, retry and continue. (Discordsharp.Objects.RateLimitException has a RetryAfter which i was hoping to use for this) What i will probably end up doing is increasing the timer to 2 ~ 3 seconds, if that still does not work properly i will probably end up making what @Siegen suggested, although i really do still hope that there is some way to catch the error properly and wait for whatever time the server needs me to wait. |
DiscordSharp doesn't have an internal ratelimit manager? @luigifan get on it The solution I'd reccomend is
This will allow you to conform to Discord's ratelimits, which are 5msgs/5seconds, or 1m/1s. |
The bot for our server is used to parse a lot of data and sometimes it needs to send 10 ~ 15 messages to a single person.
is there a way to have it wait for however long the discord server requires me to wait and then resend the message?
I have tried using a try with catch (RateLimitException ex) but it seems to be completely ignored.
The text was updated successfully, but these errors were encountered: