-
Notifications
You must be signed in to change notification settings - Fork 37
/
bot.py
47 lines (38 loc) · 1.35 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
import importlib
import discord
import winuvloop
from discord.ext import commands
import config
import database
winuvloop.install()
intents = discord.Intents(message_content=True, messages=True, guilds=True, emojis=True)
bot = commands.AutoShardedBot(command_prefix="https://www.youtube.com/watch?v=dQw4w9WgXcQ",
intents=intents,
member_cache_flags=discord.MemberCacheFlags.none(),
help_command=None,
max_messages=None,
chunk_guilds_at_startup=False)
@bot.event
async def setup_hook():
await bot.load_extension("main")
async def reload():
try:
await bot.unload_extension("main")
except commands.ExtensionNotLoaded:
pass
database.db.close()
importlib.reload(database)
database.db.connect()
await bot.load_extension("main")
bot.cat_bot_reload_hook = reload # pyright: ignore
database.db.connect()
if not database.db.get_tables():
database.db.create_tables([database.Profile, database.User, database.Channel, database.Prism])
if "prism" not in database.db.get_tables():
database.db.create_tables([database.Prism])
if "reminder" not in database.db.get_tables():
database.db.create_tables([database.Reminder])
try:
bot.run(config.TOKEN)
finally:
database.db.close()