mirror of
https://github.com/Matthww/TuneBot.git
synced 2026-09-21 23:37:47 +00:00
65 lines
2.7 KiB
Python
65 lines
2.7 KiB
Python
import typing
|
|
|
|
import humanize
|
|
import lavalink
|
|
from discord import app_commands
|
|
from discord import Interaction
|
|
|
|
from utils.embed import create_embed
|
|
|
|
if typing.TYPE_CHECKING:
|
|
from bot import TuneBot
|
|
|
|
|
|
class InfoCommands(app_commands.Group):
|
|
def __init__(self, bot: "TuneBot"):
|
|
super().__init__(name="bot", description="Some extra info")
|
|
self.bot: "TuneBot" = bot
|
|
|
|
@app_commands.command(name="invite", description="I'd happily join your server")
|
|
async def invite(self, ctx: Interaction):
|
|
embed = create_embed(ctx.user)
|
|
embed.title = "My invite link"
|
|
embed.description = f"[{self.bot.invite_link}]({self.bot.invite_link})"
|
|
await ctx.response.send_message(embed=embed)
|
|
|
|
@app_commands.command(
|
|
name="stats", description="Some node/server/player information"
|
|
)
|
|
async def wlinfo(self, ctx: Interaction):
|
|
embed = create_embed(ctx.user)
|
|
nodes = self.bot.lavalink.node_manager.available_nodes
|
|
|
|
used = humanize.naturalsize(sum([n.stats.memory_used for n in nodes]))
|
|
total = humanize.naturalsize(sum([n.stats.memory_allocated for n in nodes]))
|
|
free = humanize.naturalsize(sum([n.stats.memory_free for n in nodes]))
|
|
cpu = sum([n.stats.cpu_cores for n in nodes])
|
|
|
|
info = self.bot.config["info"]
|
|
embed.title = info["name"] + " stats"
|
|
|
|
embed.description = (
|
|
f"**Lavalink:** `{lavalink.__version__}`\n\n"
|
|
f"Connected to `{len(self.bot.lavalink.node_manager.available_nodes)}` nodes.\n"
|
|
f"`{len(self.bot.lavalink.player_manager.players)}` players are distributed on nodes.\n"
|
|
f"`{sum([n.stats.players for n in nodes])}` players are distributed on server.\n"
|
|
f"`{sum([n.stats.playing_players for n in nodes])}` players are playing on server.\n\n"
|
|
f"Server Memory: `{used}/{total}` | `({free} free)`\n"
|
|
f"Server CPU: `{cpu}`\n\n"
|
|
)
|
|
await ctx.response.send_message(embed=embed)
|
|
|
|
@app_commands.command(name="tos", description="Terms of Service")
|
|
async def tos(self, ctx: Interaction):
|
|
embed = create_embed(ctx.user)
|
|
embed.title = "Terms of Service (ToS)"
|
|
embed.description = "[https://exobot.site/static/tos.html](https://exobot.site/static/tos.html)"
|
|
await ctx.response.send_message(embed=embed)
|
|
|
|
@app_commands.command(name="privacy", description="Privacy Policy")
|
|
async def privacy(self, ctx: Interaction):
|
|
embed = create_embed(ctx.user)
|
|
embed.title = "Privacy Policy"
|
|
embed.description = "[https://exobot.site/static/privacy.html](https://exobot.site/static/privacy.html)"
|
|
await ctx.response.send_message(embed=embed)
|