diff options
| -rw-r--r-- | bot/cogs/help_channels.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index f493e5918..c547d9524 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -218,13 +218,21 @@ class HelpChannels(Scheduler, commands.Cog): self.ready.set() async def move_idle_channel(self, channel: discord.TextChannel) -> None: - """Make the `channel` dormant if idle or schedule the move if still active.""" + """ + Make the `channel` dormant if idle or schedule the move if still active. + + If a task to make the channel dormant already exists, it will first be cancelled. + """ idle_seconds = constants.HelpChannels.idle_minutes * 60 time_elapsed = await self.get_idle_time(channel) if time_elapsed is None or time_elapsed > idle_seconds: await self.move_to_dormant(channel) else: + # Cancel the existing task, if any. + if channel.id in self.scheduled_tasks: + self.cancel_task(channel.id) + data = ChannelTimeout(channel, idle_seconds - time_elapsed) self.schedule_task(self.bot.loop, channel.id, data) |