From a76f648240e30bd7cfd4b661682f3b597039f0be Mon Sep 17 00:00:00 2001 From: Fae Date: Fri, 17 May 2024 06:50:19 -0700 Subject: [PATCH] Add uptime command (#2407) Co-authored-by: Snow <135516526+BabyBoySnow@users.noreply.github.com> --- musicbot/bot.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/musicbot/bot.py b/musicbot/bot.py index 2d9dea408..0ccd5691c 100644 --- a/musicbot/bot.py +++ b/musicbot/bot.py @@ -144,6 +144,7 @@ def __init__( self.use_certifi: bool = use_certifi self.exit_signal: ExitSignals = None + self._init_time: float = time.time() self._os_signal: Optional[signal.Signals] = None self._ping_peer_addr: str = "" self._ping_use_http: bool = False @@ -6925,6 +6926,18 @@ async def cmd_checkupdates(self, channel: MessageableChannel) -> CommandResponse delete_after=60, ) + async def cmd_uptime(self) -> CommandResponse: + """ + Usage: + {command_prefix}uptime + + Displays the MusicBot uptime, since last start/restart. + """ + uptime = time.time() - self._init_time + delta = format_song_duration(uptime) + return Response( + f"MusicBot has been up for `{delta}`", + @owner_only async def cmd_botlatency(self) -> CommandResponse: """