pythondiscorddiscord.pypycord

Discord.py get requests left


As far as I know the rate limit from discord is 10,000 requests per 10 minutes. I want to know how many requests I have left so I can e.g. slow down the bot so it doesn't get banned from discord. I only found is_ws_ratelimited but this only gives me a bool and this is not what I want


Solution

  • According to the Discord Documentation, every request returns optional HTTP headers containing the calls you have remaining. You are probably most likely interested in the header X-RateLimit-Remaining which contains how many requests you have left.

    X-RateLimit-Reset gives you a unix timestamp for the date when the limit resets.