From 6001c926f201e8aa7cfa414b057a4c1ce51011f6 Mon Sep 17 00:00:00 2001 From: SeaswimmerTheFsh Date: Thu, 5 Oct 2023 17:09:55 -0400 Subject: [PATCH] feat(moderation): added resolve command --- moderation/moderation.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/moderation/moderation.py b/moderation/moderation.py index 82e0bbb..1fcf6da 100644 --- a/moderation/moderation.py +++ b/moderation/moderation.py @@ -355,6 +355,29 @@ class Moderation(commands.Cog): pass await self.mysql_log(interaction.guild.id, interaction.user.id, 'UNBAN', target.id, 'NULL', reason) + @app_commands.command(name="resolve") + async def resolve(self, interaction: discord.Interaction, case_number: int, reason: str = None): + """Resolve a specific case.""" + database = await self.connect() + cursor = database.cursor() + query_1 = "SELECT * FROM moderation_%s WHERE moderation_id = %s;" + cursor.execute(query_1, (interaction.guild.id, case_number)) + result_1 = cursor.fetchone() + if result_1 is None: + await interaction.response.send_message(content=f"There is no moderation with a case number of {case_number}!", ephemeral=True) + return + query_2 = "SELECT * FROM moderation_%s WHERE moderation_id = %s AND resolved = 0;" + cursor.execute(query_2, (interaction.guild.id, case_number)) + result_2 = cursor.fetchone() + if result_2 is None: + await interaction.response.send_message(content=f"This moderation has already been resolved!\nUse `/case {case_number}` for more information.", ephemeral=True) + return + if reason is None: + reason = "No reason given." + resolve_query = f"UPDATE moderation_{interaction.guild.id} SET resolved = 1, resolve_reason = %s WHERE moderation_id = %s" + cursor.execute(resolve_query, (reason, case_number)) + await interaction.response.send_message(content=f"✅ Moderation #{case_number} resolved!") + @app_commands.command(name="case") async def case(self, interaction: discord.Interaction, case_number: int, ephemeral: bool = False): """Check the details of a specific case."""