From a01dad283fea07b68878d93b09c5cf7a6e1821f6 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Tue, 19 Jul 2022 00:44:55 -0400 Subject: [PATCH] Add extraneous debug logging to sub ratelimits being detected --- discord/http.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/discord/http.py b/discord/http.py index 87d533d58..e795ccd1e 100644 --- a/discord/http.py +++ b/discord/http.py @@ -650,6 +650,19 @@ class HTTPClient: # Banned by Cloudflare more than likely. raise HTTPException(response, data) + if ratelimit.remaining > 0: + # According to night + # https://github.com/discord/discord-api-docs/issues/2190#issuecomment-816363129 + # Remaining > 0 and 429 means that a sub ratelimit was hit. + # It is unclear what should happen in these cases other than just using the retry_after + # value in the body. + _log.debug( + '%s %s received a 429 despite having %s remaining requests. This is a sub-ratelimit.', + method, + url, + ratelimit.remaining, + ) + retry_after: float = data['retry_after'] if self.max_ratelimit_timeout and retry_after > self.max_ratelimit_timeout: _log.warning(