Made it global rate limit resistant

This commit is contained in:
Frisk 2020-08-01 16:57:34 +02:00
parent e26258edb7
commit 06f910b64e
No known key found for this signature in database
GPG key ID: 213F7C15068AF8AC

View file

@ -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