48 lines
1.5 KiB
Python
48 lines
1.5 KiB
Python
import jarvis
|
|
from jarvis import jarvis_self, config, logo
|
|
from jarvis.utils import convert_bytesize, build_embed, get_repo_hash
|
|
from jarvis.utils.field import Field
|
|
from discord.ext import commands
|
|
|
|
|
|
class UtilCog(commands.Cog):
|
|
"""
|
|
Utility functions for J.A.R.V.I.S.
|
|
|
|
Mostly system utility functions, but may change over time
|
|
"""
|
|
|
|
def __init__(self, bot):
|
|
self.bot = bot
|
|
self.config = config.get_config()
|
|
|
|
@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))
|
|
fields.append(Field("Version", jarvis.__version__, False))
|
|
fields.append(Field("Git Hash", get_repo_hash(), False))
|
|
embed = build_embed(
|
|
title=title, description=desc, fields=fields, color=color
|
|
)
|
|
await ctx.send(embed=embed)
|
|
|
|
@commands.command(name="logo", help="Get the current logo")
|
|
async def _logo(self, ctx):
|
|
lo = logo.get_logo(self.config.logo)
|
|
await ctx.send(f"```\n{lo}\n```")
|
|
|
|
|
|
def setup(bot):
|
|
bot.add_cog(UtilCog(bot))
|