Skip to content

Commit d23cef1

Browse files
committed
Add /info command.
1 parent ce9c645 commit d23cef1

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

main.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import traceback
88
import datetime
99
import uuid
10+
import platform
11+
import time
1012

1113
from disnake.ext import commands
1214
from disnake.ui import View, Button
@@ -17,6 +19,7 @@
1719
DATA_FILE = "forums.json"
1820
client.remove_command("help")
1921

22+
start_time = time.time()
2023

2124
@client.event
2225
async def on_guild_join(guild: disnake.Guild):
@@ -199,6 +202,52 @@ async def about(interaction: disnake.CommandInteraction):
199202
await interaction.response.send_message(embed=embed, ephemeral=True)
200203

201204

205+
@client.slash_command(name="info", description="Информация о боте")
206+
async def info(interaction: disnake.CommandInteraction):
207+
uptime_seconds = int(time.time() - start_time)
208+
hours, remainder = divmod(uptime_seconds, 3600)
209+
minutes, seconds = divmod(remainder, 60)
210+
211+
ping = round(client.latency * 1000)
212+
guild_count = len(client.guilds)
213+
user_count = len(set(member.id for guild in client.guilds for member in guild.members))
214+
disnake_version = disnake.__version__
215+
python_version = platform.python_version()
216+
os_info = f"{platform.system()} {platform.release()} ({platform.machine()})"
217+
218+
embed_color = (
219+
disnake.Color.green() if ping < 100 else
220+
disnake.Color.yellow() if ping < 250 else
221+
disnake.Color.red()
222+
)
223+
224+
embed = disnake.Embed(
225+
title="Информация о боте",
226+
color=embed_color,
227+
timestamp=disnake.utils.utcnow()
228+
)
229+
230+
embed.add_field(name="📡 Пинг", value=f"`{ping} ms`", inline=True)
231+
embed.add_field(name="⏳ Аптайм", value=f"`{hours}h {minutes}m {seconds}s`", inline=True)
232+
embed.add_field(name="", value="", inline=False)
233+
embed.add_field(name="🛠️ Серверов", value=f"`{guild_count}`", inline=True)
234+
embed.add_field(name="👥 Пользователей", value=f"`{user_count}`", inline=True)
235+
embed.add_field(name="", value="", inline=False)
236+
embed.add_field(name="📦 Disnake", value=f"`v{disnake_version}`", inline=True)
237+
embed.add_field(name="🐍 Python", value=f"`v{python_version}`", inline=True)
238+
embed.add_field(name="", value="", inline=False)
239+
embed.add_field(name="💻 ОС", value=f"`{os_info}`", inline=False)
240+
241+
242+
embed.set_footer(
243+
text=f"Made with ❤️ by PrivateKey2", icon_url=client.user.display_avatar.url
244+
)
245+
246+
await interaction.response.send_message(embed=embed, ephemeral=True)
247+
248+
249+
250+
202251
@forum.sub_command(name="add", description="Создать новый форум")
203252
async def forum_add(
204253
interaction: disnake.CommandInteraction,

0 commit comments

Comments
 (0)