From 06f910b64e069752d00688b5c27ce93899c5a2a9 Mon Sep 17 00:00:00 2001 From: Frisk Date: Sat, 1 Aug 2020 16:57:34 +0200 Subject: [PATCH] Made it global rate limit resistant --- src/discord.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/discord.py b/src/discord.py index 9ac489b..ad61a35 100644 --- a/src/discord.py +++ b/src/discord.py @@ -149,7 +149,7 @@ async def send_to_discord_webhook(data: DiscordMessage, webhook_url: str) -> tup try: result = await session.post("https://discord.com/api/webhooks/"+webhook_url, data=repr(data)) logger.debug(result.headers) - rate_limit = None if int(result.headers.get('x-ratelimit-remaining')) > 0 else result.headers.get('x-ratelimit-reset-after') + rate_limit = None if int(result.headers.get('x-ratelimit-remaining', "-1")) > 0 else result.headers.get('x-ratelimit-reset-after', None) except (aiohttp.ClientConnectionError, aiohttp.ServerConnectionError, TimeoutError): logger.exception("Could not send the message to Discord") return 3, None