From c6351241c8112f633abbbe9de44a9bbc7efde613 Mon Sep 17 00:00:00 2001 From: aeru Date: Sun, 18 Oct 2026 00:35:18 +0200 Subject: [PATCH] stable1 --- .env.example | 1 + .gitignore | 3 +- README.md | 1 + main.py | 45 ++++++++++++++++++ other/__pycache__/ikavoidping.cpython-313.pyc | Bin 0 -> 604 bytes other/ikavoidping.py | 11 +++++ requirements.txt | 3 ++ 7 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 .env.example create mode 100644 README.md create mode 100644 main.py create mode 100644 other/__pycache__/ikavoidping.cpython-313.pyc create mode 100644 other/ikavoidping.py create mode 100644 requirements.txt diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8141df0 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +DISCORD_TOKEN= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 2eea525..9bec4dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -.env \ No newline at end of file +.env +venv/ \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..39a9971 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +pip install -r requirements.txt \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..7f828c0 --- /dev/null +++ b/main.py @@ -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) \ No newline at end of file diff --git a/other/__pycache__/ikavoidping.cpython-313.pyc b/other/__pycache__/ikavoidping.cpython-313.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ed5616da60a6ffa73bab246a08573c1bb6d3cd34 GIT binary patch literal 604 zcmey&%ge<81TEh$XFUYck3k$5V1hC}%K;fv8G;#t8NC^bAT(nUV=z+@Q!uj>LlJX2 zqbAEskYc|o@r;s^f?_Lu{ltPyz0B;yvi!^xy|g0zWT;tSiWx{Y1M%l2Kth>80cdzM zSOP=@!C44~5`!s}lgAJZa~4Ao3ql2qrNj`;24kBtLRbpKo6Z;^pbHF;U`Ab528KMQ zP$m@ybLKQgO(wt07eH5QvfN@R$;?f?#Zi=6SejZ~QhbX!J+;*!Lo zl6Z)U)Vvf3i=`klFTEJ#X9Wd?Tc-LM`MIh3iK#`U`Y!p&rManjCB^#5`6;RTzNzH} znW_5uB^jwj`p~cg>D4Q!yu|~wCLS23@gRXB9-v_$Zx&kuiI)rw40i-Yr%O(foGjho zb%%wg-KWWCitrT{(L4OY{gqvn-PH{qH+V!Y@+d9{xyY^A;BteTzrp)wG02D}M?OaZ zVEh#UJ