From fb035395b45d753589638181cda299aa65f4fd15 Mon Sep 17 00:00:00 2001 From: yashpaliwal-bst Date: Wed, 17 Apr 2024 17:18:09 +0530 Subject: [PATCH] added ratelimit logs --- discord/http.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/discord/http.py b/discord/http.py index 30184b665a..7f0721f375 100644 --- a/discord/http.py +++ b/discord/http.py @@ -298,6 +298,8 @@ async def request( remaining = response.headers.get("X-Ratelimit-Remaining") if remaining == "0" and response.status != 429: # we've depleted our current bucket + if response.status != 200 or response.status != 204: + print(f"RatelimitReached: status: {response.status}, url: {url}, method: {method}") delta = utils._parse_ratelimit_header( response, use_clock=self.use_clock ) @@ -319,6 +321,7 @@ async def request( # we are being rate limited if response.status == 429: + print(f"APIRatelimitError: status: {response.status}, url: {url}, method: {method}") if not response.headers.get("Via") or isinstance(data, str): # Banned by Cloudflare more than likely. raise HTTPException(response, data) @@ -335,6 +338,7 @@ async def request( # check if it's a global rate limit is_global = data.get("global", False) if is_global: + print(f"GlobalRateLimitReached: status: {response.status}, url: {url}, method: {method}") _log.warning( ( "Global rate limit has been hit. Retrying in" @@ -361,6 +365,7 @@ async def request( continue # the usual error cases + print(f"APIError: status: {response.status}, url: {url}, method: {method}") if response.status == 403: raise Forbidden(response, data) elif response.status == 404: