The Azeroth Herald bot has been refactored into a modular structure for better maintainability and organization.
AzerothHerald/
├── bot.py # Main bot entry point
├── dev_runner.py # Development runner with auto-reload
├── requirements.txt # Python dependencies
├── .env.example # Environment variables template
├── README.md # Project documentation
├── docs/ # Documentation files
│ ├── ARCHITECTURE.md # This file
│ ├── DEVELOPMENT.md # Development guide
│ └── test_commands.md # Command testing guide
└── src/ # Source code directory
├── __init__.py
├── commands/ # Individual command modules
│ ├── __init__.py
│ ├── affixes.py # !affixes command
│ ├── bluetrack.py # !bluetrack command (Blue Tracker monitoring)
│ ├── checklist.py # !checklist command
│ ├── cutoffs.py # !cutoffs command
│ ├── help.py # !help command
│ ├── test.py # !test command
│ ├── time.py # !time command
│ ├── warning.py # !warning command
│ └── wowhead_news.py # !news and !newssummary commands
├── utils/ # Utility functions
│ ├── __init__.py
│ ├── api.py # API calls (Raider.IO)
│ ├── blue_tracker.py # Blue Tracker scraping utility
│ ├── embeds.py # Discord embed creation
│ ├── error_handler.py # Centralized error handling
│ └── wowhead_news.py # Wowhead news scraping utility
└── tasks/ # Scheduled tasks
├── __init__.py
└── scheduler.py # Weekly posting scheduler with monitoring tasks
- Separation of Concerns: Each command is in its own file, making it easier to maintain and debug.
- Reusability: Utility functions can be shared across multiple commands.
- Easier Testing: Individual components can be tested in isolation.
- Better Organization: Related functionality is grouped together.
- Scalability: Adding new commands is as simple as creating a new file in the
src/commands/directory. - Clear Package Structure: The
src/directory creates a clear Python package hierarchy.
Blue Tracker and Wowhead News commands now include thematic banner images based on content keywords. This improves the visual appeal and relevance of the embeds.
With the new src/ directory structure, all imports follow a consistent pattern:
from src.tasks.scheduler import ScheduledTasks
from src.utils.error_handler import handle_command_errorfrom src.utils.embeds import create_checklist_embed
from src.utils.api import fetch_affixesfrom src.utils.embeds import create_checklist_embed, create_monday_warning_embedThis structure ensures that all modules can find each other correctly and maintains consistency across the project.
To add a new command:
- Create a new Python file in the
src/commands/directory (e.g.,newcommand.py) - Follow this template:
"""
New command for the Azeroth Herald bot.
"""
import discord
from discord.ext import commands
class NewCommand(commands.Cog):
def __init__(self, bot):
self.bot = bot
@commands.command(name='newcommand', help='Description of the new command.')
async def new_command(self, ctx):
"""Command implementation."""
embed = discord.Embed(
title="New Command",
description="This is a new command!",
color=discord.Color.blue()
)
await ctx.send(embed=embed)
async def setup(bot):
await bot.add_cog(NewCommand(bot))- Add the module name to the
command_moduleslist inbot.py:
command_modules = [
'src.commands.checklist',
'src.commands.warning',
'src.commands.time',
'src.commands.affixes',
'src.commands.cutoffs',
'src.commands.help',
'src.commands.test',
'src.commands.newcommand' # Add your new command here
]- Initializes the Discord bot
- Loads all command modules dynamically
- Sets up error handling
- Starts scheduled tasks
- Each command is a separate Discord.py Cog
- Follows consistent structure and naming
- Uses utility functions for common operations
- Import utilities using
from src.utils import ...
- embeds.py: Creates reusable Discord embeds
- api.py: Handles external API calls (Raider.IO)
- error_handler.py: Centralized error handling for commands
- scheduler.py: Manages scheduled posting (Monday warnings, Tuesday checklists)
- Imports utilities using
from src.utils import ...
The bot can be run using any of the existing methods:
python bot.py- VS Code task: "Run Discord Bot"
- Development runner:
python dev_runner.py
All existing functionality remains the same - the refactoring only improved the code organization without changing any user-facing features.