2023-05-02 15:46:15 +02:00
|
|
|
import logging
|
2024-12-16 20:34:37 +01:00
|
|
|
import sys
|
|
|
|
from logging import Logger
|
2024-12-17 22:14:06 +01:00
|
|
|
from pathlib import Path
|
2023-05-02 15:46:15 +02:00
|
|
|
|
2024-12-17 22:14:06 +01:00
|
|
|
from discord import LoginFailure, Intents
|
2024-12-26 19:12:50 +01:00
|
|
|
from libbot.utils import config_get
|
2023-05-02 15:46:15 +02:00
|
|
|
|
2024-12-17 22:14:06 +01:00
|
|
|
from classes.holo_bot import HoloBot
|
2024-12-16 20:59:10 +01:00
|
|
|
from modules.scheduler import scheduler
|
2023-05-02 15:46:15 +02:00
|
|
|
|
|
|
|
logging.basicConfig(
|
|
|
|
level=logging.INFO,
|
|
|
|
format="%(name)s.%(funcName)s | %(levelname)s | %(message)s",
|
|
|
|
datefmt="[%X]",
|
|
|
|
)
|
|
|
|
|
2024-12-16 20:34:37 +01:00
|
|
|
logger: Logger = logging.getLogger(__name__)
|
2023-05-02 15:46:15 +02:00
|
|
|
|
|
|
|
try:
|
2023-05-04 16:14:33 +02:00
|
|
|
import uvloop # type: ignore
|
2023-05-02 15:46:15 +02:00
|
|
|
|
|
|
|
uvloop.install()
|
|
|
|
except ImportError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2024-12-17 22:14:06 +01:00
|
|
|
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."
|
2023-05-06 19:06:04 +02:00
|
|
|
)
|
2024-12-17 22:14:06 +01:00
|
|
|
sys.exit()
|
2023-05-04 16:14:33 +02:00
|
|
|
|
2024-12-17 22:14:06 +01:00
|
|
|
intents: Intents = Intents().all()
|
|
|
|
client: HoloBot = HoloBot(intents=intents, scheduler=scheduler)
|
2023-05-02 15:46:15 +02:00
|
|
|
|
2024-06-23 12:05:03 +02:00
|
|
|
client.load_extension("cogs")
|
2023-05-04 16:09:47 +02:00
|
|
|
|
2023-05-02 15:46:15 +02:00
|
|
|
try:
|
2024-12-26 19:12:50 +01:00
|
|
|
client.run(config_get("bot_token", "bot"))
|
2024-12-17 22:14:06 +01:00
|
|
|
except LoginFailure as exc:
|
|
|
|
logger.error("Provided bot token is invalid: %s", exc)
|
2023-05-02 15:46:15 +02:00
|
|
|
except KeyboardInterrupt:
|
2024-12-17 22:14:06 +01:00
|
|
|
logger.info("KeyboardInterrupt received: Shutting down gracefully.")
|
|
|
|
finally:
|
2024-12-16 20:34:37 +01:00
|
|
|
sys.exit()
|
2023-05-02 15:46:15 +02:00
|
|
|
|
2023-05-04 16:14:33 +02:00
|
|
|
|
2023-05-02 15:46:15 +02:00
|
|
|
if __name__ == "__main__":
|
2023-05-04 16:14:33 +02:00
|
|
|
main()
|