feat(moderation): added resolve command
All checks were successful
Pylint / Pylint (push) Successful in 1m12s
All checks were successful
Pylint / Pylint (push) Successful in 1m12s
This commit is contained in:
parent
eb1cd6aada
commit
6001c926f2
1 changed files with 23 additions and 0 deletions
|
@ -355,6 +355,29 @@ class Moderation(commands.Cog):
|
||||||
pass
|
pass
|
||||||
await self.mysql_log(interaction.guild.id, interaction.user.id, 'UNBAN', target.id, 'NULL', reason)
|
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")
|
@app_commands.command(name="case")
|
||||||
async def case(self, interaction: discord.Interaction, case_number: int, ephemeral: bool = False):
|
async def case(self, interaction: discord.Interaction, case_number: int, ephemeral: bool = False):
|
||||||
"""Check the details of a specific case."""
|
"""Check the details of a specific case."""
|
||||||
|
|
Loading…
Reference in a new issue