main module
WeakAuras Discord Bot - Main Entry Point
This module serves as the main entry point for the WeakAuras Discord bot. It handles configuration loading, command-line argument parsing, bot initialization, and command/event registration.
The bot is designed to facilitate common questions and FAQs for World of Warcraft addon support through Discord slash commands. Each Discord server has its own isolated macro and configuration storage.
Example
Run the bot in development mode (default):
$ python main.py
Run the bot in production mode:
$ python main.py --env prod
Use a custom configuration file:
$ python main.py --config my_config.yml
- main.None
Note
Requires a valid configuration file with Discord bot tokens. See settings/token.yml.example for the required format.
- main.load_config(config_path='/home/runner/work/python-wa-discord-bot/python-wa-discord-bot/discord-bot/settings/token.yml')[source]
Load configuration from YAML file with fallback locations.
- Parameters:
config_path (str) – Path to the YAML configuration file. Defaults to “settings/token.yml”.
- Returns:
Parsed configuration dictionary.
- Return type:
- Raises:
SystemExit – If the configuration file is not found in any location or contains invalid YAML syntax.
Example
>>> config = load_config("my_config.yml") >>> print(config["discord"]["tokens"]["dev"])
- main.get_token(config, environment)[source]
Get Discord token for the specified environment.
- Parameters:
- Returns:
Discord bot token for the specified environment.
- Return type:
- Raises:
SystemExit – If the environment is not found in config or if the token is not properly configured.
Example
>>> config = {"discord": {"tokens": {"dev": "your_token_here"}}} >>> token = get_token(config, "dev")
- main.main()[source]
Main entry point for the WeakAuras Discord Bot.
This function handles: - Command-line argument parsing - Configuration loading - Bot initialization - Command and event registration - Bot startup and error handling
- Return type:
- Command-line Arguments:
–env: Environment to run in (“dev” or “prod”, defaults to “dev”) –config: Path to configuration file (defaults to “settings/token.yml”)
- Raises:
SystemExit – If configuration is invalid or bot fails to start.
Example
This function is called when the script is run directly:
$ python main.py --env prod