aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2022-11-26 14:21:58 +0400
committerGravatar Hassan Abouelela <[email protected]>2022-11-26 14:21:58 +0400
commit4779d4240ae43fd48699ac80c0779665604abebb (patch)
treed7f1da6dfb2a8d5350f9cf10037810c0af29b18c
parentHandle Discord API Not Being Ready (diff)
Don't Remove Cooldown Role From Non-Existing Users
We try to remove the cooldown role from users before checking if the user is still in the server, which can cause an error since the thread object will just contain `None` as the user. Signed-off-by: Hassan Abouelela <[email protected]>
-rw-r--r--bot/exts/help_channels/_channel.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py
index 3dc9e81ef..a41fcd63f 100644
--- a/bot/exts/help_channels/_channel.py
+++ b/bot/exts/help_channels/_channel.py
@@ -52,6 +52,15 @@ async def _close_help_thread(closed_thread: discord.Thread, closed_on: _stats.Cl
poster = closed_thread.owner
cooldown_role = closed_thread.guild.get_role(constants.Roles.help_cooldown)
+
+ if poster is None:
+ # We can't include the owner ID/name here since the thread only contains None
+ log.info(
+ f"Failed to remove cooldown role for owner of thread ({closed_thread.id}). "
+ f"The user is likely no longer on the server."
+ )
+ return
+
await members.handle_role_change(poster, poster.remove_roles, cooldown_role)