Compare commits

..

2 commits

Author SHA1 Message Date
1e59f0cada
feat(moderation): history embeds can now be epheremal
All checks were successful
Pylint / Pylint (push) Successful in 1m16s
2023-10-06 22:55:41 -04:00
3c35eeb29d
feat(moderation): enabled checking history without a user/target or moderator set 2023-10-06 22:55:07 -04:00

View file

@ -449,7 +449,7 @@ class Moderation(commands.Cog):
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="history") @app_commands.command(name="history")
async def history(self, interaction: discord.Interaction, target: discord.Member = None, moderator: discord.Member = None, pagesize: app_commands.Range[int, 1, 25] = 5, page: int = 1): async def history(self, interaction: discord.Interaction, target: discord.Member = None, moderator: discord.Member = None, pagesize: app_commands.Range[int, 1, 25] = 5, page: int = 1, epheremal: bool = False):
"""List previous infractions.""" """List previous infractions."""
database = await self.connect() database = await self.connect()
cursor = database.cursor() cursor = database.cursor()
@ -465,6 +465,11 @@ class Moderation(commands.Cog):
WHERE moderator_id = %s WHERE moderator_id = %s
ORDER BY moderation_id DESC;""" ORDER BY moderation_id DESC;"""
cursor.execute(query, (interaction.guild.id, moderator.id)) cursor.execute(query, (interaction.guild.id, moderator.id))
else:
query = """SELECT *
FROM moderation_%s
ORDER BY moderation_id DESC;"""
cursor.execute(query, (interaction.guild.id))
results = cursor.fetchall() results = cursor.fetchall()
result_dict_list = [] result_dict_list = []
for result in results: for result in results:
@ -491,7 +496,7 @@ class Moderation(commands.Cog):
if bool(case['resolved']): if bool(case['resolved']):
field_value = field_value + "\n**Resolved:** True" field_value = field_value + "\n**Resolved:** True"
embed.add_field(name=field_name, value=field_value, inline=False) embed.add_field(name=field_name, value=field_value, inline=False)
await interaction.response.send_message(embed=embed) await interaction.response.send_message(embed=embed, ephemeral=epheremal)
@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):