bot.weakauras_bot module

WeakAuras Discord Bot - Core Bot Implementation

This module contains the main WeakAurasBot class which extends discord.py’s commands.Bot with WeakAuras-specific functionality including server-specific macro storage, configuration management, and administrative features.

The bot provides: - Server-isolated macro storage and retrieval - Role-based permission system - Automatic folder management with guild ID matching - Branded embed creation for consistent UI - Server configuration management

Example

Creating and running the bot:

config = {"discord": {"tokens": {"dev": "your_token"}}}
bot = WeakAurasBot(config)
bot.run(config["discord"]["tokens"]["dev"])
Module-level constants and imports for Discord bot functionality.
class bot.weakauras_bot.WeakAurasBot(config)[source]

Bases: Bot

WeakAuras Discord Bot with server-specific macro storage and management.

This bot extends discord.py’s commands.Bot to provide WeakAuras-specific functionality including macro storage, server configuration, and administrative features. Each Discord server gets its own isolated data storage.

config

Bot configuration dictionary.

Type:

dict[str, Any]

data_dir

Directory path for server data storage.

Type:

Path

Example

>>> config = {"storage": {"data_directory": "server_data"}}
>>> bot = WeakAurasBot(config)
>>> # Bot is now ready for command registration and startup
__init__(config)[source]

Initialize the WeakAuras bot with configuration.

Parameters:

config (dict[str, Any]) – Configuration dictionary containing bot settings, storage paths, and other options.

Example

>>> config = {
...     "storage": {"data_directory": "server_data"},
...     "bot": {"brand_color": 0x9F4AF3}
... }
>>> bot = WeakAurasBot(config)
sanitize_server_name(server_name)[source]

Sanitize server name for use as folder name

Return type:

str

get_server_folder(guild_id, guild_name)[source]

Get or create the server folder path, checking for existing folders by guild ID

Return type:

Path

get_server_macros_file(guild_id, guild_name)[source]

Get the macros file path for a specific server

Return type:

Path

load_server_macros(guild_id, guild_name)[source]

Load macros for a specific server

Return type:

dict[str, Any]

save_server_macros(guild_id, guild_name, macros)[source]

Save macros for a specific server

Return type:

None

get_server_config_file(guild_id, guild_name)[source]

Get the configuration file path for a specific server

Return type:

Path

load_server_config(guild_id, guild_name)[source]

Load configuration for a specific server

Return type:

dict[str, Any]

save_server_config(guild_id, guild_name, config)[source]

Save configuration for a specific server

Return type:

None

async is_event_enabled(guild_id, event_type)[source]

Check if a specific event is enabled for a server.

Checks Django database first, then falls back to JSON configuration.

Parameters:
  • guild_id (int) – Discord guild ID

  • event_type (str) – Type of event (e.g., “temperature”)

Returns:

True if event is enabled, False otherwise

Return type:

bool

has_admin_access(member)[source]

Check if member has admin access via role names or Discord permissions

Return type:

bool

create_embed(title=None, description=None, color=None, footer_text=None)[source]

Create a branded WeakAuras embed with logo attachment

Return type:

tuple[Embed, File | None]

async on_ready()[source]
async sync_commands()[source]

Sync slash commands with Discord