Skip to content

Commit

Permalink
about: format uptime, makes it look better (Ballsdex-Team#504)
Browse files Browse the repository at this point in the history
* format uptime with datetime

* remove failing check completely, as its not needed

* appease pyright

* readd check

* Update ballsdex/packages/info/cog.py

---------

Co-authored-by: Auguste Charpentier <[email protected]>
  • Loading branch information
imtherealF1 and laggron42 authored Feb 21, 2025
1 parent beaee0e commit c4112a9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions ballsdex/packages/info/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,11 @@ async def about(self, interaction: discord.Interaction):
players_count = await row_count_estimate("player")
balls_instances_count = await row_count_estimate("ballinstance")

days, hours, minutes, seconds = 0, 0, 0, 0
if self.bot.startup_time is not None:
uptime_duration = datetime.now() - self.bot.startup_time
days, remainder = divmod(int(uptime_duration.total_seconds()), 86400)
hours, remainder = divmod(remainder, 3600)
minutes, seconds = divmod(remainder, 60)
formatted_uptime = str(uptime_duration).split(".")[0]
else:
formatted_uptime = "N/A"

assert self.bot.user
assert self.bot.application
Expand Down Expand Up @@ -125,8 +124,7 @@ async def about(self, interaction: discord.Interaction):
f"{' '.join(str(x) for x in balls)}\n"
f"{settings.about_description}\n"
f"*Running version **[{ballsdex_version}]({settings.github_link}/releases)***\n"
f"The bot has been online for **{days} days, {hours} hours, {minutes} minutes, "
f"and {seconds} seconds.**\n\n"
f"The bot has been online for **{formatted_uptime}**.\n\n"
f"**{balls_count:,}** {settings.plural_collectible_name} to collect\n"
f"**{players_count:,}** players that caught "
f"**{balls_instances_count:,}** {settings.plural_collectible_name}\n"
Expand Down

0 comments on commit c4112a9

Please sign in to comment.