Skip to content

Commit

Permalink
Added debug logs for ratelimit
Browse files Browse the repository at this point in the history
  • Loading branch information
AMIT YADAV authored and AMIT YADAV committed Mar 15, 2024
1 parent 5e3ad3f commit ef2f63d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,9 @@ async def request(

# check if we have rate limit header information
remaining = response.headers.get("X-Ratelimit-Remaining")
print(f"RatelimitReached: status: {response.status}, url: {url}, method: {method}")
if remaining == "0" and response.status != 429:
print(f"RatelimitReached: status: {response.status}, url: {url}, method: {method}")
# we've depleted our current bucket
delta = utils._parse_ratelimit_header(
response, use_clock=self.use_clock
Expand All @@ -313,6 +315,7 @@ async def request(

# we are being rate limited
if response.status == 429:
print(f"APIError: 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)
Expand Down Expand Up @@ -349,6 +352,7 @@ async def request(
continue

# the usual error cases
print(f"APIError: status: {response.status}, url: {url}")
if response.status == 403:
raise Forbidden(response, data)
elif response.status == 404:
Expand Down

0 comments on commit ef2f63d

Please sign in to comment.