From 931fb3ea4a6eb767864b33df5bd17cfb48e1b919 Mon Sep 17 00:00:00 2001 From: Will Da Silva Date: Sun, 4 Oct 2020 22:44:49 -0400 Subject: Verify channel constants on startup Closes #393 --- bot/bot.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'bot/bot.py') diff --git a/bot/bot.py b/bot/bot.py index ffaf4284..92873ba4 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -45,7 +45,7 @@ class SeasonalBot(commands.Bot): connector=TCPConnector(resolver=AsyncResolver(), family=socket.AF_INET) ) self._guild_available = asyncio.Event() - + self.loop.create_task(self.check_channels()) self.loop.create_task(self.send_log("SeasonalBot", "Connected!")) @property @@ -149,6 +149,15 @@ class SeasonalBot(commands.Bot): log.info("Nickname set successfully") return True + async def check_channels(self) -> None: + await self.wait_until_guild_available() + all_channels = set(self.get_all_channels()) + for name, channel_id in vars(Channels).items(): + if name.startswith('_'): + continue + if channel_id not in all_channels: + log.error(f'Channel "{name}" with id {channel_id} missing') + async def send_log(self, title: str, details: str = None, *, icon: str = None) -> None: """Send an embed message to the devlog channel.""" await self.wait_until_guild_available() -- cgit v1.2.3