"""Main file for Agon bot.""" import logging import os import sys import nextcord from nextcord.ext import commands from utilities import config logger = logging.getLogger("nextcord") logger.setLevel(logging.DEBUG) handler = logging.FileHandler(filename="nextcord.log", encoding="utf-8", mode="w") handler.setFormatter(logging.Formatter("%(asctime)s:%(levelname)s:%(name)s: %(message)s")) logger.addHandler(handler) def main() -> None: """Main function for bot.""" min_python_version = (3, 12) if sys.version_info < min_python_version: logger.error("ERROR: Python version must be >= 3.12") sys.exit() # Allows privileged intents for monitoring members joining, roles editing, and role assignments # These need to be enabled in the developer portal as well intents = nextcord.Intents.default() # Required in order to read messages (eg. prefix commands) intents.message_content = True # pylint: disable=assigning-non-slot bot = commands.Bot( commands.when_mentioned_or(config.BOT_PREFIX), intents=intents, ) # Get the modules of all cogs whose directory structure is ./cogs/ for folder in os.listdir("cogs"): bot.load_extension(f"cogs.{folder}") @bot.listen() async def on_ready() -> None: """When Discord is connected.""" if bot.user is not None: logger.debug("%s has connected to Discord!", bot.user.name) # Run Discord bot bot.run(config.DISCORD_TOKEN) if __name__ == "__main__": main()