-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.py
executable file
·48 lines (32 loc) · 1.16 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
#!/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 typing import TYPE_CHECKING
import discord
import config
from config import settings
from utils import SuppressTraceback, TeXBot
if TYPE_CHECKING:
from collections.abc import Sequence
from typing import NoReturn
__all__: "Sequence[str]" = ("bot",)
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()