feat(commands/bot): add status

This commit is contained in:
Ryan 2025-01-08 09:25:11 -05:00
parent e3982c064d
commit be77e62e53
Signed by: ErrorNoInternet
GPG Key ID: 2486BFB7B1E6A4A3
3 changed files with 65 additions and 7 deletions

View File

@ -1,18 +1,64 @@
import os
import threading
import time import time
import disnake
import psutil
import arguments import arguments
import commands import commands
import utils import utils
from state import start_time from constants import EMBED_COLOR
from state import client, start_time
async def help(message): async def status(message):
await utils.reply( member_count = 0
message, channel_count = 0
", ".join( for guild in client.guilds:
[f"`{command.value}`" for command in commands.Command.__members__.values()] member_count += len(guild.members)
), channel_count += len(guild.channels)
process = psutil.Process(os.getpid())
memory_usage = process.memory_info().rss / 1048576
embed = disnake.Embed(color=EMBED_COLOR)
embed.add_field(
name="Latency",
value=f"```{round(client.latency * 1000, 1)} ms```",
) )
embed.add_field(
name="RSS",
value=f"```{round(memory_usage, 1)} MiB```",
)
embed.add_field(
name="Threads",
value=f"```{threading.active_count()}```",
)
embed.add_field(
name="Guilds",
value=f"```{len(client.guilds)}```",
)
embed.add_field(
name="Members",
value=f"```{member_count}```",
)
embed.add_field(
name="Channels",
value=f"```{channel_count}```",
)
embed.add_field(
name="Commands",
value=f"```{len(commands.Command.__members__)}```",
)
embed.add_field(
name="Disnake",
value=f"```{disnake.__version__}```",
)
embed.add_field(
name="Uptime",
value=f"```{utils.format_duration(int(time.time() - start_time), short=True)}```",
)
await utils.reply(message, embed=embed)
async def uptime(message): async def uptime(message):
@ -36,3 +82,12 @@ async def uptime(message):
await utils.reply( await utils.reply(
message, f"up {utils.format_duration(int(time.time() - start_time))}" message, f"up {utils.format_duration(int(time.time() - start_time))}"
) )
async def help(message):
await utils.reply(
message,
", ".join(
[f"`{command.value}`" for command in commands.Command.__members__.values()]
),
)

View File

@ -19,6 +19,7 @@ class Command(Enum):
RELOAD = "reload" RELOAD = "reload"
RESUME = "resume" RESUME = "resume"
SKIP = "skip" SKIP = "skip"
STATUS = "status"
UPTIME = "uptime" UPTIME = "uptime"
VOLUME = "volume" VOLUME = "volume"

View File

@ -132,6 +132,8 @@ async def on_message(message, edited=False):
await commands.voice.playing(message) await commands.voice.playing(message)
case C.FAST_FORWARD: case C.FAST_FORWARD:
await commands.voice.fast_forward(message) await commands.voice.fast_forward(message)
case C.STATUS:
await commands.bot.status(message)
except Exception as e: except Exception as e:
await utils.reply( await utils.reply(
message, message,