diff options
| author | 2020-02-24 12:24:12 -0800 | |
|---|---|---|
| committer | 2020-03-22 15:54:34 -0700 | |
| commit | 67fd115fd95a003b0b248385a4175380a8959b1d (patch) | |
| tree | b8d42d542a4173fd97f4264c158ed0998afb7fd1 | |
| parent | HelpChannels: add a function to init the categories (diff) | |
HelpChannels: add a function to initialise the cog
It's created as a task in __init__ because coroutines cannot be awaited
in there.
| -rw-r--r-- | bot/cogs/help_channels.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index 5ca16fd41..1e99f16b5 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -53,6 +53,11 @@ class HelpChannels(Scheduler, commands.Cog): self.in_use_category: discord.CategoryChannel = None self.dormant_category: discord.CategoryChannel = None + self.channel_queue: asyncio.Queue = None + self.name_queue: deque = None + + asyncio.create_task(self.init_cog()) + async def create_channel_queue(self) -> asyncio.Queue: """Return a queue of dormant channels to use for getting the next available channel.""" @@ -87,6 +92,18 @@ class HelpChannels(Scheduler, commands.Cog): log.exception(f"Failed to get a category; cog will be removed") self.bot.remove_cog(self.qualified_name) + async def init_cog(self) -> None: + """Initialise the help channel system.""" + await self.bot.wait_until_guild_available() + + await self.init_categories() + + self.channel_queue = await self.create_channel_queue() + self.name_queue = await self.name_queue() + + await self.init_available() + await self.move_idle_channels() + async def move_idle_channels(self) -> None: """Make all idle in-use channels dormant.""" |