feat: add !uptime command
Track bot start time via monotonic clock, display as compact duration (e.g. "up 3d 2h 15m 42s"). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -56,6 +56,26 @@ async def cmd_version(bot, message):
|
||||
await bot.reply(message, f"derp {__version__}")
|
||||
|
||||
|
||||
@command("uptime", help="Show how long the bot has been running")
|
||||
async def cmd_uptime(bot, message):
|
||||
"""Report bot uptime."""
|
||||
import time
|
||||
|
||||
elapsed = int(time.monotonic() - bot._started)
|
||||
days, rem = divmod(elapsed, 86400)
|
||||
hours, rem = divmod(rem, 3600)
|
||||
minutes, secs = divmod(rem, 60)
|
||||
parts = []
|
||||
if days:
|
||||
parts.append(f"{days}d")
|
||||
if hours:
|
||||
parts.append(f"{hours}h")
|
||||
if minutes:
|
||||
parts.append(f"{minutes}m")
|
||||
parts.append(f"{secs}s")
|
||||
await bot.reply(message, f"up {' '.join(parts)}")
|
||||
|
||||
|
||||
@command("load", help="Hot-load a plugin: !load <name>")
|
||||
async def cmd_load(bot, message):
|
||||
"""Load a new plugin from the plugins directory."""
|
||||
|
||||
Reference in New Issue
Block a user