From 25eaf47d4f729a2b37bec61938c96052f5e7b734 Mon Sep 17 00:00:00 2001 From: MattyTheHacker <18513864+MattyTheHacker@users.noreply.github.com> Date: Sun, 28 Jul 2024 18:36:34 +0100 Subject: [PATCH] Add log to channel on shutdown and startup --- cogs/startup.py | 6 ++++++ utils/tex_bot.py | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/cogs/startup.py b/cogs/startup.py index 6c84d5b44..611805157 100644 --- a/cogs/startup.py +++ b/cogs/startup.py @@ -139,3 +139,9 @@ async def on_ready(self) -> None: await self.bot.close() logger.info("Ready! Logged in as %s", self.bot.user) + + try: + log_channel: discord.TextChannel = await self.bot.fetch_log_channel() + await log_channel.send("TeX-Bot is now running!") + except ValueError: + logger.debug("Unable to send startup message to log channel!") diff --git a/utils/tex_bot.py b/utils/tex_bot.py index 8e2be8a05..5f2e0cc1d 100644 --- a/utils/tex_bot.py +++ b/utils/tex_bot.py @@ -66,6 +66,13 @@ def __init__(self, *args: object, **options: object) -> None: @override async def close(self) -> NoReturn: # type: ignore[misc] + + try: + log_channel: discord.TextChannel = await self.fetch_log_channel() + await log_channel.send("TeX-Bot is shutting down...") + except ValueError: + logger.debug("Unable to send shutdown message to log channel!") + await super().close() logger.info("TeX-Bot manually terminated.")