"""Main file for bot.""" from __future__ import annotations import pathlib import nextcord from nextcord.ext import commands from off_cooldown_bot.open_raid import OpenRaid from .logger import ocd_logger from .settings import settings birthday_list: list[int] = [] def run() -> None: """Set config, intents, then connects the bot to discord.""" # 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 # To enable the guilds privileged intent: # intents.guilds = True # noqa: ERA001 # To enable the members privileged intent: intents.members = True bot = commands.Bot(intents=intents) # Get the modules of all cogs whose directory structure is ./cogs/ for folder in pathlib.Path("./off_cooldown_bot/cogs").iterdir(): bot.load_extension(f"off_cooldown_bot.cogs.{folder.name}") @bot.listen() async def on_ready() -> None: """When Discord is connected.""" if bot.user is None: ocd_logger.critical("Discord connection failed.") return bot.add_view(OpenRaid()) ocd_logger.info("%s has connected to Discord!", bot.user.name) # Run Discord bot bot.run(settings.params.discord_token)