mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 11:18:54 -05:00
[V3 Core] add uptime command (#1273)
This commit is contained in:
parent
9feb7ad876
commit
1d1f2c9f12
@ -87,6 +87,37 @@ class Core:
|
|||||||
except discord.HTTPException:
|
except discord.HTTPException:
|
||||||
await ctx.send("I need the `Embed links` permission to send this")
|
await ctx.send("I need the `Embed links` permission to send this")
|
||||||
|
|
||||||
|
@commands.command()
|
||||||
|
async def uptime(self, ctx: RedContext):
|
||||||
|
"""Shows Red's uptime"""
|
||||||
|
since = ctx.bot.uptime.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
passed = self.get_bot_uptime()
|
||||||
|
await ctx.send(
|
||||||
|
"Been up for: **{}** (since {} UTC)".format(
|
||||||
|
passed, since
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def get_bot_uptime(self, *, brief=False):
|
||||||
|
# Courtesy of Danny
|
||||||
|
now = datetime.datetime.utcnow()
|
||||||
|
delta = now - self.bot.uptime
|
||||||
|
hours, remainder = divmod(int(delta.total_seconds()), 3600)
|
||||||
|
minutes, seconds = divmod(remainder, 60)
|
||||||
|
days, hours = divmod(hours, 24)
|
||||||
|
|
||||||
|
if not brief:
|
||||||
|
if days:
|
||||||
|
fmt = '{d} days, {h} hours, {m} minutes, and {s} seconds'
|
||||||
|
else:
|
||||||
|
fmt = '{h} hours, {m} minutes, and {s} seconds'
|
||||||
|
else:
|
||||||
|
fmt = '{h}h {m}m {s}s'
|
||||||
|
if days:
|
||||||
|
fmt = '{d}d ' + fmt
|
||||||
|
|
||||||
|
return fmt.format(d=days, h=hours, m=minutes, s=seconds)
|
||||||
|
|
||||||
@commands.command()
|
@commands.command()
|
||||||
@checks.is_owner()
|
@checks.is_owner()
|
||||||
async def traceback(self, ctx, public: bool=False):
|
async def traceback(self, ctx, public: bool=False):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user