2023-05-07 14:00:46 -06:00
|
|
|
import tomllib
|
|
|
|
|
import os
|
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
from bot import Bot
|
|
|
|
|
from utils import Config
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidTokenException(Exception):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2023-05-07 21:25:44 -06:00
|
|
|
class InvalidConfigException(Exception):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2023-05-07 14:00:46 -06:00
|
|
|
def main() -> None:
|
|
|
|
|
DISCORD_TOKEN = os.getenv("DISCORD_TOKEN")
|
|
|
|
|
if not DISCORD_TOKEN:
|
|
|
|
|
raise InvalidTokenException("A Discord token was not set.")
|
|
|
|
|
|
|
|
|
|
with open("config.toml", "rb") as config_file:
|
2023-05-07 21:25:44 -06:00
|
|
|
if "[permissions]" in config_file.read():
|
|
|
|
|
raise InvalidConfigException(
|
|
|
|
|
"The format for permissions has changed; please check the new example config."
|
|
|
|
|
)
|
|
|
|
|
|
2023-05-07 14:00:46 -06:00
|
|
|
config = Config(tomllib.load(config_file))
|
|
|
|
|
|
|
|
|
|
bot = Bot(config)
|
|
|
|
|
bot.run(DISCORD_TOKEN)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
load_dotenv()
|
|
|
|
|
main()
|