diff options
| author | 2020-02-24 17:05:44 -0800 | |
|---|---|---|
| committer | 2020-03-22 15:54:37 -0700 | |
| commit | 4c43e6e41be365c9134bacfb690fca55cb68f81f (patch) | |
| tree | 23d8df893179a96b8a8edeb75d48f865f89c160e | |
| parent | HelpChannels: cancel an existing task before scheduling a new one (diff) | |
HelpChannels: implement _scheduled_task
Make a channel dormant after specified timeout or reschedule if it's
still active.
| -rw-r--r-- | bot/cogs/help_channels.py | 5 |
1 files changed, 5 insertions, 0 deletions
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: |