1+ from datetime import UTC , datetime
2+
13import psutil
24from discord .ext import commands
35
46from tux .bot import Tux
57from tux .ui .embeds import EmbedCreator
8+ from tux .utils .env import get_current_env
69from tux .utils .functions import generate_usage
710
811
@@ -13,6 +16,7 @@ def __init__(self, bot: Tux) -> None:
1316
1417 @commands .hybrid_command (
1518 name = "ping" ,
19+ aliases = ["status" ],
1620 )
1721 async def ping (self , ctx : commands .Context [Tux ]) -> None :
1822 """
@@ -27,6 +31,27 @@ async def ping(self, ctx: commands.Context[Tux]) -> None:
2731 # Get the latency of the bot in milliseconds
2832 discord_ping = round (self .bot .latency * 1000 )
2933
34+ environment = get_current_env ()
35+
36+ # Handles Time (turning POSIX time datetime)
37+ bot_start_time = datetime .fromtimestamp (self .bot .uptime , UTC )
38+ current_time = datetime .now (UTC ) # Get current time
39+ uptime_delta = current_time - bot_start_time
40+
41+ # Convert it into Human comprehensible times
42+ days = uptime_delta .days
43+ hours , remainder = divmod (uptime_delta .seconds , 3600 )
44+ minutes , seconds = divmod (remainder , 60 )
45+
46+ # Format it for the command
47+ bot_uptime_parts = [
48+ f"{ days } d" if days else "" ,
49+ f"{ hours } h" if hours else "" ,
50+ f"{ minutes } m" if minutes else "" ,
51+ f"{ seconds } s" ,
52+ ]
53+ bot_uptime_readable = " " .join (part for part in bot_uptime_parts if part ).strip ()
54+
3055 # Get the CPU usage and RAM usage of the bot
3156 cpu_usage = psutil .Process ().cpu_percent ()
3257 # Get the amount of RAM used by the bot
@@ -49,8 +74,10 @@ async def ping(self, ctx: commands.Context[Tux]) -> None:
4974 )
5075
5176 embed .add_field (name = "API Latency" , value = f"{ discord_ping } ms" , inline = True )
77+ embed .add_field (name = "Uptime" , value = f"{ bot_uptime_readable } " , inline = True )
5278 embed .add_field (name = "CPU Usage" , value = f"{ cpu_usage } %" , inline = True )
5379 embed .add_field (name = "RAM Usage" , value = f"{ ram_amount_formatted } " , inline = True )
80+ embed .add_field (name = "Prod/Dev" , value = f"`{ environment } `" , inline = True )
5481
5582 await ctx .send (embed = embed )
5683
0 commit comments