1
Fork 0
mirror of https://github.com/allthingslinux/tux.git synced 2024-10-02 16:43:12 +00:00

Merge pull request #511 from allthingslinux/tess-fixping

This commit is contained in:
kzndotsh 2024-09-03 10:47:03 -04:00 committed by GitHub
commit 2f5ffee5ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,15 +27,16 @@ class Ping(commands.Cog):
discord_ping = round(self.bot.latency * 1000)
# Get the CPU usage and RAM usage of the bot
cpu_usage = psutil.cpu_percent()
cpu_usage = psutil.Process().cpu_percent()
# Get the amount of RAM used by the bot
ram_amount = psutil.virtual_memory().used
ram_amount_in_bytes = psutil.Process().memory_info().rss
ram_amount_in_mb = ram_amount_in_bytes / (1024 * 1024)
# Format the RAM usage to be in GB or MB
if ram_amount >= 1024**3:
ram_amount_formatted = f"{ram_amount // (1024**3)}GB"
# Format the RAM usage to be in GB or MB, rounded to nearest integer
if ram_amount_in_mb >= 1024:
ram_amount_formatted = f"{round(ram_amount_in_mb / 1024)}GB"
else:
ram_amount_formatted = f"{ram_amount // (1024**2)}MB"
ram_amount_formatted = f"{round(ram_amount_in_mb)}MB"
embed = EmbedCreator.create_success_embed(
title="Pong!",