From 9f871a9d384ba2754bae047d62fb8a1bfd7e2141 Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Mon, 24 Feb 2020 15:19:39 -0800 Subject: HelpChannels: implement create_dormant Create and return a new channel in the Dormant category or return None if no names remain. The overwrites get synced with the category if none are explicitly specified for the channel. --- bot/cogs/help_channels.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index a848a3029..4a34bd37d 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -88,8 +88,22 @@ class HelpChannels(Scheduler, commands.Cog): return queue - async def create_dormant(self) -> discord.TextChannel: - """Create and return a new channel in the Dormant category.""" + async def create_dormant(self) -> t.Optional[discord.TextChannel]: + """ + Create and return a new channel in the Dormant category. + + The new channel will sync its permission overwrites with the category. + + Return None if no more channel names are available. + """ + name = constants.HelpChannels.name_prefix + + try: + name += self.name_queue.popleft() + except IndexError: + return None + + return await self.dormant_category.create_text_channel(name) def create_name_queue(self) -> deque: """Return a queue of element names to use for creating new channels.""" -- cgit v1.2.3