Add sysinfo command
This commit is contained in:
parent
c854d2c2ba
commit
833147017a
1 changed files with 19 additions and 0 deletions
|
@ -1,12 +1,17 @@
|
||||||
"""JARVIS bot utility commands."""
|
"""JARVIS bot utility commands."""
|
||||||
import logging
|
import logging
|
||||||
|
import platform
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
import psutil
|
||||||
from aiofile import AIOFile, LineReader
|
from aiofile import AIOFile, LineReader
|
||||||
from dis_snek import MessageContext, Scale, Snake
|
from dis_snek import MessageContext, Scale, Snake
|
||||||
|
from dis_snek.models.discord.embed import EmbedField
|
||||||
from dis_snek.models.discord.file import File
|
from dis_snek.models.discord.file import File
|
||||||
from molter import msg_command
|
from molter import msg_command
|
||||||
|
|
||||||
|
from jarvis.utils import build_embed
|
||||||
|
|
||||||
|
|
||||||
class BotutilCog(Scale):
|
class BotutilCog(Scale):
|
||||||
"""JARVIS Bot Utility Cog."""
|
"""JARVIS Bot Utility Cog."""
|
||||||
|
@ -52,6 +57,20 @@ class BotutilCog(Scale):
|
||||||
async def _crash(self, ctx: MessageContext) -> None:
|
async def _crash(self, ctx: MessageContext) -> None:
|
||||||
raise Exception("As you wish")
|
raise Exception("As you wish")
|
||||||
|
|
||||||
|
@msg_command(name="sysinfo")
|
||||||
|
async def _sysinfo(self, ctx: MessageContext) -> None:
|
||||||
|
st_ts = int(self.bot.start_time.timestamp())
|
||||||
|
ut_ts = int(psutil.boot_time())
|
||||||
|
fields = [
|
||||||
|
EmbedField(name="Operation System", value=platform.system() or "Unknown", inline=False),
|
||||||
|
EmbedField(name="Version", value=platform.release() or "N/A", inline=False),
|
||||||
|
EmbedField(name="System Start Time", value=f"<t:{ut_ts}:F> (<t:{ut_ts}:R>)"),
|
||||||
|
EmbedField(name="Python Version", value=platform.python_version()),
|
||||||
|
EmbedField(name="Bot Start Time", value=f"<t:{st_ts}:F> (<t:{st_ts}:R>)"),
|
||||||
|
]
|
||||||
|
embed = build_embed(title="System Info", description="", fields=fields)
|
||||||
|
await ctx.send(embed=embed)
|
||||||
|
|
||||||
|
|
||||||
def setup(bot: Snake) -> None:
|
def setup(bot: Snake) -> None:
|
||||||
"""Add BotutilCog to JARVIS"""
|
"""Add BotutilCog to JARVIS"""
|
||||||
|
|
Loading…
Add table
Reference in a new issue