import logging import sys from logging import Logger from pathlib import Path from discord import LoginFailure, Intents from libbot.sync import config_get as sync_config_get from classes.holo_bot import HoloBot from modules.scheduler import scheduler logging.basicConfig( level=logging.INFO, format="%(name)s.%(funcName)s | %(levelname)s | %(message)s", datefmt="[%X]", ) logger: Logger = logging.getLogger(__name__) try: import uvloop # type: ignore uvloop.install() except ImportError: pass def main() -> None: if not Path("config.json").exists(): logger.error( "Config file is missing: Make sure the configuration file 'config.json' is in place." ) sys.exit() intents: Intents = Intents().all() client: HoloBot = HoloBot(intents=intents, scheduler=scheduler) client.load_extension("cogs") try: client.run(sync_config_get("bot_token", "bot")) except LoginFailure as exc: logger.error("Provided bot token is invalid: %s", exc) except KeyboardInterrupt: logger.info("KeyboardInterrupt received: Shutting down gracefully.") finally: sys.exit() if __name__ == "__main__": main()