This commit is contained in:
Aeru committed 2026-10-18 00:35:18 +02:00
1 parent c022fc2a2d
commit c6351241c8
7 files changed
+63 -1

No files matched your search

+1
View File
@@ -0,0 +1 @@
DISCORD_TOKEN=
+2 -1
View File
@@ -1 +1,2 @@
.env
.env
venv/
+1
View File
@@ -0,0 +1 @@
pip install -r requirements.txt
+45
View File
@@ -0,0 +1,45 @@
import discord
import requests
import dotenv
from discord import app_commands
import psutil
import time
from other.ikavoidping import get_api_ping
dotenv.load_dotenv()
TOKEN = dotenv.get_key(".env", "DISCORD_TOKEN")
class Bot(discord.Client):
def __init__(self):
super().__init__(intents=discord.Intents.all())
self.tree = app_commands.CommandTree(self)
self.startup_timestamp = time.time()
async def setup_hook(self):
await self.tree.sync()
bot = Bot()
@bot.event
async def on_ready():
print(f'Logged in as {bot.user}')
@bot.tree.command(name="status", description="Get the bot's current status")
async def status(interaction: discord.Interaction):
cpu_usage = psutil.cpu_percent(interval=1, percpu=True)
avg_cpu_usage = sum(cpu_usage) / len(cpu_usage)
memory_info = psutil.virtual_memory()
used_memory = memory_info.used
total_memory = memory_info.total
discord_latency = bot.latency
uptime = time.time() - bot.startup_timestamp
await interaction.response.send_message(
f"CPU Usage: {avg_cpu_usage:.2f}%\n"
f"Per-Core CPU Usage: {', '.join(f'{usage}%' for usage in cpu_usage)}\n"
f"Memory Usage: {memory_info.percent}% ({used_memory / (1024**2):.2f} MB / {total_memory / (1024**2):.2f} MB)\n"
f"Bot Latency: {discord_latency*1000:.2f} ms\n"
f"Uptime: {int(uptime // 86400)}d {int((uptime % 86400) // 3600)}h {int((uptime % 3600) // 60)}m {int(uptime % 60)}s\n"
f"API Ping: {await get_api_ping():.2f} ms"
)
bot.run(TOKEN)
Binary file not shown.
+11
View File
@@ -0,0 +1,11 @@
import requests
import time
url = "https://api.ikavoid.fr/"
async def get_api_ping():
start_time = time.time()
requests.get(url)
end_time = time.time()
ping = (end_time - start_time) * 1000
return ping
+3
View File
@@ -0,0 +1,3 @@
discord.py
requests
psutil