fix(moderation): fixed history command erroring on unmigrated database
This commit is contained in:
parent
b982975a0c
commit
7f0d2ae153
1 changed files with 7 additions and 7 deletions
|
@ -588,18 +588,12 @@ class Moderation(commands.Cog):
|
||||||
results = cursor.fetchall()
|
results = cursor.fetchall()
|
||||||
result_dict_list = []
|
result_dict_list = []
|
||||||
|
|
||||||
for result in results:
|
|
||||||
case_dict = generate_dict(result)
|
|
||||||
if case_dict['moderation_id'] == 0:
|
|
||||||
continue
|
|
||||||
result_dict_list.append(case_dict)
|
|
||||||
|
|
||||||
if export:
|
if export:
|
||||||
try:
|
try:
|
||||||
filename = str(data_manager.cog_data_path(cog_instance=self)) + str(os.sep) + f"moderation_{interaction.guild.id}.json"
|
filename = str(data_manager.cog_data_path(cog_instance=self)) + str(os.sep) + f"moderation_{interaction.guild.id}.json"
|
||||||
|
|
||||||
with open(filename, "w", encoding="utf-8") as f:
|
with open(filename, "w", encoding="utf-8") as f:
|
||||||
json.dump(result_dict_list, f, indent=2)
|
json.dump(results, f, indent=2)
|
||||||
|
|
||||||
await interaction.followup.send(file=discord.File(filename, f"moderation_{interaction.guild.id}.json"), ephemeral=ephemeral)
|
await interaction.followup.send(file=discord.File(filename, f"moderation_{interaction.guild.id}.json"), ephemeral=ephemeral)
|
||||||
|
|
||||||
|
@ -609,6 +603,12 @@ class Moderation(commands.Cog):
|
||||||
await interaction.followup.send(content=f"An error occured while exporting the moderation history.\nError:\n```{e}```", ephemeral=ephemeral)
|
await interaction.followup.send(content=f"An error occured while exporting the moderation history.\nError:\n```{e}```", ephemeral=ephemeral)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
for result in results:
|
||||||
|
case_dict = generate_dict(result)
|
||||||
|
if case_dict['moderation_id'] == 0:
|
||||||
|
continue
|
||||||
|
result_dict_list.append(case_dict)
|
||||||
|
|
||||||
case_quantity = len(result_dict_list)
|
case_quantity = len(result_dict_list)
|
||||||
page_quantity = round(case_quantity / pagesize)
|
page_quantity = round(case_quantity / pagesize)
|
||||||
start_index = (page - 1) * pagesize
|
start_index = (page - 1) * pagesize
|
||||||
|
|
Loading…
Reference in a new issue