Skip to content

Commit

Permalink
Updated whowas command in moderation cog to use humanisze naturaltime…
Browse files Browse the repository at this point in the history
… to display how long since player died
  • Loading branch information
TanyaPegasus authored and connorhsm committed Sep 6, 2023
1 parent 4f5eec9 commit d165d8b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions dictator/cogs/moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

from datetime import datetime, timezone
import re
import humanize


class Admin(commands.Cog):
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit d165d8b

Please sign in to comment.