diff options
| author | 2020-02-24 16:49:45 -0800 | |
|---|---|---|
| committer | 2020-03-22 15:54:36 -0700 | |
| commit | 0595b550111cf684721f85a0e340880c9f15288a (patch) | |
| tree | 9c7e119184165a1a216c15c31f7b89260c21dcee | |
| parent | HelpChannels: add a function to make channels in-use (diff) | |
HelpChannels: implement the on_message listener
It handles making channels in-use and replacing them with new available
channels.
| -rw-r--r-- | bot/cogs/help_channels.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index 806020873..6b77f9955 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -265,6 +265,15 @@ class HelpChannels(Scheduler, commands.Cog): @commands.Cog.listener() async def on_message(self, message: discord.Message) -> None: """Move an available channel to the In Use category and replace it with a dormant one.""" + available_channels = self.get_category_channels(self.available_category) + if message.channel not in available_channels: + return # Ignore messages outside the Available category. + + await self.move_to_in_use(message.channel) + + # Move a dormant channel to the Available category to fill in the gap. + # This is done last because it may wait indefinitely for a channel to be put in the queue. + await self.move_to_available() async def try_get_channel(self, channel_id: int) -> discord.abc.GuildChannel: """Attempt to get or fetch a channel and return it.""" |