aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar MarkKoz <[email protected]>2020-02-24 15:29:21 -0800
committerGravatar MarkKoz <[email protected]>2020-03-22 15:54:36 -0700
commit021fcbb20816f2031c9b190fb0c91d3e9b709b59 (patch)
treebbc312416cdc7abfb0c43611ada67f739d6e02ff
parentHelpChannels: implement create_dormant (diff)
HelpChannels: implement get_available_candidate
Return a dormant channel to turn into an available channel, waiting indefinitely until one becomes available in the queue.
-rw-r--r--bot/cogs/help_channels.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py
index 4a34bd37d..99815d4e5 100644
--- a/bot/cogs/help_channels.py
+++ b/bot/cogs/help_channels.py
@@ -117,7 +117,21 @@ class HelpChannels(Scheduler, commands.Cog):
"""Make the current in-use help channel dormant."""
async def get_available_candidate(self) -> discord.TextChannel:
- """Return a dormant channel to turn into an available channel."""
+ """
+ Return a dormant channel to turn into an available channel.
+
+ If no channel is available, wait indefinitely until one becomes available.
+ """
+ try:
+ channel = self.channel_queue.get_nowait()
+ except asyncio.QueueEmpty:
+ channel = await self.create_dormant()
+
+ if not channel:
+ # Wait for a channel to become available.
+ channel = await self.channel_queue.get()
+
+ return channel
@staticmethod
def get_category_channels(category: discord.CategoryChannel) -> t.Iterable[discord.TextChannel]: