forked from blizzthewolf/SeaCogs
misc(aurora): adding typechecks to return values in utils
This commit is contained in:
parent
afb961799d
commit
db7c06b044
1 changed files with 9 additions and 9 deletions
|
@ -17,7 +17,7 @@ def check_permissions(
|
|||
permissions: list,
|
||||
ctx: Union[commands.Context, Interaction] = None,
|
||||
guild: Guild = None,
|
||||
):
|
||||
) -> Union[bool, str]:
|
||||
"""Checks if a user has a specific permission (or a list of permissions) in a channel."""
|
||||
if ctx:
|
||||
member = ctx.guild.get_member(user.id)
|
||||
|
@ -42,7 +42,7 @@ def check_permissions(
|
|||
|
||||
async def check_moddable(
|
||||
target: Union[User, Member], interaction: Interaction, permissions: list
|
||||
):
|
||||
) -> bool:
|
||||
"""Checks if a moderator can moderate a target."""
|
||||
if check_permissions(interaction.client.user, permissions, guild=interaction.guild):
|
||||
await interaction.response.send_message(
|
||||
|
@ -124,8 +124,8 @@ async def get_next_case_number(guild_id: str, cursor=None) -> int:
|
|||
return (result[0] + 1) if result else 1
|
||||
|
||||
|
||||
def generate_dict(result):
|
||||
case: dict = {
|
||||
def generate_dict(result) -> dict:
|
||||
case = {
|
||||
"moderation_id": result[0],
|
||||
"timestamp": result[1],
|
||||
"moderation_type": result[2],
|
||||
|
@ -146,7 +146,7 @@ def generate_dict(result):
|
|||
return case
|
||||
|
||||
|
||||
async def fetch_user_dict(interaction: Interaction, user_id: str):
|
||||
async def fetch_user_dict(interaction: Interaction, user_id: str) -> dict:
|
||||
"""This function returns a dictionary containing either user information or a standard deleted user template."""
|
||||
if user_id == "?":
|
||||
user_dict = {"id": "?", "name": "Unknown User", "discriminator": "0"}
|
||||
|
@ -173,7 +173,7 @@ async def fetch_user_dict(interaction: Interaction, user_id: str):
|
|||
return user_dict
|
||||
|
||||
|
||||
async def fetch_channel_dict(interaction: Interaction, channel_id: str):
|
||||
async def fetch_channel_dict(interaction: Interaction, channel_id: str) -> dict:
|
||||
"""This function returns a dictionary containing either channel information or a standard deleted channel template."""
|
||||
try:
|
||||
channel = interaction.guild.get_channel(channel_id)
|
||||
|
@ -192,7 +192,7 @@ async def fetch_channel_dict(interaction: Interaction, channel_id: str):
|
|||
return channel_dict
|
||||
|
||||
|
||||
async def fetch_role_dict(interaction: Interaction, role_id: str):
|
||||
async def fetch_role_dict(interaction: Interaction, role_id: str) -> dict:
|
||||
"""This function returns a dictionary containing either role information or a standard deleted role template."""
|
||||
role = interaction.guild.get_role(role_id)
|
||||
if not role:
|
||||
|
@ -203,7 +203,7 @@ async def fetch_role_dict(interaction: Interaction, role_id: str):
|
|||
return role_dict
|
||||
|
||||
|
||||
async def log(interaction: Interaction, moderation_id: int, resolved: bool = False):
|
||||
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."""
|
||||
from .database import fetch_case
|
||||
from .factory import log_factory
|
||||
|
@ -223,7 +223,7 @@ async def log(interaction: Interaction, moderation_id: int, resolved: bool = Fal
|
|||
return
|
||||
|
||||
|
||||
async def send_evidenceformat(interaction: Interaction, case_dict: dict):
|
||||
async def send_evidenceformat(interaction: Interaction, case_dict: dict) -> 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."""
|
||||
from .factory import evidenceformat_factory
|
||||
|
||||
|
|
Loading…
Reference in a new issue