From de90d3324c0d69801381abc9ae6bbf50b2dc80f2 Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Fri, 5 Jun 2026 14:23:01 -0700 Subject: [PATCH 1/2] Adds autocomplete prompts to the unwarn command --- techsupport_bot/commands/moderator.py | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/techsupport_bot/commands/moderator.py b/techsupport_bot/commands/moderator.py index 7a467b750..a7b5ab03b 100644 --- a/techsupport_bot/commands/moderator.py +++ b/techsupport_bot/commands/moderator.py @@ -634,6 +634,40 @@ async def handle_unwarn_user( embed = generate_response_embed(user=target, action="unwarn", reason=reason) await interaction.response.send_message(content=target.mention, embed=embed) + @handle_unwarn_user.autocomplete("warning") + async def unwarn_warning_autocomplete( + self: Self, + interaction: discord.Interaction, + current: str, + ) -> list[app_commands.Choice[str]]: + """This runs autocomplete for the unwarn function + This will show options where current is a valid substring + + Args: + interaction (discord.Interaction): The interaction creating the command + current (str): The current text in the warning field + + Returns: + list[app_commands.Choice[str]]: The list of options proposed to the user + """ + target = interaction.namespace.target + + if target is None: + return [] + + all_warnings = await moderation.get_all_warnings( + self.bot, target, interaction.guild + ) + + if not all_warnings: + return [] + + return [ + app_commands.Choice(name=warning.reason, value=warning.reason) + for warning in all_warnings + if current.lower() in warning.reason.lower() + ][:10] + @app_commands.checks.has_permissions(kick_members=True) @app_commands.checks.bot_has_permissions(kick_members=True) @warnings_group.command( From e481764918384da877bdcc5e12e149b40cb32a40 Mon Sep 17 00:00:00 2001 From: ajax146 <31014239+ajax146@users.noreply.github.com> Date: Sun, 7 Jun 2026 14:36:34 -0700 Subject: [PATCH 2/2] Add permission check --- techsupport_bot/commands/moderator.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/techsupport_bot/commands/moderator.py b/techsupport_bot/commands/moderator.py index c7edd65f7..1abc1d983 100644 --- a/techsupport_bot/commands/moderator.py +++ b/techsupport_bot/commands/moderator.py @@ -640,6 +640,9 @@ async def unwarn_warning_autocomplete( Returns: list[app_commands.Choice[str]]: The list of options proposed to the user """ + if not interaction.permissions.kick_members: + return [] + target = interaction.namespace.target if target is None: