Skip to content

Commit

Permalink
Add formatting of the timedelta to the uptime command (#36)
Browse files Browse the repository at this point in the history
Co-authored-by: nova <[email protected]>
  • Loading branch information
Regaus and novanai authored Feb 1, 2024
1 parent bec3143 commit f1ce6f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.vscode/
.idea/

# Byte-compiled / optimized / DLL files
__pycache__/
Expand Down
14 changes: 8 additions & 6 deletions src/extensions/uptime.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import time as t

start_time = t.time()
from datetime import datetime

import arc
import hikari
import datetime as dt

start_time = datetime.now()

plugin = arc.GatewayPlugin("Blockbot Uptime")


@plugin.include
@arc.slash_command("uptime", "Show formatted uptime of Blockbot")
async def uptime(ctx):
await ctx.respond(f"Uptime: **{dt.timedelta(seconds=(t.time()-start_time) // 1)!s}**")
up_time = datetime.now() - start_time
h, ms = divmod(up_time.seconds, 3600)
m, s = divmod(ms, 60)
await ctx.respond(f"Uptime: **{up_time.days} days, {h} hours, {m} minutes, and {s} seconds**.")

@arc.loader
def loader(client):
Expand Down

0 comments on commit f1ce6f9

Please sign in to comment.