fix(aurora): make changes_factory support changes properly
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Successful in 29s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 40s

This commit is contained in:
Seaswimmer 2024-08-19 17:40:52 -04:00
parent b0509d748c
commit ec082b58ad
Signed by: cswimr
GPG key ID: 3813315477F26F82

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,27 +261,22 @@ 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=change.type.title(),
name="Edit", value=change_str.join("\n"),
value=f"**User:** `{user.name}` ({user.id})\n**Reason:** {change.reason}\n**Timestamp:** {timestamp}", inline=False,
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,
)
else: else:
embed.description = "*No changes have been made to this case.* 🙁" embed.description = "*No changes have been made to this case.* 🙁"