aboutsummaryrefslogtreecommitdiffstats
path: root/bot/bot.py
diff options
context:
space:
mode:
authorGravatar Chris <[email protected]>2021-04-02 14:53:45 +0100
committerGravatar Chris <[email protected]>2021-04-02 14:53:45 +0100
commitaa4d16acca8b9ccf8ce395c70dad416506021c59 (patch)
tree54a2d083de3a0527c300a09e548ee0a97305f6bc /bot/bot.py
parentDon't allow users to run the issue command in DMs, given error feedback. (diff)
parentMerge branch 'main' into Handle-DMChannels (diff)
Merge branch 'Handle-DMChannels' of github.com:ChrisLovering/sir-lancebot into Handle-DMChannels
Diffstat (limited to 'bot/bot.py')
-rw-r--r--bot/bot.py17
1 files changed, 16 insertions, 1 deletions
diff --git a/bot/bot.py b/bot/bot.py
index 97b09243..e9750697 100644
--- a/bot/bot.py
+++ b/bot/bot.py
@@ -34,7 +34,7 @@ class Bot(commands.Bot):
)
self._guild_available = asyncio.Event()
self.redis_session = redis_session
-
+ self.loop.create_task(self.check_channels())
self.loop.create_task(self.send_log(self.name, "Connected!"))
@property
@@ -71,6 +71,21 @@ class Bot(commands.Bot):
else:
await super().on_command_error(context, exception)
+ async def check_channels(self) -> None:
+ """Verifies that all channel constants refer to channels which exist."""
+ await self.wait_until_guild_available()
+
+ if constants.Client.debug:
+ log.info("Skipping Channels Check.")
+ return
+
+ all_channels_ids = [channel.id for channel in self.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 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()