Settings & Config
SoSad uses pydantic-style settings via BaseSettings.
Basic usage
from sosad import Settings
class Config(Settings):
token: str
prefix: str = "!"
debug: bool = False
database_url: str = "sqlite:///bot.db"
Environment variables
Settings are loaded from .env automatically:
# .env
TOKEN=your-discord-bot-token
PREFIX=!
DEBUG=true
DATABASE_URL=postgresql://localhost:5432/bot
Using in commands
@sosad.slash_command("config", "Show config")
async def show_config(ctx: sosad.InteractionContext) -> None:
config = Config()
await ctx.respond(f"Prefix: {config.prefix}, Debug: {config.debug}")