Merge pull request 'Redesign server embed' (#3) from experimental into main
All checks were successful
Docker Build and Push (Multi-architecture) / build-and-push (push) Successful in 23s

Reviewed-on: #3
This commit is contained in:
2025-09-26 11:18:59 +00:00

View File

@@ -750,21 +750,35 @@ class PterodactylBot(commands.Bot):
timestamp=datetime.now()
)
embed.add_field(name="Server ID", value=identifier, inline=True)
embed.add_field(name="🆔 Server ID", value=f"`{identifier}`", inline=True)
if is_suspended:
embed.add_field(name="Status", value="⛔ Suspended", inline=True)
embed.add_field(name="📊 Status", value="⛔ Suspended", inline=True)
else:
embed.add_field(name="Status", value="✅ Active", inline=True)
embed.add_field(name="📊 Status", value="✅ Active", inline=True)
# Add resource usage if server is running
if current_state.lower() == "running":
# Current usage
cpu_usage = round(resource_attributes.get('resources', {}).get('cpu_absolute', 0), 2)
memory_usage = round(resource_attributes.get('resources', {}).get('memory_bytes', 0) / (1024 ** 2), 2)
disk_usage = round(resource_attributes.get('resources', {}).get('disk_bytes', 0) / (1024 ** 2), 2)
network_rx = round(resource_attributes.get('resources', {}).get('network_rx_bytes', 0) / (1024 ** 2), 2)
network_tx = round(resource_attributes.get('resources', {}).get('network_tx_bytes', 0) / (1024 ** 2), 2)
# Maximum allocated resources from server data
limits = attributes.get('limits', {})
cpu_limit = limits.get('cpu', 0)
memory_limit = limits.get('memory', 0)
disk_limit = limits.get('disk', 0)
# Format limit values - display ∞ for unlimited (0 limit)
def format_limit(value, unit=""):
if value == 0:
return f"{'':<8}{unit}" # Lemniscate symbol for infinity
else:
return f"{value:<8}{unit}"
# Get uptime from Pterodactyl API (in milliseconds)
uptime_ms = resource_attributes.get('resources', {}).get('uptime', 0)
@@ -786,11 +800,28 @@ class PterodactylBot(commands.Bot):
else:
uptime_text = "Just started"
embed.add_field(name="Uptime", value=uptime_text, inline=True)
embed.add_field(name="CPU Usage", value=f"{cpu_usage}%", inline=True)
embed.add_field(name="Memory Usage", value=f"{memory_usage} MB", inline=True)
embed.add_field(name="Disk Usage", value=f"{disk_usage} MB", inline=True)
embed.add_field(name="Network", value=f"⬇️ {network_rx} MB / ⬆️ {network_tx} MB", inline=False)
embed.add_field(name="⏱️ Uptime", value=uptime_text, inline=True)
# Create dedicated usage text box with current usage and limits in monospace font
usage_text = (
f"```\n"
f"CPU: {cpu_usage:>8} / {format_limit(cpu_limit, ' %')}\n"
f"Memory: {memory_usage:>8} / {format_limit(memory_limit, ' MB')}\n"
f"Disk: {disk_usage:>8} / {format_limit(disk_limit, ' MB')}\n"
f"```"
)
embed.add_field(
name="📈 Resource Usage",
value=usage_text,
inline=False
)
embed.add_field(
name="🌐 Network",
value=f"⬇️ {network_rx} MB / ⬆️ {network_tx} MB",
inline=False
)
embed.set_footer(text="Last updated")