diff --git a/src/common/humanizer.py b/src/common/humanizer.py index 0a1cf31..e92ba18 100644 --- a/src/common/humanizer.py +++ b/src/common/humanizer.py @@ -42,30 +42,6 @@ def number(n: float) -> str: ) -def seconds_to_long_text(secs: int) -> str: - if secs == 0: - return "0 seconds" - - time_units = [ - ("day", secs // 86400), - ("hour", (secs // 3600) % 24), - ("minute", (secs // 60) % 60), - ("second", secs % 60), - ] - - formatted_units = [ - f"{value} {unit}s" if value != 1 else f"{value} {unit}" - for unit, value in time_units - if value > 0 - ] - - return ( - " ".join(formatted_units[:-1]) + " and " + formatted_units[-1] - if len(formatted_units) > 1 - else formatted_units[0] - ) - - def seconds_to_text(secs: int) -> str: if secs == 0: return "0 seconds" diff --git a/src/models/weather.py b/src/models/weather.py index 0f0ad79..c403600 100644 --- a/src/models/weather.py +++ b/src/models/weather.py @@ -83,8 +83,8 @@ class LocationData(BaseModel): id: int | None = None type: int | None = None country: str - sunrise: int - sunset: int + sunrise: datetime + sunset: datetime class WeatherResponse(BaseModel): diff --git a/src/ui/embeds/information/botinfo.py b/src/ui/embeds/information/botinfo.py index af53f7c..8cfa1b2 100644 --- a/src/ui/embeds/information/botinfo.py +++ b/src/ui/embeds/information/botinfo.py @@ -5,6 +5,8 @@ from typing import TYPE_CHECKING +from discord.utils import format_dt + from ui.embeds.generic import ContextEmbed if TYPE_CHECKING: @@ -34,6 +36,7 @@ def __init__(self, ctx: Context, *args: Any, **kwargs: Any) -> None: self.add_field(name="Commands", value=len(ctx.bot.all_commands)) self.add_field(name="Cogs", value=len(ctx.bot.cogs)) self.add_field( - name="Created:", - value=f"", + name="Shard Info", + value=f"`ID {ctx.guild.shard_id}`: `{ctx.bot.shard_count} total`", ) + self.add_field(name="Created", value=format_dt(ctx.bot.user.created_at)) diff --git a/src/ui/embeds/information/severinfo.py b/src/ui/embeds/information/severinfo.py index 9854183..51680f4 100644 --- a/src/ui/embeds/information/severinfo.py +++ b/src/ui/embeds/information/severinfo.py @@ -5,7 +5,8 @@ from typing import TYPE_CHECKING -import discord +from discord.channel import TextChannel +from discord.utils import format_dt from ui.embeds.generic import ContextEmbed @@ -40,7 +41,7 @@ def __init__(self, ctx: Context, *args: Any, **kwargs: Any) -> None: value=len( list( filter( - lambda x: isinstance(x, discord.channel.TextChannel), + lambda x: isinstance(x, TextChannel), ctx.guild.channels, ), ), @@ -48,7 +49,4 @@ def __init__(self, ctx: Context, *args: Any, **kwargs: Any) -> None: ) self.add_field(name="Roles", value=len(ctx.guild.roles)) self.add_field(name="Emotes", value=len(ctx.guild.emojis)) - self.add_field( - name="Created On:", - value=f"", - ) + self.add_field(name="Created", value=format_dt(ctx.guild.created_at)) diff --git a/src/ui/embeds/osu/beatmap.py b/src/ui/embeds/osu/beatmap.py index d946296..1006b74 100644 --- a/src/ui/embeds/osu/beatmap.py +++ b/src/ui/embeds/osu/beatmap.py @@ -10,6 +10,7 @@ from aiosu.models import Beatmap from aiosu.models import Beatmapset from discord.utils import escape_markdown +from discord.utils import format_dt from ui.embeds.generic import ContextEmbed from ui.icons.beatmap import BeatmapDifficultyIcon @@ -68,7 +69,7 @@ def __init__( content = cleandoc( f"""**▸** {beatmap.difficulty_rating:.2f}⭐ **▸Max Combo:** x{beatmap.max_combo}\n**▸AR:** {beatmap.ar} **▸OD:** {beatmap.accuracy} **▸CS:** {beatmap.cs} **▸HP:** {beatmap.drain} {beatmap.status.name} | ❤️ {beatmapset.favourite_count} | ▶️ {beatmapset.play_count} - {footer_date_prefix} + {footer_date_prefix}{format_dt(date, style="R")} """, ) diff --git a/src/ui/embeds/osu/profile.py b/src/ui/embeds/osu/profile.py index 32a1abe..994e32c 100644 --- a/src/ui/embeds/osu/profile.py +++ b/src/ui/embeds/osu/profile.py @@ -10,6 +10,7 @@ from aiosu.models import User from discord.ext import commands from discord.utils import escape_markdown +from discord.utils import format_dt from common import humanizer from ui.embeds.generic import ContextEmbed @@ -30,7 +31,7 @@ def __init__( ) -> None: peak_str = "" if user.rank_highest: - peak_str = f"(peaked #{user.rank_highest.rank} )\n" + peak_str = f"(peaked #{user.rank_highest.rank} {format_dt(user.rank_highest.updated_at)}\n" content = ( f"{user.statistics.pp}pp (#{user.statistics.global_rank} | {user.country.flag_emoji}#{user.statistics.country_rank})\n" @@ -73,7 +74,7 @@ def __init__( ) -> None: peak_str = "" if user.rank_highest: - peak_str = f"peak: **#{user.rank_highest.rank}** \n" + peak_str = f"peak: **#{user.rank_highest.rank}** {format_dt(user.rank_highest.updated_at)}\n" rank_content = ( f"rank: **#{user.statistics.global_rank}**\n" @@ -94,7 +95,7 @@ def __init__( max combo: **{user.statistics.maximum_combo}** pp/hour: **{user.statistics.pp_per_playtime:.2f}** avg. rank gain: **{user.rank_history.average_gain:.2f}** - joined: + joined: {format_dt(user.join_date)} """, ) self.add_field(name="", value=average_content) diff --git a/src/ui/embeds/osu/score.py b/src/ui/embeds/osu/score.py index ab56ed5..9e9f477 100644 --- a/src/ui/embeds/osu/score.py +++ b/src/ui/embeds/osu/score.py @@ -12,6 +12,7 @@ from aiosu.models import Score from aiosu.utils.performance import get_calculator from discord.utils import escape_markdown +from discord.utils import format_dt from ui.embeds.generic import ContextEmbed from ui.icons.score import ScoreRankIcon @@ -144,7 +145,7 @@ def _score_to_embed_strs( f"""**{pp:.2f}pp**{weight}, accuracy: **{score.accuracy*100:.2f}%**, combo: **{score.max_combo}x/{max_combo}x** {fc_text}score: **{score.score}** [**{statistics.count_300}**/**{statistics.count_100}**/**{statistics.count_50}**/**{statistics.count_miss}**] bpm: {bpm_text} | mods: {mods_text} | {ScoreRankIcon[score.rank]}{fail_text}{mods_settings_text} - + {format_dt(score.created_at, style="R")} {score_text}{user_text}[map]({beatmap.url}) """, ) diff --git a/src/ui/embeds/weather/info.py b/src/ui/embeds/weather/info.py index 56dd5cd..9c2a211 100644 --- a/src/ui/embeds/weather/info.py +++ b/src/ui/embeds/weather/info.py @@ -6,6 +6,7 @@ from inspect import cleandoc from typing import TYPE_CHECKING +from discord.utils import format_dt from emojiflags import lookup from models.weather import Units @@ -22,8 +23,8 @@ def __init__(self, ctx: commands.Context, response: WeatherResponse, units: Unit description = cleandoc( f""" {latest_forecast.main.capitalize()} ({latest_forecast.description}) - Sunrise - Sunset + Sunrise {format_dt(response.location_data.sunrise, style="t")} + Sunset {format_dt(response.location_data.sunset, style="t")} """, ) flag = lookup.lookup(response.location_data.country)