File size: 2,076 Bytes
4745b10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
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)
@bot.event
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)
@bot.command()
async def ping(ctx):
    latency = round(bot.latency * 1000)
    await ctx.send(f'🏓 Pong! | السرعة: {latency}ms')

# أمر ترحيب بسيط
@bot.command()
async def hello(ctx):
    await ctx.send(f'أهلاً بك يا {ctx.author.mention}! أنا بوت Maden Delta Force، كيف يمكنني مساعدتك؟')

# أمر لعرض معلومات السيرفر
@bot.command()
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")