[3.4] Use discord native timestamp in [p]uptime (#5323) (#5332)

* support for discord's timestamp on uptime

* woops not supposed to remove `_`.

* ups

* ups x2

* Apply suggested change.

* hehe
(cherry picked from commit d69326b1fe)

Co-authored-by: MAX <63972751+maxbooiii@users.noreply.github.com>

Co-authored-by: MAX <63972751+maxbooiii@users.noreply.github.com>
This commit is contained in:
Red-GitHubBot
2021-09-23 16:29:01 +02:00
committed by GitHub
parent 39169703a7
commit 3865449d3b

View File

@@ -558,12 +558,12 @@ class Core(commands.commands._RuleDropper, commands.Cog, CoreLogic):
@commands.command() @commands.command()
async def uptime(self, ctx: commands.Context): async def uptime(self, ctx: commands.Context):
"""Shows [botname]'s uptime.""" """Shows [botname]'s uptime."""
since = ctx.bot.uptime.strftime("%Y-%m-%d %H:%M:%S")
delta = datetime.datetime.utcnow() - self.bot.uptime delta = datetime.datetime.utcnow() - self.bot.uptime
uptime_str = humanize_timedelta(timedelta=delta) or _("Less than one second") uptime = self.bot.uptime.replace(tzinfo=datetime.timezone.utc)
uptime_str = humanize_timedelta(timedelta=delta) or _("Less than one second.")
await ctx.send( await ctx.send(
_("Been up for: **{time_quantity}** (since {timestamp} UTC)").format( _("Been up for: **{time_quantity}** (since {timestamp})").format(
time_quantity=uptime_str, timestamp=since time_quantity=uptime_str, timestamp=f"<t:{int(uptime.timestamp())}:f>"
) )
) )