diff options
| author | 2021-01-03 20:22:04 -0800 | |
|---|---|---|
| committer | 2021-01-04 23:20:01 -0800 | |
| commit | 6b02c5cb7c4792e9b7641a80965aa56e43ee6e2a (patch) | |
| tree | d41b82ae3fc17fbfe5e8cc4d8c1931ebf11e9e24 | |
| parent | HelpChannels: clarify close command docstring (diff) | |
HelpChannels: unschedule the dormant task in unclaim_channel
Ensure the cancellation will be under the lock once the lock is added.
| -rw-r--r-- | bot/exts/help_channels/_cog.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py index 2b7cfcba7..9d80e193e 100644 --- a/bot/exts/help_channels/_cog.py +++ b/bot/exts/help_channels/_cog.py @@ -184,7 +184,6 @@ class HelpChannels(commands.Cog): if await self.close_check(ctx): log.info(f"Close command invoked by {ctx.author} in #{ctx.channel}.") await self.unclaim_channel(ctx.channel, "command") - self.scheduler.cancel(ctx.channel.id) async def get_available_candidate(self) -> discord.TextChannel: """ @@ -392,9 +391,13 @@ class HelpChannels(commands.Cog): await _message.unpin(channel) await _stats.report_complete_session(channel.id, caller) - await self.move_to_dormant(channel) + # Cancel the task that makes the channel dormant only if called by the close command. + # In other cases, the task is either already done or not-existent. + if caller == "command": + self.scheduler.cancel(channel.id) + async def move_to_in_use(self, channel: discord.TextChannel) -> None: """Make a channel in-use and schedule it to be made dormant.""" log.info(f"Moving #{channel} ({channel.id}) to the In Use category.") |