Open Metalhead33 opened 1 month ago
The changes in the pull request focus on enhancing the rate limiting functionality within the libdiscord.c
file. This includes the introduction of new static variables to manage rate limit information and the implementation of a new function, UpdateRateLimits
, which updates these variables based on Discord API response headers. Modifications to existing functions ensure that rate limit values are processed correctly, allowing for dynamic adjustments to request delays in accordance with the API's rate limiting policies.
File | Change Summary |
---|---|
libdiscord.c | Added static variables for rate limit management and new functions UpdateRateLimits and parse_rate_limit_headers to process rate limit headers. Modified discord_response_callback to call parse_rate_limit_headers and updated discord_fetch_url_with_method_delay for dynamic request delays. |
🐰 In the land where Discord chats,
Rate limits dance like friendly bats.
With updates swift, our requests align,
A smoother flow, oh how divine!
Hops of joy for every call,
Together we shall rise, not fall! 🌟
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
I'm not sure this actually did anything. In the actual debug logs, I don't see any references to the X-RateLimit headers - still, at least it doesn't result in an instant temp-ban like it did before I implemented this change. Placebo effect, perhaps?
Thank you for getting this PR underway! Really appreciate the help. 🥳
With the rate limits, are they enforced per-account or per IP? One of the suggestions from the bot (thanks for working with that btw, I've only just started using it so wasn't sure how well it'd go) was to put the variables into the account so that they aren't global, but is that intentional?
Looks good so far though. I'll have to try it out tonight. We can point other users to the dll auto builds to try out too. I'll do that when I'm back at my desktop, unless someone else jumps into it first 🙂
Hello @EionRobb - thank you for your kind coment, this is a very special moment for me, as it is the first time I truly contribute to an open-source repository :)
I personally bleieve that he bot is mistaken - Discord's rate limits are enforced per-IP. I noticed that because whenever the temp-ban is triggered, it affects both my desktop PC and my phone's wi-fi (which ultimately leads to the same modem/router that my desktop PC uses), but when I switch my mobile phone to "using data", the temp-ban is gone. This suggests that it is NOT per-account, but per-IP.
Still a work in progress, but I decided to take matters into my own hands because #450 and #448 really get on my nerves.
Summary by CodeRabbit
New Features
Bug Fixes