43 lines
1.7 KiB
Python
43 lines
1.7 KiB
Python
import os
|
|
|
|
import disnake
|
|
import psutil
|
|
from disnake.ext import commands
|
|
|
|
from lib import determine_prefix, determine_time
|
|
from lib import logger
|
|
|
|
|
|
class Bot_info(commands.Cog, name='Bot Info'):
|
|
def __init__(self, bot):
|
|
self.bot = bot # defining bot as global var in class
|
|
|
|
@commands.Cog.listener() # this is a decorator for events/listeners
|
|
async def on_ready(self):
|
|
logger.info(f'Cog {__name__.split(".")[1]} is ready!.')
|
|
|
|
@commands.slash_command(name="info_bot",
|
|
description='Shows general info about bot') # this is for making a command
|
|
async def info_bot(self, inter):
|
|
_pid = os.getpid()
|
|
_process = psutil.Process(_pid)
|
|
emb = disnake.Embed(
|
|
title=f"General information",
|
|
description=f"General information on about bot",
|
|
)
|
|
# emb.set_thumbnail(self.bot.user.avarat_url)
|
|
emb.add_field(name="System info:", value=f"Memory Usage: {round(_process.memory_info().rss / 2 ** 20, 2)} Mb\n"
|
|
f"CPU Usage: {_process.cpu_percent()}%\n"
|
|
f'Bot ping: {round(self.bot.latency * 1000)}\n'
|
|
f'Prefix: `{determine_prefix(self.bot, inter)}\n`'
|
|
f"Max audio duration: {determine_time(inter)} sec\n"
|
|
)
|
|
emb.add_field(name="Bot owner", value=f"<@{self.bot.owner_id}>")
|
|
emb.set_footer(text="Information requested by: {}".format(inter.author.display_name))
|
|
|
|
await inter.response.send_message(embed=emb, ephemeral=True)
|
|
|
|
|
|
def setup(bot): # an extension must have a setup function
|
|
bot.add_cog(Bot_info(bot)) # adding a cog
|