fix(aurora): fixed failed_cases in the aurora importer

This commit is contained in:
Seaswimmer 2024-06-05 00:51:13 -04:00
parent fe5823b637
commit d1b5346396
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -1,14 +1,16 @@
# pylint: disable=duplicate-code
import json
import os
from time import time
from typing import Dict
from discord import ButtonStyle, Interaction, Message, ui
from redbot.core import commands
from redbot.core.utils.chat_formatting import box, warning
from discord import ButtonStyle, File, Interaction, Message, ui
from redbot.core import commands, data_manager
from redbot.core.utils.chat_formatting import warning
from ..models.moderation import Moderation
from ..utilities.database import connect, create_guild_table
from ..utilities.json import dump
from ..utilities.utils import timedelta_from_string
@ -118,12 +120,26 @@ class ImportAuroraView(ui.View):
await interaction.edit_original_response(content="Import complete.")
if failed_cases:
filename = (
str(data_manager.cog_data_path(cog_instance=self))
+ str(os.sep)
+ f"failed_cases_{interaction.guild.id}.json"
)
with open(filename, "w", encoding="utf-8") as f:
dump(obj=failed_cases, fp=f, indent=2)
await interaction.edit_original_response(
content="Import complete.\n"
+ warning("Failed to import the following cases:\n")
+ box(failed_cases)
+ warning("Failed to import the following cases:\n"),
attachments=[File(
filename, f"failed_cases_{interaction.guild.id}.json"
)
]
)
os.remove(filename)
@ui.button(label="No", style=ButtonStyle.danger)
async def import_button_n(
self, interaction: Interaction, button: ui.Button