aboutsummaryrefslogtreecommitdiffstats
path: root/bot/exts/utilities/logging.py
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2022-09-23 22:58:49 +0100
committerGravatar GitHub <[email protected]>2022-09-23 22:58:49 +0100
commitf9cc77f55a7bac9cff1f5674b36b3f17560f6bfe (patch)
tree4d9a9684d6c0d8f1f749355353fbadb7fd89960b /bot/exts/utilities/logging.py
parentFix issue #1050 (#1097) (diff)
parentRemove all wait_until_guil_available as this is now done in bot-core (diff)
Merge pull request #1092 from python-discord/bot-core-migration
Diffstat (limited to 'bot/exts/utilities/logging.py')
-rw-r--r--bot/exts/utilities/logging.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/bot/exts/utilities/logging.py b/bot/exts/utilities/logging.py
new file mode 100644
index 00000000..83b7025f
--- /dev/null
+++ b/bot/exts/utilities/logging.py
@@ -0,0 +1,40 @@
+from botcore.utils.logging import get_logger
+from discord.ext.commands import Cog
+
+from bot import constants
+from bot.bot import Bot
+
+log = get_logger(__name__)
+
+
+class Logging(Cog):
+ """Debug logging module."""
+
+ def __init__(self, bot: Bot):
+ self.bot = bot
+
+ async def cog_load(self) -> None:
+ """Announce our presence to the configured dev-log channel after checking channel constants."""
+ await self.check_channels()
+ await self.bot.log_to_dev_log(
+ title=self.bot.name,
+ details="Connected!",
+ )
+
+ async def check_channels(self) -> None:
+ """Verifies that all channel constants refer to channels which exist."""
+ if constants.Client.debug:
+ log.info("Skipping Channels Check.")
+ return
+
+ all_channels_ids = [channel.id for channel in self.bot.get_all_channels()]
+ for name, channel_id in vars(constants.Channels).items():
+ if name.startswith("_"):
+ continue
+ if channel_id not in all_channels_ids:
+ log.error(f'Channel "{name}" with ID {channel_id} missing')
+
+
+async def setup(bot: Bot) -> None:
+ """Load the Logging cog."""
+ await bot.add_cog(Logging(bot))