From 1a173153c8c812f36d1571f43050db5b7a88524f Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sun, 14 May 2023 17:16:56 +0100 Subject: [PATCH] Inspect Discord webhook response --- app/tasks/webhooktasks.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/tasks/webhooktasks.py b/app/tasks/webhooktasks.py index e810fcaa..60df9c45 100644 --- a/app/tasks/webhooktasks.py +++ b/app/tasks/webhooktasks.py @@ -13,6 +13,7 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . +import sys from typing import Optional import requests @@ -48,4 +49,7 @@ def post_discord_webhook(username: Optional[str], content: str, is_queue: bool, json["embeds"] = [embed] - requests.post(discord_url, json=json) + res = requests.post(discord_url, json=json, headers={"Accept": "application/json"}) + if res.status_code != 200: + print("Failed to submit Discord webhook", res.json(), file=sys.stderr) + res.raise_for_status()