-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
76 lines (57 loc) · 2.15 KB
/
main.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import asyncio
import logging
import sys
import discord
from discord.ext import commands
from bot.ui import MediaPlayer
from bot.utils.database import db
from bot.env import load_config
config = load_config()
class Bot(commands.AutoShardedBot):
def __init__(self) -> None:
intents = discord.Intents.default()
intents.messages = True
intents.guilds = True
logging.basicConfig(level=logging.INFO)
logging.getLogger("apscheduler").setLevel(logging.WARNING)
super().__init__(command_prefix="?", intents=intents, help_command=None)
async def on_command_error(self, ctx, error):
if isinstance(error, commands.CommandNotFound):
await ctx.send("Дождитесь полного запуска бота или синхронизации команд на сервере!")
elif isinstance(error, discord.ApplicationCommandError):
await ctx.send("Дождитесь полного запуска бота или синхронизации команд на сервере!")
elif isinstance(error, discord.ApplicationCommandInvokeError):
await ctx.send("Дождитесь полного запуска бота или синхронизации команд на сервере!")
else:
print(f"Unhandled error: {error}")
async def on_ready(self) -> None:
await db.create_table()
bot.add_view(MediaPlayer())
# BOT_SCHEDULER.start()
logging.info(f"Logged in: {self.user} | {self.user.id}")
bot: Bot = Bot()
async def main() -> None:
async with bot:
await load_extensions()
await bot.start(config.TOKEN)
async def load_extensions() -> None:
print("Loading extensions...")
cogs_list = [
"interactions.play",
"interactions.help",
"interactions.prefix",
"interactions.role",
"core.events",
"core.wavelink.waveEvents",
]
for cog in cogs_list:
bot.load_extension(f"bot.{cog}")
loop = asyncio.get_event_loop()
loop.create_task(main())
try:
loop.run_forever()
except KeyboardInterrupt:
pass
finally:
loop.stop()
sys.exit(0)