diff options
| author | 2020-04-06 02:02:41 +0200 | |
|---|---|---|
| committer | 2020-04-09 20:24:40 +0200 | |
| commit | 7ccfa21f38b0df50f582ceb6e64d1ce1fe9c6617 (patch) | |
| tree | b9469dccda56cf5271ebdcb9b118ea137ac5f273 | |
| parent | Allow help session starters to invoke dormant. (diff) | |
Reset cooldown after channel is made dormant.
| -rw-r--r-- | bot/cogs/help_channels.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/bot/cogs/help_channels.py b/bot/cogs/help_channels.py index cdfe4e72c..7bfb33875 100644 --- a/bot/cogs/help_channels.py +++ b/bot/cogs/help_channels.py @@ -206,6 +206,7 @@ class HelpChannels(Scheduler, commands.Cog): self.cancel_task(ctx.channel.id) await self.move_to_dormant(ctx.channel) await ctx.message.delete() + await self.reset_send_permissions_for_help_user(ctx.channel) else: log.debug(f"{ctx.author} invoked command 'dormant' outside an in-use help channel") @@ -610,6 +611,19 @@ class HelpChannels(Scheduler, commands.Cog): log.trace(f"Ensuring channels in `Help: Available` are synchronized after permissions reset.") await self.ensure_permissions_synchronization(self.available_category) + async def reset_send_permissions_for_help_user(self, channel: discord.TextChannel) -> None: + """Reset send permissions in the Available category for member that started the help session in `channel`.""" + # Get mapping of channels to users that started the help session in them. + channels_to_users = {value: key for key, value in self.help_channel_users.items()} + log.trace(f"Attempting to find user for help session in #{channel.name} ({channel.id}).") + try: + member: discord.Member = channels_to_users[channel] + except KeyError: + log.trace(f"Channel #{channel.name} ({channel.id}) not in help session cache, permissions unchanged.") + return + log.trace(f"Resetting send permissions for {member} ({member.id}).") + await self.available_category.set_permissions(member, send_messages=None) + async def revoke_send_permissions(self, member: discord.Member) -> None: """ Disallow `member` to send messages in the Available category for a certain time. |