-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.py
43 lines (36 loc) · 1.26 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
import asyncio
import tracemalloc
import disnake
from disnake.ext import commands
from keys import get_keys
from models import Bot
DEV_MODE = True
if __name__ == "__main__":
tracemalloc.start()
intents = disnake.Intents.default()
intents.members = True # turn on privileged members intent
intents.messages = True
intents.message_content = True
# intents.presences = True # turn on presences intent
t_keys = get_keys()
options = {
"case_insensitive": True,
"owner_id": t_keys.bot_owner_id,
"intents": intents,
"test_guilds": None if not DEV_MODE else [t_keys.support_server_id],
"command_sync_flags": commands.CommandSyncFlags.all(),
"chunk_guilds_at_startup": DEV_MODE
}
loop = asyncio.get_event_loop()
bot = Bot(t_keys.bot_prefix, t_keys, dev_mode=DEV_MODE, **options)
try:
loop.run_until_complete(bot.run_api_before_bot())
except KeyboardInterrupt:
# cancel all tasks lingering.
loop.run_until_complete(bot.close())
# disconnect from the api.
loop.run_until_complete(bot.api.disconnect())
finally:
tracemalloc.stop()
... # we want the API to finish everything in the queue before closing the loop.
# loop.close()