Skip to content

Config model ​

config.yaml is loaded into these pydantic models (ruby.config). Field by field explanations are on the Configuration page.

python
class Currency(BaseModel):
    currency: str = "points"


class Server(BaseModel):
    id: int = 0
    name: str = "Server"
    invite: str = "No invite link"
    channels: dict[str, int] = {}


class Config(BaseModel):
    # Bot identity
    name: str = "ruby"
    friendly_name: str = "Ruby"
    version: str = "v0.1.0"
    prefix: str = "r!"
    invite_link: str = "No invite link"
    owners: list[int] = []

    # Bot config
    statuses: list[str] | None = None  # null in config.yaml = no status; left out = "<friendly_name> <version>"
    status_interval: float = 60
    status: Literal["online", "offline", "idle", "dnd", "invisible"] = "online"
    strings: dict[str, str] = {}
    log_level: str | int = INFO
    embeds: bool = True

    # Cog config
    currency: Currency = Currency()
    cogs: dict[_YAMLKey, _YAMLValue] = {}

    # Server
    server: Server = Server()

load_config(path=Path("config.yaml")) -> Config ​

Reads and validates the file. Most code should call get_config() instead, which caches the result.