From aef1b89ab08be8cb45111cb44c4c5a1dd32905db Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Tue, 14 Apr 2026 13:49:31 -0700 Subject: [PATCH] Fixes warnings being blocked in threads --- techsupport_bot/commands/moderator.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/techsupport_bot/commands/moderator.py b/techsupport_bot/commands/moderator.py index 79322df6..6f21cdbc 100644 --- a/techsupport_bot/commands/moderator.py +++ b/techsupport_bot/commands/moderator.py @@ -469,7 +469,7 @@ async def handle_warn_user( await interaction.response.send_message(embed=embed) return - if target not in interaction.channel.members: + if not can_user_see_punishment(target, interaction.channel): embed = auxiliary.prepare_deny_embed( message=f"{target} cannot see this warning. No warning was added." ) @@ -880,3 +880,26 @@ def build_warning_embeds( ) embeds.append(embed) return embeds + + +def can_user_see_punishment( + user: discord.Member, channel: discord.abc.GuildChannel | discord.Thread +) -> bool: + """This checks if a user can see a given punishments. + This handles threads by checking if the parent channel has the user + + Args: + user (discord.Member): The user who is getting punished + channel (discord.abc.GuildChannel | discord.Thread): + The channel or thread the command was run from + + Returns: + bool: If the user can see the punishment + """ + if isinstance(channel, discord.Thread): + if user in channel.parent.members: + return True + else: + if user in channel.members: + return True + return False