diff options
author | 2021-05-31 13:07:23 -0400 | |
---|---|---|
committer | 2021-05-31 13:07:23 -0400 | |
commit | 0aec67d3bc7699bcdcba75d59214bb14b7e4cb07 (patch) | |
tree | 9c9f7d1c1cce2f1b4834bd71d8c6d08171edc01d | |
parent | Merge branch 'main' of https://github.com/python-discord/bot into swfarnswort... (diff) |
Role lookup takes place only in `_handle_role_change`.
-rw-r--r-- | bot/exts/help_channels/_cog.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py index 49640dda7..5c410a0a1 100644 --- a/bot/exts/help_channels/_cog.py +++ b/bot/exts/help_channels/_cog.py @@ -94,15 +94,14 @@ class HelpChannels(commands.Cog): self.scheduler.cancel_all() - @staticmethod - async def _handle_role_change(member: discord.Member, coro: t.Coroutine) -> None: + async def _handle_role_change(self, member: discord.Member, coro: t.Callable[..., t.Coroutine]) -> None: """ Change `member`'s cooldown role via awaiting `coro` and handle errors. `coro` is intended to be `discord.Member.add_roles` or `discord.Member.remove_roles`. """ try: - await coro + await coro(self.bot.get_guild(constants.Guild.id).get_role(constants.Roles.help_cooldown)) except discord.NotFound: log.debug(f"Failed to change role for {member} ({member.id}): member not found") except discord.Forbidden: @@ -125,8 +124,7 @@ class HelpChannels(commands.Cog): """ log.info(f"Channel #{message.channel} was claimed by `{message.author.id}`.") await self.move_to_in_use(message.channel) - cooldown_role = self.bot.get_guild(constants.Guild.id).get_role(constants.Roles.help_cooldown) - await self._handle_role_change(message.author, message.author.add_roles(cooldown_role)) + await self._handle_role_change(message.author, message.author.add_roles) await _message.pin(message) @@ -431,8 +429,7 @@ class HelpChannels(commands.Cog): if claimant is None: log.info(f"{claimant_id} left the guild during their help session; the cooldown role won't be removed") else: - cooldown_role = self.bot.get_guild(constants.Guild.id).get_role(constants.Roles.help_cooldown) - await self._handle_role_change(claimant, claimant.remove_roles(cooldown_role)) + await self._handle_role_change(claimant, claimant.remove_roles) await _message.unpin(channel) await _stats.report_complete_session(channel.id, closed_on) |