diff options
| author | 2020-02-24 15:19:39 -0800 | |
|---|---|---|
| committer | 2020-03-22 15:54:36 -0700 | |
| commit | 9f871a9d384ba2754bae047d62fb8a1bfd7e2141 (patch) | |
| tree | 6b46bc0a7431269820186da8e4d170f4aee66a25 | |
| parent | HelpChannels: implement get_idle_time (diff) | |
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.
Diffstat (limited to '')
| -rw-r--r-- | bot/cogs/help_channels.py | 18 |
1 files 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.""" |