WIP: Refactor Aurora (3.0.0) #29
9 changed files with 45 additions and 45 deletions
|
@ -205,7 +205,7 @@ class Aurora(commands.Cog):
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
target: discord.User,
|
target: discord.User,
|
||||||
reason: str,
|
reason: str,
|
||||||
silent: bool = None,
|
silent: bool | None = None,
|
||||||
):
|
):
|
||||||
"""Add a note to a user.
|
"""Add a note to a user.
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ class Aurora(commands.Cog):
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
reason: str,
|
reason: str,
|
||||||
silent: bool = None,
|
silent: bool | None = None,
|
||||||
):
|
):
|
||||||
"""Warn a user.
|
"""Warn a user.
|
||||||
|
|
||||||
|
@ -322,8 +322,8 @@ class Aurora(commands.Cog):
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
role: discord.Role,
|
role: discord.Role,
|
||||||
reason: str,
|
reason: str,
|
||||||
duration: str = None,
|
duration: str | None = None,
|
||||||
silent: bool = None,
|
silent: bool | None = None,
|
||||||
):
|
):
|
||||||
"""Add a role to a user.
|
"""Add a role to a user.
|
||||||
|
|
||||||
|
@ -427,8 +427,8 @@ class Aurora(commands.Cog):
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
role: discord.Role,
|
role: discord.Role,
|
||||||
reason: str,
|
reason: str,
|
||||||
duration: str = None,
|
duration: str | None = None,
|
||||||
silent: bool = None,
|
silent: bool | None = None,
|
||||||
):
|
):
|
||||||
"""Remove a role from a user.
|
"""Remove a role from a user.
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ class Aurora(commands.Cog):
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
duration: str,
|
duration: str,
|
||||||
reason: str,
|
reason: str,
|
||||||
silent: bool = None,
|
silent: bool | None = None,
|
||||||
):
|
):
|
||||||
"""Mute a user.
|
"""Mute a user.
|
||||||
|
|
||||||
|
@ -617,8 +617,8 @@ class Aurora(commands.Cog):
|
||||||
self,
|
self,
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
reason: str = None,
|
reason: str | None = None,
|
||||||
silent: bool = None,
|
silent: bool | None = None,
|
||||||
):
|
):
|
||||||
"""Unmute a user.
|
"""Unmute a user.
|
||||||
|
|
||||||
|
@ -692,7 +692,7 @@ class Aurora(commands.Cog):
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
target: discord.Member,
|
target: discord.Member,
|
||||||
reason: str,
|
reason: str,
|
||||||
silent: bool = None,
|
silent: bool | None = None,
|
||||||
):
|
):
|
||||||
"""Kick a user.
|
"""Kick a user.
|
||||||
|
|
||||||
|
@ -762,9 +762,9 @@ class Aurora(commands.Cog):
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
target: discord.User,
|
target: discord.User,
|
||||||
reason: str,
|
reason: str,
|
||||||
duration: str = None,
|
duration: str | None = None,
|
||||||
delete_messages: Choice[int] = None,
|
delete_messages: Choice[int] | None = None,
|
||||||
silent: bool = None,
|
silent: bool | None = None,
|
||||||
):
|
):
|
||||||
"""Ban a user.
|
"""Ban a user.
|
||||||
|
|
||||||
|
@ -901,8 +901,8 @@ class Aurora(commands.Cog):
|
||||||
self,
|
self,
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
target: discord.User,
|
target: discord.User,
|
||||||
reason: str = None,
|
reason: str | None = None,
|
||||||
silent: bool = None,
|
silent: bool | None = None,
|
||||||
):
|
):
|
||||||
"""Unban a user.
|
"""Unban a user.
|
||||||
|
|
||||||
|
@ -976,12 +976,12 @@ class Aurora(commands.Cog):
|
||||||
async def history(
|
async def history(
|
||||||
self,
|
self,
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
target: discord.User = None,
|
target: discord.User | None = None,
|
||||||
moderator: discord.User = None,
|
moderator: discord.User | None = None,
|
||||||
pagesize: app_commands.Range[int, 1, 20] = None,
|
pagesize: app_commands.Range[int, 1, 20] | None = None,
|
||||||
page: int = 1,
|
page: int = 1,
|
||||||
ephemeral: bool = None,
|
ephemeral: bool | None = None,
|
||||||
inline: bool = None,
|
inline: bool | None = None,
|
||||||
export: bool = False,
|
export: bool = False,
|
||||||
):
|
):
|
||||||
"""List previous infractions.
|
"""List previous infractions.
|
||||||
|
@ -1179,7 +1179,7 @@ class Aurora(commands.Cog):
|
||||||
|
|
||||||
@app_commands.command(name="resolve")
|
@app_commands.command(name="resolve")
|
||||||
async def 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.
|
"""Resolve a specific case.
|
||||||
|
|
||||||
|
@ -1251,10 +1251,10 @@ class Aurora(commands.Cog):
|
||||||
self,
|
self,
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
case: int,
|
case: int,
|
||||||
ephemeral: bool = None,
|
ephemeral: bool | None = None,
|
||||||
evidenceformat: bool = False,
|
evidenceformat: bool = False,
|
||||||
changes: bool = False,
|
changes: bool = False,
|
||||||
export: Choice[str] = None,
|
export: Choice[str] | None = None,
|
||||||
):
|
):
|
||||||
"""Check the details of a specific case.
|
"""Check the details of a specific case.
|
||||||
|
|
||||||
|
@ -1355,7 +1355,7 @@ class Aurora(commands.Cog):
|
||||||
interaction: discord.Interaction,
|
interaction: discord.Interaction,
|
||||||
case: int,
|
case: int,
|
||||||
reason: str,
|
reason: str,
|
||||||
duration: str = None,
|
duration: str | None = None,
|
||||||
):
|
):
|
||||||
"""Edit the reason of a specific case.
|
"""Edit the reason of a specific case.
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ from aurora.utilities.factory import addrole_embed
|
||||||
|
|
||||||
|
|
||||||
class Addrole(ui.View):
|
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__()
|
super().__init__()
|
||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
|
@ -7,7 +7,7 @@ from aurora.utilities.utils import create_pagesize_options
|
||||||
|
|
||||||
|
|
||||||
class Guild(ui.View):
|
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__()
|
super().__init__()
|
||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
|
@ -7,7 +7,7 @@ from aurora.utilities.factory import immune_embed
|
||||||
|
|
||||||
|
|
||||||
class Immune(ui.View):
|
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__()
|
super().__init__()
|
||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
|
@ -7,7 +7,7 @@ from aurora.utilities.utils import create_pagesize_options
|
||||||
|
|
||||||
|
|
||||||
class Overrides(ui.View):
|
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__()
|
super().__init__()
|
||||||
self.ctx = ctx
|
self.ctx = ctx
|
||||||
self.message = message
|
self.message = message
|
||||||
|
|
|
@ -9,7 +9,7 @@ class AuroraBaseModel(BaseModel):
|
||||||
model_config = ConfigDict(ignored_types=(Red,), arbitrary_types_allowed=True)
|
model_config = ConfigDict(ignored_types=(Red,), arbitrary_types_allowed=True)
|
||||||
bot: Red
|
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
|
from aurora.utilities.json import ( # pylint: disable=cyclic-import
|
||||||
dump, dumps)
|
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)
|
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."""
|
"""Subclass of AuroraBaseModel that includes a guild_id attribute, and a modified to_json() method to match."""
|
||||||
guild_id: int
|
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
|
from aurora.utilities.json import ( # pylint: disable=cyclic-import
|
||||||
dump, dumps)
|
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)
|
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)
|
||||||
|
|
|
@ -223,16 +223,16 @@ class Moderation(AuroraGuildModel):
|
||||||
target_type: str,
|
target_type: str,
|
||||||
target_id: int,
|
target_id: int,
|
||||||
role_id: int,
|
role_id: int,
|
||||||
duration: timedelta = None,
|
duration: timedelta | None = None,
|
||||||
reason: str = None,
|
reason: str | None = None,
|
||||||
database: sqlite3.Connection = None,
|
database: sqlite3.Connection | None = None,
|
||||||
timestamp: datetime = None,
|
timestamp: datetime | None = None,
|
||||||
resolved: bool = False,
|
resolved: bool = False,
|
||||||
resolved_by: int = None,
|
resolved_by: int | None = None,
|
||||||
resolved_reason: str = None,
|
resolved_reason: str | None = None,
|
||||||
expired: bool = None,
|
expired: bool | None = None,
|
||||||
changes: list = None,
|
changes: list | None = None,
|
||||||
metadata: dict = None,
|
metadata: dict | None = None,
|
||||||
) -> "Moderation":
|
) -> "Moderation":
|
||||||
from aurora.utilities.database import connect
|
from aurora.utilities.database import connect
|
||||||
from aurora.utilities.json import dumps
|
from aurora.utilities.json import dumps
|
||||||
|
|
|
@ -20,10 +20,10 @@ async def message_factory(
|
||||||
guild: Guild,
|
guild: Guild,
|
||||||
reason: str,
|
reason: str,
|
||||||
moderation_type: str,
|
moderation_type: str,
|
||||||
moderator: Union[Member, User] = None,
|
moderator: Union[Member, User] | None = None,
|
||||||
duration: timedelta = None,
|
duration: timedelta | None = None,
|
||||||
response: InteractionMessage = None,
|
response: InteractionMessage | None = None,
|
||||||
role: Role = None,
|
role: Role | None = None,
|
||||||
) -> Embed:
|
) -> Embed:
|
||||||
"""This function creates a message from set parameters, meant for contacting the moderated user.
|
"""This function creates a message from set parameters, meant for contacting the moderated user.
|
||||||
|
|
||||||
|
|
|
@ -14,8 +14,8 @@ from aurora.utilities.config import config
|
||||||
def check_permissions(
|
def check_permissions(
|
||||||
user: User,
|
user: User,
|
||||||
permissions: list,
|
permissions: list,
|
||||||
ctx: Union[commands.Context, Interaction] = None,
|
ctx: Union[commands.Context, Interaction] | None = None,
|
||||||
guild: Guild = None,
|
guild: Guild | None = None,
|
||||||
) -> Union[bool, str]:
|
) -> Union[bool, str]:
|
||||||
"""Checks if a user has a specific permission (or a list of permissions) in a channel."""
|
"""Checks if a user has a specific permission (or a list of permissions) in a channel."""
|
||||||
if ctx:
|
if ctx:
|
||||||
|
|
Loading…
Reference in a new issue