From 056cdffb7d2dd48f939572c69e1fcfc6e2298e89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Sun, 21 May 2023 20:18:02 +0200 Subject: [PATCH] Send error to webhook when failing to get webhook URL from reminder --- discord_reminder_bot/main.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/discord_reminder_bot/main.py b/discord_reminder_bot/main.py index 57c6234..99c49bd 100644 --- a/discord_reminder_bot/main.py +++ b/discord_reminder_bot/main.py @@ -19,6 +19,7 @@ from interactions import ( ) from interactions.ext.paginator import Page, Paginator +from discord_reminder_bot import settings from discord_reminder_bot.countdown import calculate from discord_reminder_bot.create_pages import create_pages from discord_reminder_bot.parse import ParsedTime, parse_time @@ -50,8 +51,12 @@ def send_webhook( message: The message that will be sent to Discord. """ if not url: - logging.error("ERROR: Tried to send a webhook but you have no webhook url configured.") + msg = "ERROR: Tried to send a webhook but you have no webhook url configured." + logging.error(msg) + webhook: DiscordWebhook = DiscordWebhook(url=settings.webhook_url, content=msg, rate_limit_retry=True) + webhook.execute() return + webhook: DiscordWebhook = DiscordWebhook(url=url, content=message, rate_limit_retry=True) webhook.execute()