From 76f176d4ccf7f61f91207f2ac34e8c91c5540915 Mon Sep 17 00:00:00 2001 From: Seaswimmer Date: Mon, 3 Jun 2024 00:22:32 -0400 Subject: [PATCH] feat(aurora): change history to use `Moderation.from_sql_all()` --- aurora/aurora.py | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/aurora/aurora.py b/aurora/aurora.py index ec8a0e6..e4f9c2b 100644 --- a/aurora/aurora.py +++ b/aurora/aurora.py @@ -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