-
Notifications
You must be signed in to change notification settings - Fork 0
API Reference
See also: Architecture-Overview | Module-Development | Services-Documentation
The main classes and functions you'll use:
from wisp_framework import WispBot, create_app, Module, ModuleRegistry
from wisp_framework.config import AppConfig
from wisp_framework.context import BotContext
from wisp_framework.lifecycle import LifecycleManagerImportant: There is no Wisp class. Use WispBot (the main bot class) or create_app() (convenience function) instead.
See also: Architecture-Overview | Module-Development | Services-Documentation
Main bot class for Wisp Framework, extending discord.ext.commands.Bot.
from wisp_framework import WispBotWispBot(
config: AppConfig,
services: ServiceContainer,
module_registry: ModuleRegistry,
ctx: BotContext
)Parameters:
-
config(AppConfig): Application configuration -
services(ServiceContainer): Service container instance -
module_registry(ModuleRegistry): Module registry instance -
ctx(BotContext): Bot context with services and config
Attributes:
-
config(AppConfig): Application configuration -
services(ServiceContainer): Service container -
module_registry(ModuleRegistry): Module registry -
ctx(BotContext): Bot context -
started_at(Optional[datetime]): Bot startup timestamp
Called when the bot is starting up. Syncs commands if configured.
Called when the bot is ready. Loads modules for all guilds.
Called when an app command completes successfully. Logs to audit service.
Called when the bot joins a new guild. Loads enabled modules for the guild.
Global error handler for app commands. Provides user-friendly error messages.
Abstract base class for framework modules.
from wisp_framework import ModuleModule name. Must be unique.
Whether the module is enabled by default. Default: True
Set of required service names. Default: set()
List of module names this module depends on. Default: []
Set up the module. Called when the module is loaded.
Parameters:
-
bot: The Discord bot instance -
ctx: Bot context with services and config
Tear down the module. Called when the module is unloaded. Default implementation does nothing.
Registry for managing framework modules.
from wisp_framework import ModuleRegistryModuleRegistry(feature_flags: FeatureFlags)Register a module.
Raises:
-
ValueError: If module name is already registered
Automatically discover and register modules from a package.
Parameters:
-
package_path: Python package path (e.g., 'wisp_framework.modules')
List all registered module names.
Get a module by name.
Load all enabled modules for a guild.
Parameters:
-
bot: The Discord bot instance -
ctx: Bot context with services and config -
guild_id: Guild ID (None for global modules)
Context object passed to modules with services and configuration.
from wisp_framework import BotContext-
config(AppConfig): Application configuration -
services(ServiceContainer): Service container -
guild_data(GuildDataService): Per-guild data storage service
Manages bot startup and shutdown lifecycle.
from wisp_framework.lifecycle import LifecycleManagerStart up the bot and all services.
Returns: Configured WispBot instance
Shut down the bot and all services gracefully.
Application configuration loaded from environment variables.
from wisp_framework import AppConfig-
discord_token: str- Discord bot token (required) -
database_url: Optional[str]- Database connection URL -
redis_url: Optional[str]- Redis connection URL -
log_level: str- Logging level (default: "INFO") -
sync_on_startup: bool- Whether to sync commands on startup (default: True) -
owner_id: Optional[int]- Bot owner Discord user ID -
welcome_channel_id: Optional[int]- Default welcome channel ID -
intents: discord.Intents- Discord gateway intents
Load environment variables from .env.{ENV} file.
Validate that all required environment variables are present.
Raises:
-
ConfigError: If required variables are missing
See Configuration-Reference for complete list.
Container for managing framework services.
from wisp_framework.services.base import ServiceContainerRegister a service with the container.
Raises:
-
ServiceError: If service name is already registered
Get a service by name.
Get a service by name with type checking.
Raises:
-
ServiceError: If service is not of the expected type
Start up all registered services.
Shut down all registered services.
List all registered service names.
See Services-Documentation for detailed service documentation.
Service for per-guild key-value data storage.
from wisp_framework.db.guild_data import GuildDataServiceStore a value for a guild.
Retrieve a value for a guild.
Delete a value for a guild.
Get all data for a guild (optionally filtered by module).
See Database Models for model documentation.
from wisp_framework.utils.embeds import EmbedBuilderSee Framework Extensions for details.
from wisp_framework.utils.responses import (
respond_success,
respond_error,
respond_info,
respond_embed
)See Framework Extensions for details.
from wisp_framework.utils.decorators import (
require_guild,
require_admin,
require_owner,
handle_errors
)See Framework Extensions for details.
from wisp_framework.utils.pagination import paginate_embedsSee Framework Extensions for details.
from wisp_framework.utils.cooldowns import cooldownSee Framework Extensions for details.
Base exception for framework errors.
Raised when configuration is invalid or missing required values.
Raised when a service operation fails.
Current framework version.
from wisp_framework import __version__Current version: 0.2.0
- Module-Development - Using these APIs in modules
- Services-Documentation - Detailed service documentation
- Configuration-Reference - Configuration options
- Architecture-Overview - Understanding the architecture
Create and configure a Discord bot application.
from wisp_framework import create_app
bot, lifecycle, ctx = create_app(
config=None,
auto_discover_modules=False,
module_package="wisp_framework.modules"
)Parameters:
-
config(Optional[AppConfig]): Optional AppConfig instance -
auto_discover_modules(bool): Whether to auto-discover modules -
module_package(str): Package path for module discovery
Returns: Tuple of (bot, lifecycle_manager, context)