Skip to content

Commit 93aee92

Browse files
committed
Add reason to subratelimit hit log
Signed-off-by: davfsa <[email protected]>
1 parent c4843dc commit 93aee92

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

hikari/impl/rest.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,20 +1000,23 @@ async def _parse_ratelimits(
10001000
)
10011001

10021002
body_retry_after = float(body["retry_after"])
1003+
reason = body.get("message", "none")
10031004

10041005
if body.get("global", False) is True:
10051006
_LOGGER.error(
1006-
"rate limited on the global bucket. You should consider lowering the number of requests you make or "
1007-
"contacting Discord to raise this limit. Backing off and retrying request..."
1007+
"rate limited on the global bucket (reason: '%s'). You should consider lowering the number of requests "
1008+
"you make or contacting Discord to raise this limit. Backing off and retrying request...",
1009+
reason,
10081010
)
10091011
self._bucket_manager.throttle(body_retry_after)
10101012
return 0
10111013

10121014
_LOGGER.error(
1013-
"rate limited on a %s sub bucket on bucket %s. You should consider lowering the number of requests "
1014-
"you make to '%s'. Backing off and retrying request...",
1015+
"rate limited on a %s sub bucket on bucket %s (reason: '%s'). You should consider lowering the number "
1016+
"of requests you make to '%s'. Backing off and retrying request...",
10151017
resp_headers.get(_X_RATELIMIT_SCOPE_HEADER, "route"),
10161018
bucket,
1019+
reason,
10171020
compiled_route.route,
10181021
)
10191022

0 commit comments

Comments
 (0)