edditing code

This commit is contained in:
2022-08-21 20:59:53 +03:00
parent 1011e287c9
commit 5a50b2ac98
5 changed files with 182 additions and 64 deletions

View File

@@ -1,11 +1,14 @@
import logging
import os
import psutil
import disnake
from disnake.ext import commands
class Bot_info(commands.Cog, name='Bot Info'):
def __init__(self, bot: object) -> object:
def __init__(self, bot):
self.bot = bot # defining bot as global var in class
@commands.Cog.listener() # this is a decorator for events/listeners
@@ -14,20 +17,21 @@ class Bot_info(commands.Cog, name='Bot Info'):
@commands.slash_command(name="info_bot") # this is for making a command
async def info_bot(self, inter):
# await ctx.send(f'Pong! {round(self.bot.latency * 1000)}')
_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.avatar.url)
# emb.set_thumbnail(self.bot.display_avatar)
emb.add_field(name="Bot ping", value=f'Bot ping: {round(self.bot.latency * 1000)}', inline=True)
emb.add_field(name="Memory Usage", value=f"{_process.memory_info()[0]/2**20} Mb", inline=True)
emb.add_field(name="CPU Usage", value=f"{_process.cpu_percent()}%", inline=True)
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