WIP: Moderation type registry #26
3 changed files with 7 additions and 7 deletions
|
@ -1191,7 +1191,7 @@ class Aurora(commands.Cog):
|
||||||
Reason for resolving case"""
|
Reason for resolving case"""
|
||||||
permissions = check_permissions(
|
permissions = check_permissions(
|
||||||
interaction.client.user,
|
interaction.client.user,
|
||||||
["embed_links", "moderate_members", "ban_members"],
|
("embed_links", "moderate_members", "ban_members"),
|
||||||
interaction,
|
interaction,
|
||||||
)
|
)
|
||||||
if permissions:
|
if permissions:
|
||||||
|
|
|
@ -63,10 +63,10 @@ class Moderation(AuroraGuildModel):
|
||||||
return await PartialRole.from_id(self.bot, self.guild_id, self.role_id)
|
return await PartialRole.from_id(self.bot, self.guild_id, self.role_id)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self) -> str:
|
||||||
return f"{self.moderation_type} {self.target_type} {self.target_id} {self.reason}"
|
return f"{self.moderation_type} {self.target_type} {self.target_id} {self.reason}"
|
||||||
|
|
||||||
async def resolve(self, resolved_by: int, reason: str):
|
async def resolve(self, resolved_by: int, reason: str) -> None:
|
||||||
if self.resolved:
|
if self.resolved:
|
||||||
raise ValueError("Case is already resolved!")
|
raise ValueError("Case is already resolved!")
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ class Moderation(AuroraGuildModel):
|
||||||
|
|
||||||
self.update()
|
self.update()
|
||||||
|
|
||||||
def update(self):
|
def update(self) -> None:
|
||||||
from ..utilities.database import connect
|
from ..utilities.database import connect
|
||||||
from ..utilities.json import dumps
|
from ..utilities.json import dumps
|
||||||
query = f"UPDATE moderation_{self.guild_id} SET timestamp = ?, moderation_type = ?, target_type = ?, moderator_id = ?, role_id = ?, duration = ?, end_timestamp = ?, reason = ?, resolved = ?, resolved_by = ?, resolve_reason = ?, expired = ?, changes = ?, metadata = ? WHERE moderation_id = ?;"
|
query = f"UPDATE moderation_{self.guild_id} SET timestamp = ?, moderation_type = ?, target_type = ?, moderator_id = ?, role_id = ?, duration = ?, end_timestamp = ?, reason = ?, resolved = ?, resolved_by = ?, resolve_reason = ?, expired = ?, changes = ?, metadata = ? WHERE moderation_id = ?;"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# pylint: disable=cyclic-import
|
# pylint: disable=cyclic-import
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from typing import Optional, Union
|
from typing import Optional, Tuple, Union
|
||||||
|
|
||||||
from dateutil.relativedelta import relativedelta as rd
|
from dateutil.relativedelta import relativedelta as rd
|
||||||
from discord import File, Guild, Interaction, Member, SelectOption, TextChannel, User
|
from discord import File, Guild, Interaction, Member, SelectOption, TextChannel, User
|
||||||
|
@ -13,7 +13,7 @@ from ..utilities.config import config
|
||||||
|
|
||||||
def check_permissions(
|
def check_permissions(
|
||||||
user: User,
|
user: User,
|
||||||
permissions: list,
|
permissions: Tuple[str],
|
||||||
ctx: Union[commands.Context, Interaction] | None = None,
|
ctx: Union[commands.Context, Interaction] | None = None,
|
||||||
guild: Guild | None = None,
|
guild: Guild | None = None,
|
||||||
) -> Union[bool, str]:
|
) -> Union[bool, str]:
|
||||||
|
@ -40,7 +40,7 @@ def check_permissions(
|
||||||
|
|
||||||
|
|
||||||
async def check_moddable(
|
async def check_moddable(
|
||||||
target: Union[User, Member, TextChannel], interaction: Interaction, permissions: list
|
target: Union[User, Member, TextChannel], interaction: Interaction, permissions: Tuple[str]
|
||||||
) -> bool:
|
) -> bool:
|
||||||
"""Checks if a moderator can moderate a target."""
|
"""Checks if a moderator can moderate a target."""
|
||||||
is_channel = isinstance(target, TextChannel)
|
is_channel = isinstance(target, TextChannel)
|
||||||
|
|
Loading…
Reference in a new issue