fix(moderation): fixed resolve command
All checks were successful
Pylint / Pylint (push) Successful in 1m13s

This commit is contained in:
Seaswimmer 2023-10-06 09:11:22 -04:00
parent 5fa62fceca
commit fedd5f6799
No known key found for this signature in database
GPG key ID: 5019678FD9CF50D8

View file

@ -398,8 +398,12 @@ class Moderation(commands.Cog):
@app_commands.command(name="resolve") @app_commands.command(name="resolve")
async def resolve(self, interaction: discord.Interaction, case_number: int, reason: str = None): async def resolve(self, interaction: discord.Interaction, case_number: int, reason: str = None):
"""Resolve a specific case.""" """Resolve a specific case."""
conf = await self.check_conf(['mysql_database'])
if conf:
raise(LookupError)
database = await self.connect() database = await self.connect()
cursor = database.cursor() cursor = database.cursor()
db = await self.config.mysql_database()
query_1 = "SELECT * FROM moderation_%s WHERE moderation_id = %s;" query_1 = "SELECT * FROM moderation_%s WHERE moderation_id = %s;"
cursor.execute(query_1, (interaction.guild.id, case_number)) cursor.execute(query_1, (interaction.guild.id, case_number))
result_1 = cursor.fetchone() result_1 = cursor.fetchone()
@ -428,9 +432,9 @@ class Moderation(commands.Cog):
await interaction.guild.unban(user, reason=f"Case #{case_number} resolved by {interaction.user.id}") await interaction.guild.unban(user, reason=f"Case #{case_number} resolved by {interaction.user.id}")
except discord.NotFound: except discord.NotFound:
pass pass
resolve_query = f"UPDATE moderation_{interaction.guild.id} SET resolved = 1, expired = 1, resolve_reason = %s WHERE moderation_id = %s" resolve_query = f"UPDATE `{db}`.`moderation_{interaction.guild.id}` SET resolved = 1, expired = 1, resolve_reason = %s WHERE moderation_id = %s"
else: else:
resolve_query = f"UPDATE moderation_{interaction.guild.id} SET resolved = 1, resolve_reason = %s WHERE moderation_id = %s" resolve_query = f"UPDATE `{db}`.`moderation_{interaction.guild.id}` SET resolved = 1, resolve_reason = %s WHERE moderation_id = %s"
cursor.execute(resolve_query, (reason, case_number)) cursor.execute(resolve_query, (reason, case_number))
await interaction.response.send_message(content=f"✅ Moderation #{case_number} resolved!") await interaction.response.send_message(content=f"✅ Moderation #{case_number} resolved!")