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,23 @@ 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_readable = " " .join (
48+ [f"{ days } d" if days else "" , f"{ hours } h" if hours else "" , f"{ minutes } m" if minutes else "" , f"{ seconds } s" ],
49+ ).strip ()
50+
3051 # Get the CPU usage and RAM usage of the bot
3152 cpu_usage = psutil .Process ().cpu_percent ()
3253 # Get the amount of RAM used by the bot
@@ -49,8 +70,10 @@ async def ping(self, ctx: commands.Context[Tux]) -> None:
4970 )
5071
5172 embed .add_field (name = "API Latency" , value = f"{ discord_ping } ms" , inline = True )
73+ embed .add_field (name = "Uptime" , value = f"{ bot_uptime_readable } " , inline = True )
5274 embed .add_field (name = "CPU Usage" , value = f"{ cpu_usage } %" , inline = True )
5375 embed .add_field (name = "RAM Usage" , value = f"{ ram_amount_formatted } " , inline = True )
76+ embed .add_field (name = "Prod/Dev" , value = f"`{ environment } `" , inline = True )
5477
5578 await ctx .send (embed = embed )
5679
0 commit comments