Spaces:
Configuration error
Configuration error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,51 +2,20 @@ import discord
|
|
| 2 |
from discord.ext import commands
|
| 3 |
from discord.ui import Select, View
|
| 4 |
import threading
|
| 5 |
-
import asyncio
|
| 6 |
from flask import Flask
|
| 7 |
|
| 8 |
-
# الكود الصغير
|
| 9 |
app = Flask('')
|
| 10 |
@app.route('/')
|
| 11 |
def home(): return "🤖 MAGIC BOT IS ONLINE 24/7"
|
| 12 |
def run_server(): app.run(host='0.0.0.0', port=7860)
|
| 13 |
|
| 14 |
-
# 1. إعداد صلاحيات البوت الأساسية
|
| 15 |
intents = discord.Intents.default()
|
| 16 |
intents.message_content = True
|
| 17 |
-
intents.voice_states = True
|
| 18 |
|
| 19 |
bot = commands.Bot(command_prefix="!", intents=intents)
|
| 20 |
|
| 21 |
-
# 🆔 آي دي الروم الصوتي الحقيقي بتاع سيرفرك
|
| 22 |
-
VOICE_CHANNEL_ID = 1390374574687785020
|
| 23 |
-
|
| 24 |
-
@bot.event
|
| 25 |
-
async def on_ready():
|
| 26 |
-
print(f"=================================")
|
| 27 |
-
print(f"🤖 MAGIC Bot is online: {bot.user}")
|
| 28 |
-
print(f"=================================")
|
| 29 |
-
|
| 30 |
-
# دخول الروم الصوتي فوراً عند التشغيل
|
| 31 |
-
channel = bot.get_channel(VOICE_CHANNEL_ID)
|
| 32 |
-
if channel and isinstance(channel, discord.VoiceChannel):
|
| 33 |
-
try:
|
| 34 |
-
await channel.connect(reconnect=True, timeout=10.0, self_deaf=True)
|
| 35 |
-
print(f"🎤 تم دخول الروم الصوتي بنجاح: {channel.name}")
|
| 36 |
-
except Exception as e:
|
| 37 |
-
print(f"❌ فشل دخول الروم بسبب: {e}")
|
| 38 |
-
|
| 39 |
-
@bot.event
|
| 40 |
-
async def on_voice_state_update(member, before, after):
|
| 41 |
-
if member == bot.user and after.channel is None:
|
| 42 |
-
await asyncio.sleep(5)
|
| 43 |
-
channel = bot.get_channel(VOICE_CHANNEL_ID)
|
| 44 |
-
if channel:
|
| 45 |
-
try:
|
| 46 |
-
await channel.connect(reconnect=True, self_deaf=True)
|
| 47 |
-
except:
|
| 48 |
-
pass
|
| 49 |
-
|
| 50 |
# 2. تصميم قائمة اختيار اللغة (قوانين السيرفر)
|
| 51 |
class LanguageSelect(Select):
|
| 52 |
def __init__(self):
|
|
@@ -100,7 +69,17 @@ class LanguageView(View):
|
|
| 100 |
super().__init__(timeout=None)
|
| 101 |
self.add_item(LanguageSelect())
|
| 102 |
|
| 103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
@bot.command(name="setup")
|
| 105 |
async def setup_rules(ctx):
|
| 106 |
try:
|
|
@@ -123,7 +102,7 @@ async def setup_rules(ctx):
|
|
| 123 |
await ctx.send(content="@everyone", embed=embed, view=view)
|
| 124 |
|
| 125 |
if __name__ == "__main__":
|
| 126 |
-
# تشغيل السيرفر في الخلفية
|
| 127 |
threading.Thread(target=run_server, daemon=True).start()
|
| 128 |
# تشغيل البوت
|
| 129 |
bot.run("MTQ5ODcyODE0NTQzMDM4NDY4MQ.GpMCDX.LU144SfR5qJgiwuHm_3JRxxo82fTTN8f5zdFAo")
|
|
|
|
| 2 |
from discord.ext import commands
|
| 3 |
from discord.ui import Select, View
|
| 4 |
import threading
|
|
|
|
| 5 |
from flask import Flask
|
| 6 |
|
| 7 |
+
# الكود الصغير لتشغيل سيرفر الويب عشان البوت يفضل صاحي على Hugging Face
|
| 8 |
app = Flask('')
|
| 9 |
@app.route('/')
|
| 10 |
def home(): return "🤖 MAGIC BOT IS ONLINE 24/7"
|
| 11 |
def run_server(): app.run(host='0.0.0.0', port=7860)
|
| 12 |
|
| 13 |
+
# 1. إعداد صلاحيات البوت الأساسية (بدون صلاحيات الفويس)
|
| 14 |
intents = discord.Intents.default()
|
| 15 |
intents.message_content = True
|
|
|
|
| 16 |
|
| 17 |
bot = commands.Bot(command_prefix="!", intents=intents)
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
# 2. تصميم قائمة اختيار اللغة (قوانين السيرفر)
|
| 20 |
class LanguageSelect(Select):
|
| 21 |
def __init__(self):
|
|
|
|
| 69 |
super().__init__(timeout=None)
|
| 70 |
self.add_item(LanguageSelect())
|
| 71 |
|
| 72 |
+
@bot.event
|
| 73 |
+
async def on_ready():
|
| 74 |
+
print(f"=================================")
|
| 75 |
+
print(f"🤖 MAGIC Bot is online: {bot.user}")
|
| 76 |
+
print(f"=================================")
|
| 77 |
+
|
| 78 |
+
# 🌟 تفعيل الأزرار فوراً عند تشغيل البوت لمنع أي تعليق نهائياً
|
| 79 |
+
bot.add_view(LanguageView())
|
| 80 |
+
print("⚙️ تم تفعيل أزرار اللغات بنجاح وبدون تعليق!")
|
| 81 |
+
|
| 82 |
+
# 3. أمر الشات لإنشاء رسالة القوانين
|
| 83 |
@bot.command(name="setup")
|
| 84 |
async def setup_rules(ctx):
|
| 85 |
try:
|
|
|
|
| 102 |
await ctx.send(content="@everyone", embed=embed, view=view)
|
| 103 |
|
| 104 |
if __name__ == "__main__":
|
| 105 |
+
# تشغيل السيرفر الوهمي في الخلفية
|
| 106 |
threading.Thread(target=run_server, daemon=True).start()
|
| 107 |
# تشغيل البوت
|
| 108 |
bot.run("MTQ5ODcyODE0NTQzMDM4NDY4MQ.GpMCDX.LU144SfR5qJgiwuHm_3JRxxo82fTTN8f5zdFAo")
|