WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
9 changed files with 45 additions and 45 deletions
Showing only changes of commit ab878739c4 - Show all commits

View file

@ -205,7 +205,7 @@ class Aurora(commands.Cog):
interaction: discord.Interaction,
target: discord.User,
reason: str,
silent: bool = None,
silent: bool | None = None,
):
"""Add a note to a user.
@ -263,7 +263,7 @@ class Aurora(commands.Cog):
interaction: discord.Interaction,
target: discord.Member,
reason: str,
silent: bool = None,
silent: bool | None = None,
):
"""Warn a user.
@ -322,8 +322,8 @@ class Aurora(commands.Cog):
target: discord.Member,
role: discord.Role,
reason: str,
duration: str = None,
silent: bool = None,
duration: str | None = None,
silent: bool | None = None,
):
"""Add a role to a user.
@ -427,8 +427,8 @@ class Aurora(commands.Cog):
target: discord.Member,
role: discord.Role,
reason: str,
duration: str = None,
silent: bool = None,
duration: str | None = None,
silent: bool | None = None,
):
"""Remove a role from a user.
@ -532,7 +532,7 @@ class Aurora(commands.Cog):
target: discord.Member,
duration: str,
reason: str,
silent: bool = None,
silent: bool | None = None,
):
"""Mute a user.
@ -617,8 +617,8 @@ class Aurora(commands.Cog):
self,
interaction: discord.Interaction,
target: discord.Member,
reason: str = None,
silent: bool = None,
reason: str | None = None,
silent: bool | None = None,
):
"""Unmute a user.
@ -692,7 +692,7 @@ class Aurora(commands.Cog):
interaction: discord.Interaction,
target: discord.Member,
reason: str,
silent: bool = None,
silent: bool | None = None,
):
"""Kick a user.
@ -762,9 +762,9 @@ class Aurora(commands.Cog):
interaction: discord.Interaction,
target: discord.User,
reason: str,
duration: str = None,
delete_messages: Choice[int] = None,
silent: bool = None,
duration: str | None = None,
delete_messages: Choice[int] | None = None,
silent: bool | None = None,
):
"""Ban a user.
@ -901,8 +901,8 @@ class Aurora(commands.Cog):
self,
interaction: discord.Interaction,
target: discord.User,
reason: str = None,
silent: bool = None,
reason: str | None = None,
silent: bool | None = None,
):
"""Unban a user.
@ -976,12 +976,12 @@ class Aurora(commands.Cog):
async def history(
self,
interaction: discord.Interaction,
target: discord.User = None,
moderator: discord.User = None,
pagesize: app_commands.Range[int, 1, 20] = None,
target: discord.User | None = None,
moderator: discord.User | None = None,
pagesize: app_commands.Range[int, 1, 20] | None = None,
page: int = 1,
ephemeral: bool = None,
inline: bool = None,
ephemeral: bool | None = None,
inline: bool | None = None,
export: bool = False,
):
"""List previous infractions.
@ -1179,7 +1179,7 @@ class Aurora(commands.Cog):
@app_commands.command(name="resolve")
async def resolve(
self, interaction: discord.Interaction, case: int, reason: str = None
self, interaction: discord.Interaction, case: int, reason: str | None = None
):
"""Resolve a specific case.
@ -1251,10 +1251,10 @@ class Aurora(commands.Cog):
self,
interaction: discord.Interaction,
case: int,
ephemeral: bool = None,
ephemeral: bool | None = None,
evidenceformat: bool = False,
changes: bool = False,
export: Choice[str] = None,
export: Choice[str] | None = None,
):
"""Check the details of a specific case.
@ -1355,7 +1355,7 @@ class Aurora(commands.Cog):
interaction: discord.Interaction,
case: int,
reason: str,
duration: str = None,
duration: str | None = None,
):
"""Edit the reason of a specific case.

View file

@ -7,7 +7,7 @@ from aurora.utilities.factory import addrole_embed
class Addrole(ui.View):
def __init__(self, ctx: commands.Context, message: Message, timeout: int = None):
def __init__(self, ctx: commands.Context, message: Message, timeout: int | None = None):
super().__init__()
self.ctx = ctx
self.message = message

View file

@ -7,7 +7,7 @@ from aurora.utilities.utils import create_pagesize_options
class Guild(ui.View):
def __init__(self, ctx: commands.Context, message: Message, timeout: int = None):
def __init__(self, ctx: commands.Context, message: Message, timeout: int | None = None):
super().__init__()
self.ctx = ctx
self.message = message

View file

@ -7,7 +7,7 @@ from aurora.utilities.factory import immune_embed
class Immune(ui.View):
def __init__(self, ctx: commands.Context, message: Message, timeout: int = None):
def __init__(self, ctx: commands.Context, message: Message, timeout: int | None = None):
super().__init__()
self.ctx = ctx
self.message = message

View file

@ -7,7 +7,7 @@ from aurora.utilities.utils import create_pagesize_options
class Overrides(ui.View):
def __init__(self, ctx: commands.Context, message: Message, timeout: int = None):
def __init__(self, ctx: commands.Context, message: Message, timeout: int | None = None):
super().__init__()
self.ctx = ctx
self.message = message

View file

@ -9,7 +9,7 @@ class AuroraBaseModel(BaseModel):
model_config = ConfigDict(ignored_types=(Red,), arbitrary_types_allowed=True)
bot: Red
def to_json(self, indent: int = None, file: Any = None, **kwargs):
def to_json(self, indent: int | None = None, file: Any | None = None, **kwargs):
from aurora.utilities.json import ( # pylint: disable=cyclic-import
dump, dumps)
return dump(self.model_dump(exclude={"bot"}), file, indent=indent, **kwargs) if file else dumps(self.model_dump(exclude={"bot"}), indent=indent, **kwargs)
@ -18,7 +18,7 @@ class AuroraGuildModel(AuroraBaseModel):
"""Subclass of AuroraBaseModel that includes a guild_id attribute, and a modified to_json() method to match."""
guild_id: int
def to_json(self, indent: int = None, file: Any = None, **kwargs):
def to_json(self, indent: int | None = None, file: Any | None = None, **kwargs):
from aurora.utilities.json import ( # pylint: disable=cyclic-import
dump, dumps)
return dump(self.model_dump(exclude={"bot", "guild_id"}), file, indent=indent, **kwargs) if file else dumps(self.model_dump(exclude={"bot", "guild_id"}), indent=indent, **kwargs)

View file

@ -223,16 +223,16 @@ class Moderation(AuroraGuildModel):
target_type: str,
target_id: int,
role_id: int,
duration: timedelta = None,
reason: str = None,
database: sqlite3.Connection = None,
timestamp: datetime = None,
duration: timedelta | None = None,
reason: str | None = None,
database: sqlite3.Connection | None = None,
timestamp: datetime | None = None,
resolved: bool = False,
resolved_by: int = None,
resolved_reason: str = None,
expired: bool = None,
changes: list = None,
metadata: dict = None,
resolved_by: int | None = None,
resolved_reason: str | None = None,
expired: bool | None = None,
changes: list | None = None,
metadata: dict | None = None,
) -> "Moderation":
from aurora.utilities.database import connect
from aurora.utilities.json import dumps

View file

@ -20,10 +20,10 @@ async def message_factory(
guild: Guild,
reason: str,
moderation_type: str,
moderator: Union[Member, User] = None,
duration: timedelta = None,
response: InteractionMessage = None,
role: Role = None,
moderator: Union[Member, User] | None = None,
duration: timedelta | None = None,
response: InteractionMessage | None = None,
role: Role | None = None,
) -> Embed:
"""This function creates a message from set parameters, meant for contacting the moderated user.

View file

@ -14,8 +14,8 @@ from aurora.utilities.config import config
def check_permissions(
user: User,
permissions: list,
ctx: Union[commands.Context, Interaction] = None,
guild: Guild = None,
ctx: Union[commands.Context, Interaction] | None = None,
guild: Guild | None = None,
) -> Union[bool, str]:
"""Checks if a user has a specific permission (or a list of permissions) in a channel."""
if ctx: