Download main.py from coo0lt/262: direct link, hf CLI and curl.
- Browser
- Download file 2.08 kB
-
https://huggingface.co/spaces/coo0lt/262/resolve/main/main.py
- Command line
-
hf download hf://spaces/coo0lt/262/main.py
-
curl -L -o main.py https://huggingface.co/spaces/coo0lt/262/resolve/main/main.py
2.08 kB
| import discord | |
| from discord.ext import commands | |
| import os | |
| # 1. إعداد الصلاحيات (Intents) | |
| # بنفعل كل الصلاحيات عشان البوت يقدر يقرأ الرسائل ويشوف الأعضاء | |
| intents = discord.Intents.all() | |
| bot = commands.Bot(command_prefix='.', intents=intents) | |
| # 2. سحب التوكن من السيكريتس (لأمان بوتك) | |
| # لازم تكون ضفت BOT_TOKEN في الـ Settings بتاعة الـ Space | |
| TOKEN = os.environ.get("BOT_TOKEN") | |
| # 3. أحداث البوت (Events) | |
| async def on_ready(): | |
| print(f'--- Maden System Online ---') | |
| print(f'Logged in as: {bot.user.name}') | |
| print(f'ID: {bot.user.id}') | |
| print(f'Discord.py Version: {discord.__version__}') | |
| print(f'---------------------------') | |
| # تغيير حالة البوت (Status) لـ Maden Delta Force | |
| await bot.change_presence(activity=discord.Game(name="Maden Delta Force")) | |
| # 4. الأوامر (Commands) | |
| # أمر التأكد من السرعة (Ping) | |
| async def ping(ctx): | |
| latency = round(bot.latency * 1000) | |
| await ctx.send(f'🏓 Pong! | السرعة: {latency}ms') | |
| # أمر ترحيب بسيط | |
| async def hello(ctx): | |
| await ctx.send(f'أهلاً بك يا {ctx.author.mention}! أنا بوت Maden Delta Force، كيف يمكنني مساعدتك؟') | |
| # أمر لعرض معلومات السيرفر | |
| async def server(ctx): | |
| name = str(ctx.guild.name) | |
| memberCount = str(ctx.guild.member_count) | |
| await ctx.send(f'اسم السيرفر: {name}\nعدد الأعضاء: {memberCount}') | |
| # 5. تشغيل البوت | |
| if TOKEN: | |
| try: | |
| bot.run(TOKEN) | |
| except discord.errors.LoginFailure: | |
| print("خطأ: التوكن غير صحيح! تأكد من عمل Reset Token من صفحة المطورين.") | |
| except Exception as e: | |
| print(f"حدث خطأ أثناء التشغيل: {e}") | |
| else: | |
| print("خطأ: لم يتم العثور على التوكن! تأكد من إضافته في Settings > Secrets باسم BOT_TOKEN") |