WIP: Refactor Aurora (3.0.0) #29

Draft
cswimr wants to merge 347 commits from aurora-pydantic into main
Showing only changes of commit ec082b58ad - Show all commits

View file

@ -5,7 +5,7 @@ from typing import Union
from discord import Color, Embed, Guild, Interaction, Member, Message, Role, User from discord import Color, Embed, Guild, Interaction, Member, Message, Role, User
from redbot.core import commands from redbot.core import commands
from redbot.core.bot import Red from redbot.core.bot import Red
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, inline, warning
from ..models.moderation import Moderation from ..models.moderation import Moderation
from ..models.partials import PartialUser from ..models.partials import PartialUser
@ -261,25 +261,20 @@ async def changes_factory(interaction: Interaction, moderation: Moderation) -> E
user: PartialUser = memory_dict[str(change.user_id)] user: PartialUser = memory_dict[str(change.user_id)]
timestamp = f"<t:{change.unix_timestamp}> | <t:{change.unix_timestamp}:R>" timestamp = f"<t:{change.unix_timestamp}> | <t:{change.unix_timestamp}:R>"
end_timestamp = f"<t:{change.end_timestamp}> | <t:{change.end_timestamp}:R>" if change.end_timestamp else None
if change.type == "ORIGINAL": change_str = [
embed.add_field( f"{bold("User:")} {inline(user.name)} ({user.id})",
name="Original", f"{bold("Reason:")} {change.reason}" if change.reason else "",
value=f"**User:** `{user.name}` ({user.id})\n**Reason:** {change.reason}\n**Timestamp:** {timestamp}", f"{bold('Duration:')} {humanize_timedelta(timedelta=change.duration)}" if change.duration else "",
inline=False, f"{bold('End Timestamp:')} {end_timestamp}" if end_timestamp else "",
) f"{bold("Timestamp:")} {timestamp}",
]
change_str.remove("")
elif change.type == "EDIT":
embed.add_field( embed.add_field(
name="Edit", name=change.type.title(),
value=f"**User:** `{user.name}` ({user.id})\n**Reason:** {change.reason}\n**Timestamp:** {timestamp}", value=change_str.join("\n"),
inline=False,
)
elif change.type == "RESOLVE":
embed.add_field(
name="Resolve",
value=f"**User:** `{user.name}` ({user.id})\n**Reason:** {change.reason}\n**Timestamp:** {timestamp}",
inline=False, inline=False,
) )