This repository has been archived by the owner on Aug 20, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.py
64 lines (52 loc) · 1.65 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
# coding=utf-8
import asyncio
import uvloop
import discord
import statcord
from utils.config import load_config
from utils.bot_class import MyBot
from utils.models import init_db_connection
from cogs.help import BoatHelp
import sentry_sdk
try:
from blackfire import probe
except (ImportError, ModuleNotFoundError):
blackfire = False
else:
blackfire = True
asyncio.set_event_loop_policy(uvloop.EventLoopPolicy())
config = load_config()
if blackfire:
bf_config = config["auth"]["blackfire"]
probe.initialize(**bf_config)
probe.enable()
sentry_sdk.init(
config["auth"]["sentry"]["sentry_url"],
traces_sample_rate=1.0
)
if config['database']['enable']:
asyncio.ensure_future(init_db_connection(config['database']))
basic_intents = discord.Intents.none()
basic_intents.guilds = True
basic_intents.webhooks = True
basic_intents.messages = True
basic_intents.reactions = True
bot = MyBot(description=config["bot"]["description"], intents=basic_intents,
member_cache_flags=discord.MemberCacheFlags.from_intents(basic_intents))
bot.help_command = BoatHelp()
bot.blackfire = blackfire
stcd = statcord.Client(bot, config["auth"]["statcord"]["token"])
stcd.start_loop()
bot.statcord = stcd # best way i know of to make a global system
for cog_name in config["cogs"]["cog_reloader"]["cogs_to_load"]:
try:
bot.load_extension(cog_name)
bot.logger.debug(f"{cog_name} loaded!")
except Exception as e:
bot.logger.exception(f'Failed to load extension {cog_name}\n{type(e).__name__}: {e}')
try:
bot.run(config['auth']['discord']['token'])
finally:
if blackfire:
probe.disable()
probe.end()