jarvis-bot/jarvis/cogs/util.py

32 lines
991 B
Python

from jarvis import jarvis_self
from jarvis.utils import convert_bytesize, build_embed
from jarvis.utils.field import Field
from discord import Embed, Color
from discord.ext import commands
class UtilCog(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(name="status", help="Retrieve J.A.R.V.I.S. status")
async def _status(self, ctx):
title = "J.A.R.V.I.S. Status"
desc = "All systems online"
color = "#98CCDA"
fields = []
with jarvis_self.oneshot():
fields.append(Field("CPU Usage", jarvis_self.cpu_percent()))
fields.append(
Field(
"RAM Usage",
convert_bytesize(jarvis_self.memory_info().rss),
)
)
fields.append(Field("PID", jarvis_self.pid))
embed = build_embed(title, desc, fields, color)
await ctx.send(embed=embed)
def setup(bot):
bot.add_cog(UtilCog(bot))