feat(aurora): change history to use Moderation.from_sql_all()

This commit is contained in:
Seaswimmer 2024-06-03 00:22:32 -04:00
parent c35580c576
commit 76f176d4cc
Signed by untrusted user: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -1083,21 +1083,6 @@ class Aurora(commands.Cog):
database = connect()
if export:
database.row_factory = sqlite3.Row
cursor = database.cursor()
query = f"""SELECT *
FROM moderation_{interaction.guild.id}
ORDER BY moderation_id DESC;"""
cursor.execute(query)
results = cursor.fetchall()
cases = []
for result in results:
case = dict(result)
cases.append(case)
try:
filename = (
str(data_manager.cog_data_path(cog_instance=self))
@ -1105,8 +1090,10 @@ class Aurora(commands.Cog):
+ f"moderation_{interaction.guild.id}.json"
)
cases = Moderation.from_sql_all(interaction.client, interaction.guild.id)
with open(filename, "w", encoding="utf-8") as f:
dump(cases, f, indent=2)
dump(obj=cases, fp=f, indent=2)
await interaction.followup.send(
file=discord.File(
@ -1124,7 +1111,6 @@ class Aurora(commands.Cog):
+ box(e, "py"),
ephemeral=ephemeral,
)
cursor.close()
database.close()
return