diff options
| author | 2020-11-20 22:22:10 -0500 | |
|---|---|---|
| committer | 2020-11-20 22:22:10 -0500 | |
| commit | 8ea13768378deadef6e666ed40ed88ff8a08e16d (patch) | |
| tree | 7cb56dfe0a6c0b5ce86ae010082edc8b46f74725 | |
| parent | Checkout code so we can deploy (diff) | |
`!close` removes the cooldown role from the claimant even when invoked by someone else; flattened `close_command`
| -rw-r--r-- | bot/exts/help_channels.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/bot/exts/help_channels.py b/bot/exts/help_channels.py index f5a8b251b..e50fab7fc 100644 --- a/bot/exts/help_channels.py +++ b/bot/exts/help_channels.py @@ -213,18 +213,23 @@ class HelpChannels(commands.Cog): and reset the send permissions cooldown for the user who started the session. """ log.trace("close command invoked; checking if the channel is in-use.") - if ctx.channel.category == self.in_use_category: - if await self.dormant_check(ctx): - await self.remove_cooldown_role(ctx.author) + if ctx.channel.category != self.in_use_category: + log.debug(f"{ctx.author} invoked command 'dormant' outside an in-use help channel") + return - # Ignore missing task when cooldown has passed but the channel still isn't dormant. - if ctx.author.id in self.scheduler: - self.scheduler.cancel(ctx.author.id) + if not await self.dormant_check(ctx): + return - await self.move_to_dormant(ctx.channel, "command") - self.scheduler.cancel(ctx.channel.id) - else: - log.debug(f"{ctx.author} invoked command 'dormant' outside an in-use help channel") + guild = self.bot.get_guild(constants.Guild.id) + claimant = guild.get_member(await self.help_channel_claimants.get(ctx.channel.id)) + await self.move_to_dormant(ctx.channel, "command") + await self.remove_cooldown_role(claimant) + + # Ignore missing task when cooldown has passed but the channel still isn't dormant. + if ctx.author.id in self.scheduler: + self.scheduler.cancel(ctx.author.id) + + self.scheduler.cancel(ctx.channel.id) async def get_available_candidate(self) -> discord.TextChannel: """ |