feat(aurora): bunch of changes
This commit is contained in:
parent
f6a42b97d9
commit
0bcbcd6c0c
6 changed files with 122 additions and 149 deletions
|
@ -9,9 +9,8 @@ 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
|
||||
from ..utilities.utils import create_guild_table, timedelta_from_string
|
||||
|
||||
|
||||
class ImportAuroraView(ui.View):
|
||||
|
@ -29,10 +28,8 @@ class ImportAuroraView(ui.View):
|
|||
"Deleting original table...", ephemeral=True
|
||||
)
|
||||
|
||||
database = await connect()
|
||||
query = f"DROP TABLE IF EXISTS moderation_{self.ctx.guild.id};"
|
||||
await database.execute(query)
|
||||
await database.commit()
|
||||
await Moderation.execute(query=query, return_obj=False)
|
||||
|
||||
await interaction.edit_original_response(content="Creating new table...")
|
||||
|
||||
|
@ -111,15 +108,11 @@ class ImportAuroraView(ui.View):
|
|||
expired=case["expired"],
|
||||
changes=changes,
|
||||
metadata=metadata,
|
||||
database=database,
|
||||
return_obj=False
|
||||
)
|
||||
except Exception as e: # pylint: disable=broad-exception-caught
|
||||
failed_cases.append(str(case["moderation_id"]) + f": {e}")
|
||||
|
||||
await database.commit()
|
||||
await database.close()
|
||||
|
||||
await interaction.edit_original_response(content="Import complete.")
|
||||
if failed_cases:
|
||||
filename = (
|
||||
|
|
|
@ -8,13 +8,14 @@ from redbot.core import commands
|
|||
from redbot.core.utils.chat_formatting import box, warning
|
||||
|
||||
from ..models.moderation import Change, Moderation
|
||||
from ..utilities.database import connect, create_guild_table
|
||||
from ..utilities.database import create_guild_table
|
||||
|
||||
|
||||
class ImportGalacticBotView(ui.View):
|
||||
def __init__(self, timeout, ctx, message):
|
||||
super().__init__()
|
||||
self.ctx: commands.Context = ctx
|
||||
self.timeout = timeout
|
||||
self.message: Message = message
|
||||
|
||||
@ui.button(label="Yes", style=ButtonStyle.success)
|
||||
|
@ -26,7 +27,7 @@ class ImportGalacticBotView(ui.View):
|
|||
"Deleting original table...", ephemeral=True
|
||||
)
|
||||
|
||||
database = await connect()
|
||||
database = await Moderation.connect()
|
||||
cursor = await database.cursor()
|
||||
|
||||
query = f"DROP TABLE IF EXISTS moderation_{self.ctx.guild.id};"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue