WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
14 changed files with 55 additions and 61 deletions
Showing only changes of commit d91a4f49f9 - Show all commits

View file

@ -23,26 +23,24 @@ from redbot.core.commands.converter import parse_relativedelta, parse_timedelta
from redbot.core.utils.chat_formatting import (box, error, humanize_list, from redbot.core.utils.chat_formatting import (box, error, humanize_list,
humanize_timedelta, warning) humanize_timedelta, warning)
from aurora.importers.aurora import ImportAuroraView from .importers.aurora import ImportAuroraView
from aurora.importers.galacticbot import ImportGalacticBotView from .importers.galacticbot import ImportGalacticBotView
from aurora.menus.addrole import Addrole from .menus.addrole import Addrole
from aurora.menus.guild import Guild from .menus.guild import Guild
from aurora.menus.immune import Immune from .menus.immune import Immune
from aurora.menus.overrides import Overrides from .menus.overrides import Overrides
from aurora.models.change import Change from .models.change import Change
from aurora.models.moderation import Moderation from .models.moderation import Moderation
from aurora.utilities.config import config, register_config from .utilities.config import config, register_config
from aurora.utilities.database import connect, create_guild_table from .utilities.database import connect, create_guild_table
from aurora.utilities.factory import (addrole_embed, case_factory, from .utilities.factory import (addrole_embed, case_factory, changes_factory,
changes_factory, evidenceformat_factory, evidenceformat_factory, guild_embed,
guild_embed, immune_embed, immune_embed, message_factory, overrides_embed)
message_factory, overrides_embed) from .utilities.json import dump
from .utilities.logger import logger
from aurora.utilities.json import dump from .utilities.utils import (check_moddable, check_permissions,
from aurora.utilities.logger import logger get_footer_image, log, send_evidenceformat,
from aurora.utilities.utils import (check_moddable, check_permissions, timedelta_from_relativedelta)
get_footer_image, log, send_evidenceformat,
timedelta_from_relativedelta)
class Aurora(commands.Cog): class Aurora(commands.Cog):

View file

@ -8,8 +8,8 @@ from discord import ButtonStyle, Interaction, Message, ui
from redbot.core import commands from redbot.core import commands
from redbot.core.utils.chat_formatting import box, warning from redbot.core.utils.chat_formatting import box, warning
from aurora.models.moderation import Moderation from ..models.moderation import Moderation
from aurora.utilities.database import connect, create_guild_table from ..utilities.database import connect, create_guild_table
class ImportAuroraView(ui.View): class ImportAuroraView(ui.View):

View file

@ -7,8 +7,8 @@ from discord import ButtonStyle, Interaction, Message, ui
from redbot.core import commands from redbot.core import commands
from redbot.core.utils.chat_formatting import box, warning from redbot.core.utils.chat_formatting import box, warning
from aurora.models.moderation import Change, Moderation from ..models.moderation import Change, Moderation
from aurora.utilities.database import connect, create_guild_table from ..utilities.database import connect, create_guild_table
class ImportGalacticBotView(ui.View): class ImportGalacticBotView(ui.View):

View file

@ -2,8 +2,8 @@ from discord import ButtonStyle, Interaction, Message, ui
from redbot.core import commands from redbot.core import commands
from redbot.core.utils.chat_formatting import error from redbot.core.utils.chat_formatting import error
from aurora.utilities.config import config from ..utilities.config import config
from aurora.utilities.factory import addrole_embed from ..utilities.factory import addrole_embed
class Addrole(ui.View): class Addrole(ui.View):

View file

@ -1,9 +1,9 @@
from discord import ButtonStyle, Interaction, Message, ui from discord import ButtonStyle, Interaction, Message, ui
from redbot.core import commands from redbot.core import commands
from aurora.utilities.config import config from ..utilities.config import config
from aurora.utilities.factory import guild_embed from ..utilities.factory import guild_embed
from aurora.utilities.utils import create_pagesize_options from ..utilities.utils import create_pagesize_options
class Guild(ui.View): class Guild(ui.View):

View file

@ -2,8 +2,8 @@ from discord import ButtonStyle, Interaction, Message, ui
from redbot.core import commands from redbot.core import commands
from redbot.core.utils.chat_formatting import error from redbot.core.utils.chat_formatting import error
from aurora.utilities.config import config from ..utilities.config import config
from aurora.utilities.factory import immune_embed from ..utilities.factory import immune_embed
class Immune(ui.View): class Immune(ui.View):

View file

@ -1,9 +1,9 @@
from discord import ButtonStyle, Interaction, Message, ui from discord import ButtonStyle, Interaction, Message, ui
from redbot.core import commands from redbot.core import commands
from aurora.utilities.config import config from ..utilities.config import config
from aurora.utilities.factory import overrides_embed from ..utilities.factory import overrides_embed
from aurora.utilities.utils import create_pagesize_options from ..utilities.utils import create_pagesize_options
class Overrides(ui.View): class Overrides(ui.View):

View file

@ -4,9 +4,9 @@ from typing import Literal, Optional
from redbot.core.bot import Red from redbot.core.bot import Red
from aurora.models.base import AuroraBaseModel from ..models.base import AuroraBaseModel
from aurora.models.partials import PartialUser from ..models.partials import PartialUser
from aurora.utilities.logger import logger from ..utilities.logger import logger
class Change(AuroraBaseModel): class Change(AuroraBaseModel):

View file

@ -8,11 +8,11 @@ import discord
from discord import NotFound from discord import NotFound
from redbot.core.bot import Red from redbot.core.bot import Red
from aurora.models.base import AuroraGuildModel from ..models.base import AuroraGuildModel
from aurora.models.change import Change from ..models.change import Change
from aurora.models.partials import PartialChannel, PartialRole, PartialUser from ..models.partials import PartialChannel, PartialRole, PartialUser
from aurora.utilities.logger import logger from ..utilities.logger import logger
from aurora.utilities.utils import get_next_case_number from ..utilities.utils import get_next_case_number
class Moderation(AuroraGuildModel): class Moderation(AuroraGuildModel):

View file

@ -1,7 +1,7 @@
from discord import Forbidden, HTTPException, InvalidData, NotFound from discord import Forbidden, HTTPException, InvalidData, NotFound
from redbot.core.bot import Red from redbot.core.bot import Red
from aurora.models.base import AuroraBaseModel, AuroraGuildModel from ..models.base import AuroraBaseModel, AuroraGuildModel
class PartialUser(AuroraBaseModel): class PartialUser(AuroraBaseModel):

View file

@ -5,7 +5,7 @@ import sqlite3
from discord import Guild from discord import Guild
from redbot.core import data_manager from redbot.core import data_manager
from aurora.utilities.logger import logger from .logger import logger
def connect() -> sqlite3.Connection: def connect() -> sqlite3.Connection:

View file

@ -2,18 +2,14 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import Union from typing import Union
from discord import (Color, Embed, Guild, Interaction, InteractionMessage, from discord import Color, Embed, Guild, Interaction, InteractionMessage, Member, Role, User
Member, Role, User)
from redbot.core import commands from redbot.core import commands
from redbot.core.utils.chat_formatting import (bold, box, error, from redbot.core.utils.chat_formatting import bold, box, error, humanize_timedelta, warning
humanize_timedelta, warning)
from aurora.models.moderation import Moderation
from aurora.models.partials import PartialUser
from aurora.utilities.config import config
from aurora.utilities.utils import (get_bool_emoji, get_next_case_number,
get_pagesize_str)
from ..models.moderation import Moderation
from ..models.partials import PartialUser
from .config import config
from .utils import get_bool_emoji, get_next_case_number, get_pagesize_str
async def message_factory( async def message_factory(
color: Color, color: Color,

View file

@ -3,7 +3,7 @@ from datetime import datetime, timedelta
from redbot.core.bot import Red from redbot.core.bot import Red
from aurora.models.base import AuroraBaseModel from ..models.base import AuroraBaseModel
class JSONEncoder(json.JSONEncoder): class JSONEncoder(json.JSONEncoder):

View file

@ -8,7 +8,7 @@ from discord.errors import Forbidden
from redbot.core import commands, data_manager from redbot.core import commands, data_manager
from redbot.core.utils.chat_formatting import error from redbot.core.utils.chat_formatting import error
from aurora.utilities.config import config from ..utilities.config import config
def check_permissions( def check_permissions(
@ -111,7 +111,7 @@ async def check_moddable(
def get_next_case_number(guild_id: str, cursor=None) -> int: def get_next_case_number(guild_id: str, cursor=None) -> int:
"""This function returns the next case number from the MySQL table for a specific guild.""" """This function returns the next case number from the MySQL table for a specific guild."""
from aurora.utilities.database import connect from .database import connect
if not cursor: if not cursor:
database = connect() database = connect()
@ -125,8 +125,8 @@ def get_next_case_number(guild_id: str, cursor=None) -> int:
async def log(interaction: Interaction, moderation_id: int, resolved: bool = False) -> None: async def log(interaction: Interaction, moderation_id: int, resolved: bool = False) -> None:
"""This function sends a message to the guild's configured logging channel when an infraction takes place.""" """This function sends a message to the guild's configured logging channel when an infraction takes place."""
from aurora.models.moderation import Moderation from ..models.moderation import Moderation
from aurora.utilities.factory import log_factory from .factory import log_factory
logging_channel_id = await config.guild(interaction.guild).log_channel() logging_channel_id = await config.guild(interaction.guild).log_channel()
if logging_channel_id != " ": if logging_channel_id != " ":
@ -147,8 +147,8 @@ async def log(interaction: Interaction, moderation_id: int, resolved: bool = Fal
async def send_evidenceformat(interaction: Interaction, moderation_id: int) -> None: async def send_evidenceformat(interaction: Interaction, moderation_id: int) -> None:
"""This function sends an ephemeral message to the moderator who took the moderation action, with a pre-made codeblock for use in the mod-evidence channel.""" """This function sends an ephemeral message to the moderator who took the moderation action, with a pre-made codeblock for use in the mod-evidence channel."""
from aurora.models.moderation import Moderation from ..models.moderation import Moderation
from aurora.utilities.factory import evidenceformat_factory from .factory import evidenceformat_factory
send_evidence_bool = ( send_evidence_bool = (
await config.user(interaction.user).auto_evidenceformat() await config.user(interaction.user).auto_evidenceformat()