aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Chris Lovering <[email protected]>2022-02-20 14:10:49 +0000
committerGravatar Chris Lovering <[email protected]>2022-02-20 20:28:23 +0000
commit4e0c6e73a5d430574ec73257734c78a8c6574fa2 (patch)
tree6523ae805fb0cd0db1dd689c98ad17e1bfa0506b
parentEnsure each in-use channel has a cached claimant on init (diff)
Handle uncached claimant on unclaim
This could be possible during init_available. If there are too many available channels they are made dormant by calling unclaim_channel. However there may not be claimants cached and ensure_claimants wouldn't populate cache, since the channels weren't in use.
-rw-r--r--bot/exts/help_channels/_cog.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py
index b0f1a1dce..f276a7993 100644
--- a/bot/exts/help_channels/_cog.py
+++ b/bot/exts/help_channels/_cog.py
@@ -452,18 +452,21 @@ class HelpChannels(commands.Cog):
async def _unclaim_channel(
self,
channel: discord.TextChannel,
- claimant_id: int,
+ claimant_id: t.Optional[int],
closed_on: _channel.ClosingReason
) -> None:
"""Actual implementation of `unclaim_channel`. See that for full documentation."""
await _caches.claimants.delete(channel.id)
await _caches.session_participants.delete(channel.id)
- claimant = await members.get_or_fetch_member(self.guild, claimant_id)
- if claimant is None:
- log.info(f"{claimant_id} left the guild during their help session; the cooldown role won't be removed")
+ if not claimant_id:
+ log.info("No claimant given when un-claiming %s (%d). Skipping role removal.", channel, channel.id)
else:
- await members.handle_role_change(claimant, claimant.remove_roles, self.cooldown_role)
+ claimant = await members.get_or_fetch_member(self.guild, claimant_id)
+ if claimant is None:
+ log.info(f"{claimant_id} left the guild during their help session; the cooldown role won't be removed")
+ else:
+ await members.handle_role_change(claimant, claimant.remove_roles, self.cooldown_role)
await _message.unpin(channel)
await _stats.report_complete_session(channel.id, closed_on)