-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.py
45 lines (28 loc) · 1.08 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
#!/usr/bin/env python
"""
The main entrypoint into the running of TeX-Bot.
It loads the settings values from the .env file/the environment variables,
then ensures the Django database is correctly migrated to the latest version and finally begins
the asynchronous running process for TeX-Bot.
"""
from collections.abc import Sequence
__all__: Sequence[str] = ("bot",)
from typing import NoReturn
import discord
import config
from config import settings
from utils import SuppressTraceback, TeXBot
with SuppressTraceback():
config.run_setup()
intents: discord.Intents = discord.Intents.default()
# noinspection PyDunderSlots,PyUnresolvedReferences
intents.members = True
bot: TeXBot = TeXBot(intents=intents) # NOTE: See https://github.com/CSSUoB/TeX-Bot-Py-V2/issues/261
bot.load_extension("cogs")
def _run_bot() -> NoReturn: # NOTE: See https://github.com/CSSUoB/TeX-Bot-Py-V2/issues/261
bot.run(settings["DISCORD_BOT_TOKEN"])
if bot.EXIT_WAS_DUE_TO_KILL_COMMAND:
raise SystemExit(0)
raise SystemExit(1)
if __name__ == "__main__":
_run_bot()