-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
41 lines (34 loc) · 1.3 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
import sys
import logging
from discord import Intents, Activity, ActivityType
from tortoise import Tortoise
from discord.ext import commands
from sentry_sdk.integrations.aiohttp import AioHttpIntegration
import config
from constants import SENTRY_ENV_NAME, TORTOISE_ORM
from app.utils import use_sentry
if __name__ == "__main__":
# initialize bot params
intents = Intents.default()
intents.members = True
activity = Activity(type=ActivityType.playing, name="Covalent Roles")
bot = commands.Bot(command_prefix="!role.", help_command=None, intents=intents, activity=activity)
# init sentry SDK
use_sentry(
bot,
dsn=config.SENTRY_API_KEY,
environment=SENTRY_ENV_NAME,
integrations=[AioHttpIntegration()],
)
# setup logger
file_handler = logging.FileHandler(filename="covalent-role-sheet.log")
stdout_handler = logging.StreamHandler(sys.stdout)
logging.basicConfig(
level=logging.getLevelName(config.LOG_LEVEL),
format="%(asctime)s %(levelname)s:%(message)s",
handlers=[file_handler if config.LOG_TO_FILE else stdout_handler],
)
bot.load_extension("app.extensions.roles")
bot.load_extension("app.extensions.notifications")
bot.loop.run_until_complete(Tortoise.init(config=TORTOISE_ORM))
bot.run(config.TOKEN)