-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbot.py
50 lines (40 loc) · 1.59 KB
/
bot.py
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
import json
import nextcord
from nextcord.ext import commands
# Загружаем инфу из config.json
with open('config.json', 'r') as config_file:
config = json.load(config_file)
TOKEN = config['TOKEN']
GUILD_ID = int(config['GUILD_ID'])
intents = nextcord.Intents.default()
intents.message_content = True
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
print(f"✅ Бот {bot.user} успешно подключился к Discord!")
guild = bot.get_guild(GUILD_ID)
if guild is None:
print("❌ Ошибка: сервер не найден!")
return
await clear_channels(guild)
await clear_roles(guild)
async def clear_channels(guild):
"""Удаляет все текстовые и голосовые каналы."""
for channel in guild.channels:
try:
await channel.delete()
print(f"🗑️ Удалён канал: {channel.name}")
except Exception as e:
print(f"❌ Ошибка при удалении {channel.name}: {e}")
async def clear_roles(guild):
"""Удаляет все роли, кроме @everyone."""
for role in guild.roles:
if role.name != "@everyone": # Не удаляем стандартную роль
try:
await role.delete()
print(f"🗑️ Удалена роль: {role.name}")
except Exception as e:
print(f"❌ Ошибка при удалении роли {role.name}: {e}")
# Запускаем бота
bot.run(TOKEN)