aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bot/exts/help_channels/_cog.py11
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)