mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
fix uptime for uptime of less than a second (#3009)
* fix uptime for uptime of less than a second * changelog * More conclusive fix
This commit is contained in:
parent
c288185a16
commit
e38c08ab12
1
changelog.d/3008.bugfix.rst
Normal file
1
changelog.d/3008.bugfix.rst
Normal file
@ -0,0 +1 @@
|
||||
Uptime command works with uptimes of under a second
|
||||
@ -327,9 +327,10 @@ class Core(commands.Cog, CoreLogic):
|
||||
"""Shows Red's uptime"""
|
||||
since = ctx.bot.uptime.strftime("%Y-%m-%d %H:%M:%S")
|
||||
delta = datetime.datetime.utcnow() - self.bot.uptime
|
||||
uptime_str = humanize_timedelta(timedelta=delta) or _("Less than one second")
|
||||
await ctx.send(
|
||||
_("Been up for: **{}** (since {} UTC)").format(
|
||||
humanize_timedelta(timedelta=delta), since
|
||||
_("Been up for: **{time_quantity}** (since {timestamp} UTC)").format(
|
||||
time_quantity=uptime_str, timestamp=since
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@ -3,11 +3,19 @@ from . import commands
|
||||
|
||||
|
||||
def init_global_checks(bot):
|
||||
@bot.check_once
|
||||
def actually_up(ctx):
|
||||
"""
|
||||
Uptime is set during the initial startup process.
|
||||
If this hasn't been set, we should assume the bot isn't ready yet.
|
||||
"""
|
||||
return ctx.bot.uptime is not None
|
||||
|
||||
@bot.check_once
|
||||
async def whiteblacklist_checks(ctx):
|
||||
return await ctx.bot.allowed_by_whitelist_blacklist(ctx.author)
|
||||
|
||||
@bot.check_once
|
||||
async def bots(ctx):
|
||||
def bots(ctx):
|
||||
"""Check the user is not another bot."""
|
||||
return not ctx.author.bot
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user