feat(aurora): finished the factory migrations
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Successful in 23s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 32s

This commit is contained in:
Seaswimmer 2024-05-04 21:24:37 -04:00
parent e89db3de5a
commit fc15b434c7
Signed by: cswimr
GPG key ID: 5D671B5D03D65A7F

View file

@ -2,13 +2,16 @@
from datetime import datetime, timedelta
from typing import Union
from discord import Color, Embed, Guild, Interaction, InteractionMessage, Member, Role, User
from discord import (Color, Embed, Guild, Interaction, InteractionMessage,
Member, Role, User)
from redbot.core import commands
from redbot.core.utils.chat_formatting import bold, box, error, humanize_timedelta, warning
from redbot.core.utils.chat_formatting import (bold, box, error,
humanize_timedelta, warning)
from aurora.models import Moderation, PartialUser
from aurora.utilities.config import config
from aurora.utilities.utils import fetch_channel_dict, fetch_user_dict, get_bool_emoji, get_next_case_number, get_pagesize_str
from aurora.utilities.utils import (get_bool_emoji, get_next_case_number,
get_pagesize_str)
async def message_factory(
@ -258,40 +261,22 @@ async def changes_factory(interaction: Interaction, moderation: Moderation) -> E
return embed
async def evidenceformat_factory(interaction: Interaction, case_dict: dict) -> str:
async def evidenceformat_factory(interaction: Interaction, moderation: Moderation) -> str:
"""This function creates a codeblock in evidence format from set parameters.
Args:
interaction (Interaction): The interaction object.
case_dict (dict): The case dictionary.
interaction (discord.Interaction): The interaction object.
moderation (aurora.models.Moderation): The moderation object.
"""
if case_dict["target_type"] == "USER":
target_user = await fetch_user_dict(interaction.client, case_dict["target_id"])
target_name = (
target_user["name"]
if target_user["discriminator"] == "0"
else f"{target_user['name']}#{target_user['discriminator']}"
)
target = await moderation.get_target()
moderator = await moderation.get_moderator()
elif case_dict["target_type"] == "CHANNEL":
target_user = await fetch_channel_dict(interaction.guild, case_dict["target_id"])
target_name = target_user["name"]
content = f"Case: {moderation.id:,} ({str.title(moderation.type)})\nTarget: {target.name} ({target.id})\nModerator: {moderator.name} ({moderator.id})"
moderator_user = await fetch_user_dict(interaction.client, case_dict["moderator_id"])
moderator_name = (
moderator_user["name"]
if moderator_user["discriminator"] == "0"
else f"{moderator_user['name']}#{moderator_user['discriminator']}"
)
if moderation.duration is not None:
content += f"\nDuration: {humanize_timedelta(timedelta=moderation.duration)}"
content = f"Case: {case_dict['moderation_id']:,} ({str.title(case_dict['moderation_type'])})\nTarget: {target_name} ({target_user['id']})\nModerator: {moderator_name} ({moderator_user['id']})"
if case_dict["duration"] != "NULL":
hours, minutes, seconds = map(int, case_dict["duration"].split(":"))
td = timedelta(hours=hours, minutes=minutes, seconds=seconds)
content += f"\nDuration: {humanize_timedelta(timedelta=td)}"
content += f"\nReason: {case_dict['reason']}"
content += f"\nReason: {moderation.reason}"
return box(content, "prolog")