fix(aurora): fixed failed_cases in the aurora importer
This commit is contained in:
parent
fe5823b637
commit
d1b5346396
1 changed files with 21 additions and 5 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue