mirror of
https://gitlab.com/chicken-riders/RcGcDb.git
synced 2025-02-22 00:44:10 +00:00
Don't remove webhooks when random 404, only when Discord generates json calling the webhook bad
This commit is contained in:
parent
4a272eb8c9
commit
03892fbfd1
|
@ -239,11 +239,20 @@ async def handle_discord_http(code: int, formatted_embed: str, result: aiohttp.C
|
|||
logger.error(await result.text())
|
||||
return 1
|
||||
elif code == 401 or code == 404: # HTTP UNAUTHORIZED AND NOT FOUND
|
||||
logger.error("Webhook URL is invalid or no longer in use, please replace it with proper one.")
|
||||
async with db.pool().acquire() as connection:
|
||||
await connection.execute("DELETE FROM rcgcdw WHERE webhook = $1", webhook_url)
|
||||
await webhook_removal_monitor(webhook_url, code)
|
||||
return 1
|
||||
if result.content_type == "application/json":
|
||||
error_details = await result.json()
|
||||
if error_details.get("code", -1) == 10015:
|
||||
logger.error("Webhook URL is invalid or no longer in use, please replace it with proper one.")
|
||||
async with db.pool().acquire() as connection:
|
||||
await connection.execute("DELETE FROM rcgcdw WHERE webhook = $1", webhook_url)
|
||||
await webhook_removal_monitor(webhook_url, code)
|
||||
return 1
|
||||
else:
|
||||
await generic_msg_sender_exception_logger("Could not get a message sent to wiki with webhook URL: {}. "
|
||||
"Discord's error: {}".format(webhook_url, str(error_details)))
|
||||
return 3
|
||||
|
||||
|
||||
elif code == 429:
|
||||
logger.error("We are sending too many requests to the Discord, slowing down...")
|
||||
return 5
|
||||
|
|
Loading…
Reference in a new issue