WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
Showing only changes of commit d1b5346396 - Show all commits

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,11 +120,25 @@ 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(