From d165d8b39d49004d76b654627a506f09ef5accc1 Mon Sep 17 00:00:00 2001 From: TanyaPegasus Date: Sun, 3 Sep 2023 22:07:43 +1000 Subject: [PATCH] Updated whowas command in moderation cog to use humanisze naturaltime to display how long since player died --- dictator/cogs/moderation.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dictator/cogs/moderation.py b/dictator/cogs/moderation.py index be86abe..ea703cc 100644 --- a/dictator/cogs/moderation.py +++ b/dictator/cogs/moderation.py @@ -7,6 +7,7 @@ from datetime import datetime, timezone import re +import humanize class Admin(commands.Cog): @@ -313,13 +314,10 @@ async def whowas( # Format death time as timezone aware death_time = datetime.strptime(u[1], "%Y-%m-%d %H:%M:%S") death_time = death_time.replace(tzinfo=timezone.utc) - diff = discord.utils.utcnow() - death_time - diff_split = str(diff).split(":") - # diff_split[0] appears as '3 days, 4' where 3 = amount of days and 4 = amount of hours. I aplogise if you have to debug this. - diff_formatted = f"{diff_split[0]} hours, {diff_split[1]} minutes ago" + difference = humanize.naturaltime(discord.utils.utcnow() - death_time) embed.add_field(name="Username:", value=f"{u[2]}", inline=True) embed.add_field(name="Member:", value=f"{found_user}", inline=True) - embed.add_field(name="Died:", value=f"{diff_formatted}", inline=True) + embed.add_field(name="Died:", value=f"{difference}", inline=True) if len(users) < history: embed.add_field(name="\u200b", value="End of results")