From 4c43e6e41be365c9134bacfb690fca55cb68f81f Mon Sep 17 00:00:00 2001 From: MarkKoz Date: Mon, 24 Feb 2020 17:05:44 -0800 Subject: HelpChannels: implement _scheduled_task Make a channel dormant after specified timeout or reschedule if it's still active. --- bot/cogs/help_channels.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index c547d9524..12bed2e61 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -296,6 +296,11 @@ class HelpChannels(Scheduler, commands.Cog): async def _scheduled_task(self, data: ChannelTimeout) -> None: """Make a channel dormant after specified timeout or reschedule if it's still active.""" + await asyncio.sleep(data.timeout) + + # Use asyncio.shield to prevent move_idle_channel from cancelling itself. + # The parent task (_scheduled_task) will still get cancelled. + await asyncio.shield(self.move_idle_channel(data.channel)) def setup(bot: Bot) -> None: -- cgit v1.2.3