11import os
2+ import platform
3+ import sys
4+ from datetime import datetime
25
36import discord
7+ import pomice
48from discord import app_commands
59from discord .ext import commands
6- from yt_dlp .version import __version__
710
8- from ..utils .embeds import InfoEmbed , PingEmbed
11+ from ..utils .cog import Cog
12+ from ..utils .embeds import PingEmbed
13+ from ..utils .player import CustomPlayer
914
1015
11- class Basics (commands . Cog ):
16+ class Basics (Cog ):
1217 def __init__ (self , bot : commands .Bot ):
13- self . bot = bot
18+ super (). __init__ ( bot = bot )
1419
1520 @app_commands .command (name = "ping" , description = "Ping the bot" )
1621 async def ping (self , interaction : discord .Interaction ):
17- voice_client = interaction .guild .voice_client if interaction .guild else None
22+ voice_client : CustomPlayer | None = (
23+ interaction .guild .voice_client if interaction .guild else None
24+ )
1825 if voice_client :
1926 await interaction .response .send_message (
20- embed = PingEmbed (self .bot .user , voice_client .latency )
27+ embed = PingEmbed (self .bot .user , voice_client .node . latency )
2128 )
2229 else :
2330 await interaction .response .send_message (
@@ -26,7 +33,143 @@ async def ping(self, interaction: discord.Interaction):
2633
2734 @app_commands .command (name = "version" , description = "Show version information" )
2835 async def version (self , interaction : discord .Interaction ):
29- embed = InfoEmbed ( self .bot . user , "" )
30- embed . add_field ( name = "version" , value = os . getenv ( "ROSETTA_VERSION" ) )
31- embed . add_field ( name = "yt-dlp version" , value = __version__ )
36+ embed = await self .generate_version_embed (
37+ interaction , is_admin = await self . bot . is_owner ( interaction . user )
38+ )
3239 await interaction .response .send_message (embed = embed )
40+
41+ @commands .is_owner ()
42+ @commands .command (name = "version" , description = "Show version information" )
43+ async def admin (self , ctx : commands .Context ):
44+ embed = await self .generate_version_embed (ctx , is_admin = True )
45+
46+ await ctx .reply (embed = embed )
47+
48+ @commands .is_owner ()
49+ @commands .command (name = "guilds" , description = "Show all guilds the bot is in" )
50+ async def guilds (self , ctx : commands .Context ):
51+ """Display all guilds the bot is currently in"""
52+ from ..utils .views import GuildsView
53+
54+ view = GuildsView (self .bot )
55+ await ctx .reply (view = view )
56+
57+ async def generate_version_embed (
58+ self , ctx : discord .Interaction | commands .Context , is_admin : bool = False
59+ ):
60+ embed = discord .Embed (
61+ title = ":information_source: Info" ,
62+ color = discord .Color .blurple (),
63+ timestamp = datetime .now (),
64+ )
65+
66+ # Gather bot statistics
67+ total_guilds = len (self .bot .guilds )
68+ total_users = sum (guild .member_count for guild in self .bot .guilds )
69+ total_channels = sum (len (guild .channels ) for guild in self .bot .guilds )
70+ total_voice_channels = sum (
71+ len (guild .voice_channels ) for guild in self .bot .guilds
72+ )
73+
74+ # Version information
75+ python_version = f"{ sys .version_info .major } .{ sys .version_info .minor } .{ sys .version_info .micro } "
76+ discord_version = discord .__version__
77+
78+ # System information
79+ os_info = f"{ platform .system ()} { platform .release ()} "
80+
81+ # Create embed
82+ embed = discord .Embed (
83+ title = "🛡️ Admin Panel" ,
84+ description = "Bot Statistics and Information" ,
85+ color = discord .Color .blue (),
86+ timestamp = datetime .now (),
87+ )
88+
89+ # Versions
90+ embed .add_field (
91+ name = "Version" ,
92+ value = os .getenv ("ROSETTA_VERSION" ),
93+ inline = True ,
94+ )
95+ embed .add_field (
96+ name = "Python" ,
97+ value = python_version ,
98+ inline = True ,
99+ )
100+ embed .add_field (
101+ name = "Discord.py" ,
102+ value = discord_version ,
103+ inline = True ,
104+ )
105+
106+ if is_admin :
107+ # Bot Statistics
108+ embed .add_field (
109+ name = "Statistics" ,
110+ value = f"**Guilds:** { total_guilds :,} \n "
111+ f"**Users:** { total_users :,} \n "
112+ f"**Channels:** { total_channels :,} \n "
113+ f"**Voice Channels:** { total_voice_channels :,} " ,
114+ inline = True ,
115+ )
116+
117+ # System Information
118+ embed .add_field (
119+ name = "System" ,
120+ value = f"**OS:** { os_info } \n **Platform:** { platform .machine ()} " ,
121+ inline = True ,
122+ )
123+
124+ # Cog Information
125+ cog_count = len (self .bot .cogs )
126+ command_count = len (self .bot .tree .get_commands ())
127+ embed .add_field (
128+ name = "Loaded Modules" ,
129+ value = f"**Cogs:** { cog_count } \n **Slash Commands:** { command_count } " ,
130+ inline = True ,
131+ )
132+
133+ # Lavalink Node Information
134+ try :
135+ node_pool = pomice .NodePool ()
136+ nodes = node_pool .nodes
137+
138+ if nodes :
139+ node_info_lines = []
140+ for node in nodes .values ():
141+ status = (
142+ "🟢 Connected" if node .is_connected else "🔴 Disconnected"
143+ )
144+ latency_ms = (
145+ round (node .latency * 1000 , 2 ) if node .latency else 0
146+ )
147+ node_info_lines .append (
148+ f"- **{ node ._identifier } ** { status } • { latency_ms } ms"
149+ )
150+
151+ embed .add_field (
152+ name = f"🎵 Lavalink Nodes ({ len (nodes )} )" ,
153+ value = "\n " .join (node_info_lines )
154+ if node_info_lines
155+ else "No nodes available" ,
156+ inline = False ,
157+ )
158+ else :
159+ embed .add_field (
160+ name = "🎵 Lavalink Nodes" ,
161+ value = "No nodes available" ,
162+ inline = False ,
163+ )
164+ except Exception as e :
165+ embed .add_field (
166+ name = "🎵 Lavalink Nodes" ,
167+ value = f"Error fetching nodes: { str (e )} " ,
168+ inline = False ,
169+ )
170+
171+ embed .set_thumbnail (
172+ url = self .bot .user .avatar .url if self .bot .user .avatar else None
173+ )
174+
175+ return embed
0 commit comments