fix(aurora): removed humanize from factory.py

This commit is contained in:
Seaswimmer 2024-03-08 15:01:24 -05:00
parent 99dddf2fa7
commit 92e8ee2dc2
Signed by untrusted user: cswimr
GPG key ID: B8953EC01E5C4063

View file

@ -2,16 +2,12 @@
from datetime import datetime, timedelta from datetime import datetime, timedelta
from typing import Union from typing import Union
import humanize 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 import commands
from redbot.core.utils.chat_formatting import bold, box, error, warning from redbot.core.utils.chat_formatting import bold, box, error, humanize_timedelta, warning
from aurora.utilities.config import config from aurora.utilities.config import config
from aurora.utilities.utils import (fetch_channel_dict, fetch_user_dict, from aurora.utilities.utils import fetch_channel_dict, fetch_user_dict, get_bool_emoji, get_next_case_number, get_pagesize_str
get_bool_emoji, get_next_case_number,
get_pagesize_str)
async def message_factory( async def message_factory(
@ -51,7 +47,7 @@ async def message_factory(
guild_name = guild.name guild_name = guild.name
if moderation_type in ["tempbanned", "muted"] and duration: if moderation_type in ["tempbanned", "muted"] and duration:
embed_duration = f" for {humanize.precisedelta(duration)}" embed_duration = f" for {humanize_timedelta(timedelta=duration)}"
else: else:
embed_duration = "" embed_duration = ""
@ -141,9 +137,9 @@ async def log_factory(
} }
) )
duration_embed = ( duration_embed = (
f"{humanize.precisedelta(td)} | <t:{case_dict['end_timestamp']}:R>" f"{humanize_timedelta(timedelta=td)} | <t:{case_dict['end_timestamp']}:R>"
if case_dict["expired"] == "0" if case_dict["expired"] == "0"
else str(humanize.precisedelta(td)) else str(humanize_timedelta(timedelta=td))
) )
embed.description = ( embed.description = (
embed.description embed.description
@ -204,7 +200,7 @@ async def log_factory(
) )
embed.description = ( embed.description = (
embed.description embed.description
+ f"\n**Duration:** {humanize.precisedelta(td)} | <t:{case_dict['end_timestamp']}:R>" + f"\n**Duration:** {humanize_timedelta(timedelta=td)} | <t:{case_dict['end_timestamp']}:R>"
) )
embed.add_field(name="Reason", value=box(case_dict["reason"]), inline=False) embed.add_field(name="Reason", value=box(case_dict["reason"]), inline=False)
@ -255,9 +251,9 @@ async def case_factory(interaction: Interaction, case_dict: dict) -> Embed:
} }
) )
duration_embed = ( duration_embed = (
f"{humanize.precisedelta(td)} | <t:{case_dict['end_timestamp']}:R>" f"{humanize_timedelta(timedelta=td)} | <t:{case_dict['end_timestamp']}:R>"
if bool(case_dict["expired"]) is False if bool(case_dict["expired"]) is False
else str(humanize.precisedelta(td)) else str(humanize_timedelta(timedelta=td))
) )
embed.description += f"\n**Duration:** {duration_embed}\n**Expired:** {bool(case_dict['expired'])}" embed.description += f"\n**Duration:** {duration_embed}\n**Expired:** {bool(case_dict['expired'])}"
@ -379,7 +375,7 @@ async def evidenceformat_factory(interaction: Interaction, case_dict: dict) -> s
if case_dict["duration"] != "NULL": if case_dict["duration"] != "NULL":
hours, minutes, seconds = map(int, case_dict["duration"].split(":")) hours, minutes, seconds = map(int, case_dict["duration"].split(":"))
td = timedelta(hours=hours, minutes=minutes, seconds=seconds) td = timedelta(hours=hours, minutes=minutes, seconds=seconds)
content += f"\nDuration: {humanize.precisedelta(td)}" content += f"\nDuration: {humanize_timedelta(timedelta=td)}"
content += f"\nReason: {case_dict['reason']}" content += f"\nReason: {case_dict['reason']}"