Skip to content

API Reference

Every public symbol in the rootbot package, grouped by area. The symbols below are the ones exported from rootbot itself or documented as public in their module. Signatures are the exact ones from the source. For narrative walkthroughs, see the Library Reference.

import rootbot

rootbot.__version__  # "0.2.0"

Bot

Bot

Bot(token: str | None = None, api: RootApi | None = None,
    config: BotConfig | None = None, clock: Callable[[], float] | None = None)

The framework core. Owns the API client, multi-community discovery and the polling loop, and dispatches chat commands to registered handlers. The core is voice-free: voice lives in rootbot.voice.session and rootbot.voice.player.

Parameters:

  • token: the account's session Bearer token. Falls back to config.token, then to load_token() when the bot starts.
  • api: a prebuilt client, usually a RootApi or a test double such as FakeRootApi. When given, token is not needed.
  • config: a BotConfig. Defaults to BotConfig(). The config is validated in the constructor and a bad value raises ConfigError.
  • clock: a monotonic time source used for cooldowns. Injectable so tests never sleep.

Public attributes: config, commands (name to Command, aliases included), communities (discovery state), cache (an EntityCache), self_id, self_name, running, and the api property, which raises ConfigError when no client is connected yet.

Bot.command

Bot.command(name: str | Callable | None = None, *, brief: str = "",
            usage: str = "", cooldown: float = 0.0, aliases: tuple = (),
            owner_only: bool = False) -> Callable

Decorator that registers an async command handler. Used bare (@bot.command) the command name is the function name; used with arguments (@bot.command("play", brief="...")) the given name wins. cooldown is per-user seconds, aliases registers extra names for the same handler, and owner_only restricts the command to BotConfig.owner_id. Returns the function unchanged.

Bot.event

Bot.event(fn: Callable | None = None, *, name: str | None = None) -> Callable

Decorator that registers an event handler. The event name comes from name or from the function name, and must be one of the names listed under Events. An unknown name raises ValueError.

Bot.on

Bot.on(event_name: str) -> Callable

Shortcut for Bot.event(name=event_name), for when the handler function is not named after the event: @bot.on("on_ready").

Bot.before_dispatch

Bot.before_dispatch(fn) -> fn

Registers a hook that runs with the Context before a command dispatches. A hook returning False vetoes the command. Usable as a decorator.

Bot.after_dispatch

Bot.after_dispatch(fn) -> fn

Registers a hook that runs with the Context after a command dispatches, whether the handler succeeded or raised. Usable as a decorator.

Bot.use

Bot.use(middleware: Middleware) -> Middleware

Appends a middleware to the dispatch pipeline. Middleware compose in registration order around the handler. Returns the middleware.

Bot.run

Bot.run() -> None

Blocking entry point. Runs Bot.start on a fresh asyncio loop and swallows KeyboardInterrupt.

Bot.start

async Bot.start() -> None

Async entry point. Resolves the token and client, discovers communities, primes the chat watcher, emits on_ready, then polls: fresh messages are dispatched, communities are rescanned every rescan_seconds, and voice presence is diffed when voice event handlers are registered. Handler and poll errors are logged, never fatal. Emits on_shutdown when the loop ends.

Bot.stop

Bot.stop() -> None

Asks the polling loop to stop at the next iteration.

Bot.dispatch

async Bot.dispatch(message: Message) -> bool

Runs one message through the full pipeline: emits on_message, checks the prefix, runs before hooks, the owner and cooldown checks, then the middleware pipeline and the handler. Returns True when the message was a command that was handled. A plain dict is accepted and converted with Message.from_dict. Conversion failures inside a handler are answered with a short Invalid argument: reply.

Bot.say

async Bot.say(container_id: str, text: str) -> str | None

Sends plain text to a container, split into chunks of at most config.message_limit characters. Returns the id of the last message sent, or None when the bot is not running yet.

Bot.help_text

Bot.help_text() -> str

Builds the help listing from the registered commands: one line per command with its prefix, usage and brief, sorted by name. This is what the auto-registered help command replies with.

Bot.discover

Bot.discover() -> tuple

Refreshes community and channel discovery and returns (communities, source), where source is "api" when ListMine answered and "config" when the config fallback was used. Results also fill the entity cache.

Bot.rescan

Bot.rescan() -> None

Re-runs discovery and reconciles the chat watcher with the result: new containers are primed and watched, removed containers are unwatched.

Bot.container_map

Bot.container_map() -> dict

Returns the current {container_id: community_id} mapping for every discovered channel.

Bot.get_channel

Bot.get_channel(container_id: str) -> Channel | None

Looks a channel up by container id: entity cache first, then the discovered state. Returns None when unknown.

Bot.get_community

Bot.get_community(community_id: str) -> Community | None

Looks a community up by id: entity cache first, then the discovered state. Returns None when unknown.

Bot.fetch_channel

async Bot.fetch_channel(community_id: str, container_id: str) -> Channel | None

Cache-miss fallback for Bot.get_channel: asks the API for the community's channels, caches them, and returns the matching one. Returns None when there is no client or the channel does not exist.

Bot.get_self

Bot.get_self() -> tuple

Returns (self_id, self_name) for the bot account. Triggers a GetSelf call and ignores its failure; the values are the ones recorded at startup.

Bot.emit

async Bot.emit(name: str, *args: Any) -> None

Calls every handler registered for the event name with args. A raising handler is logged and does not stop the others.

Bot.poll_presence_once

async Bot.poll_presence_once() -> list

Polls voice presence for every voice channel once, diffs it against the previous snapshot, and emits on_voice_join and on_voice_leave for the changes. Returns the list of (event_name, member) pairs. The first call only primes the snapshot, so members already present at startup produce no events. The bot account itself is skipped.

Context and commands

Context

Context(bot: Bot, message: Message, command: str, args: str)

What a command handler receives. Built by Bot.dispatch, not usually constructed by hand.

Attributes: bot, message (a Message), command (the name as typed), args (the raw argument string), arg_list (args split on whitespace), author_id, container_id, community_id, and the properties channel and community, which resolve through Bot.get_channel and Bot.get_community.

Context.reply

async Context.reply(text: str) -> str | None

Sends text to the channel the command came from. Returns the new message id, or None when the bot is not running.

Context.send

async Context.send(container_id: str, text: str) -> str | None

Sends text to an arbitrary container. Returns the new message id, or None when the bot is not running.

Context.arg_int

Context.arg_int(index: int) -> int

Parses argument index (zero-based) as an integer. Raises ConversionError when the argument is missing or not an integer.

Context.arg_float

Context.arg_float(index: int) -> float

Parses argument index as a float. Raises ConversionError when the argument is missing or not a number.

Context.arg_bool

Context.arg_bool(index: int) -> bool

Parses argument index as a boolean. Accepts true, yes, on, 1 and false, no, off, 0, case-insensitive. Raises ConversionError for anything else.

Context.arg_duration

Context.arg_duration(index: int) -> float

Parses argument index as a duration and returns seconds. Accepts a bare number or unit parts such as 5m and 1h30m. Raises ConversionError when the argument is missing or malformed.

Command

Command(name: str, handler: Callable[[Context], Awaitable[Any]],
        brief: str = "", usage: str = "", cooldown: float = 0.0,
        aliases: tuple = (), owner_only: bool = False)

Dataclass describing one registered command. Bot.command builds these; Bot.commands maps every name and alias to one. handler is the async callable that receives the Context.

Events

Handlers are registered with @bot.event or @bot.on(name). Each handler is awaited with the arguments below. Voice events come from polling presence and are best-effort: they are only polled when at least one voice handler is registered.

EventHandler receivesWhen
on_ready(bot)Once, after discovery and priming, before the poll loop.
on_message(message)For every fresh message, before prefix checks and dispatch.
on_voice_join(member)A user appears in a voice channel. member is a VoiceMember with channel_id and community_id set.
on_voice_leave(member)A user disappears from a voice channel. The member is the last seen snapshot.
on_tick(bot)Every poll loop iteration.
on_shutdown(bot)When the poll loop ends, for any reason.

Models

Typed dataclasses returned at every user-facing boundary, defined in rootbot.core.models. Each one also supports dict-style access through DictBridge: msg["content"], "id" in msg, msg.get("id"), msg.keys() and msg.to_dict(). Models marked with from_dict have a classmethod that builds one from a plain dict, ignoring unknown keys, which is what makes parsing tolerant of new payload fields.

Message

Message(id: str, user_id: str | None = None, user_name: str | None = None,
        content: str | None = None, container_id: str | None = None,
        community_id: str | None = None)

One chat message. user_name is only set when the author appears in the response's reference maps, otherwise None. Has from_dict.

Channel

Channel(id: str, name: str | None = None, type: int | None = None,
        members: list = [], community_id: str | None = None)

One channel. type is 1 for text and 4 for voice. A channel's id is also its message container id. members holds the user ids currently in the channel's voice, empty for text channels. Has from_dict.

Community

Community(id: str, name: str | None = None,
          default_channel_id: str | None = None)

One community (server) the account belongs to. Has from_dict.

User

User(id: str, name: str | None = None)

A user account. Has from_dict.

Role

Role(id: str, name: str | None = None, community_id: str | None = None)

A community role. Carried on Member.roles.

Member

Member(user_id: str, community_id: str | None = None,
       name: str | None = None, roles: list = [])

A user's membership of one community, with their roles in that community.

VoiceMember

VoiceMember(user_id: str, channel_id: str | None = None,
            community_id: str | None = None, is_muted: bool = False,
            is_deafened: bool = False, is_video: bool = False,
            is_screen: bool = False)

One user's presence in a voice channel, with the mute, deafen, video and screen-share flags reported by the presence call.

Track

Track(title: str, url: str, duration: int | None = None,
      author: str | None = None)

One playable track, as produced by the music helpers. duration is in milliseconds. Has from_dict.

Errors

All framework errors derive from RootBotError, defined in rootbot.errors. Catch RootBotError to catch everything the framework raises on purpose.

RootBotError

class RootBotError(Exception)

Base class for every framework error.

AuthError

class AuthError(RootBotError)

The API answered HTTP 401 or 403. In practice this means the token is dead: expired, revoked, or the account was logged out. Raised immediately, never retried.

APIError

APIError(message: str, status: int | None = None,
         service: str | None = None, method: str | None = None)

An API call failed after the retry policy ran out, or failed with a non-transient status. Carries status, service and method attributes naming the call that failed.

NotFoundError

class NotFoundError(APIError)

The API answered HTTP 404. Subclass of APIError, so it carries the same status, service and method attributes.

ConversionError

ConversionError(message: str, value: str | None = None,
                kind: str | None = None)

A converter could not parse its input. Carries the offending value and the converter kind (one of int, float, bool, duration, str, or argument for a missing argument). Dispatch turns a ConversionError escaping a handler into an Invalid argument: reply.

ConfigError

class ConfigError(RootBotError)

Invalid configuration, or an operation that needs a connected client before one exists.

TokenMissingError

class TokenMissingError(ConfigError)

No token was found in the environment, the .env file, or the constructor. The message tells you where to put one.

Configuration

Defined in rootbot.config.

BotConfig

BotConfig(token: str | None = None, prefix: str = "!",
          community_id: str | None = None, container_id: str | None = None,
          communities: list = [], error_reply: str | None = None,
          poll_seconds: float = 2.0, rescan_seconds: float = 60.0,
          owner_id: str | None = None, auto_help: bool = True,
          message_limit: int = 2000, cooldown_reply: str | None = None,
          extra: dict = {})

Dataclass holding every bot setting. community_id, container_id and communities are the discovery fallback seed, used when ListMine returns nothing. error_reply is sent when a handler raises (nothing is sent when it is None). cooldown_reply may contain {seconds} and is sent when a command is refused for cooldown. auto_help registers the built-in help command at startup. Unknown JSON keys loaded by load_config land in extra.

BotConfig.validate

BotConfig.validate() -> None

Raises ConfigError when the prefix is empty, poll_seconds is not positive, rescan_seconds is negative, or message_limit is under 100. Called by the Bot constructor and by load_config.

load_token

load_token(env_file: str | None = None) -> str

Reads ROOT_TOKEN from the environment, then from a .env file: the given env_file, or the candidates $ROOTBOT_ENV, ./.env and the repo root .env, in that order. Raises TokenMissingError when no token is found anywhere.

load_config

load_config(env_file: str | None = None,
            json_file: str | None = None) -> BotConfig

Builds a BotConfig from the token sources (see load_token), the ROOTBOT_OWNER_ID environment variable, and an optional JSON file. Known JSON keys set fields directly; unknown keys go to BotConfig.extra. A missing JSON file raises ConfigError. The result is validated before it is returned.

parse_dotenv

parse_dotenv(path: str | None) -> dict[str, str]

Parses a .env file into a dict. Blank lines and comments are skipped, surrounding quotes are stripped. A missing file parses to an empty dict.

dotenv_candidates

dotenv_candidates() -> list

Returns the .env paths load_token searches, in order.

Converters

Defined in rootbot.core.converters. Every converter raises ConversionError on bad input. These back the Context.arg_* methods, and can also be called directly.

convert

convert(kind: str, text: str) -> object

Runs the converter named by kind: one of int, float, bool, duration, str. An unknown kind raises ConversionError.

parse_int

parse_int(text: str) -> int

Parses a whole integer, optional sign included. Anything with a decimal point or other characters raises ConversionError.

parse_float

parse_float(text: str) -> float

Parses a float using Python's float() syntax.

parse_bool

parse_bool(text: str) -> bool

Accepts true, yes, on, 1 and false, no, off, 0, case-insensitive. Anything else raises ConversionError.

parse_duration

parse_duration(text: str) -> float

Parses a duration into seconds. Accepts a bare number (seconds) or unit parts with the units s, m, h, d, combined freely: 90, 5m, 2h, 1h30m, 1m15s.

parse_str

parse_str(text: str) -> str

The identity converter. Returns text unchanged.

Middleware

Defined in rootbot.core.middleware. A middleware is an async callable with the signature (ctx, nxt): call await nxt() to run the rest of the pipeline and ultimately the handler, or return without calling it to veto the command. Register middleware with Bot.use.

Middleware

Middleware = Callable[[Context, NextFn], Awaitable[object]]
NextFn = Callable[[], Awaitable[object]]

The middleware type alias, and the type of the nxt continuation passed to it.

logging_middleware

logging_middleware(logger: logging.Logger | None = None) -> Middleware

Logs each command's start, completion and raised errors through the framework logger, or through the given logger.

rate_limit_middleware

rate_limit_middleware(limit: int = 5, per_seconds: float = 60.0,
                      clock: Callable[[], float] | None = None,
                      reply: str | None = None) -> Middleware

Sliding-window rate limit per command and user: at most limit calls in any per_seconds window. Over-limit calls are dropped, and reply is sent when given. The clock is injectable so tests never sleep.

Testing

Defined in rootbot.testing. Test doubles that mirror the RootApi surface, so a Bot can run end to end with no network.

FakeClock

FakeClock(start: float = 1000.0)

A callable clock for tests. Calling it returns the current fake time; advance(seconds) moves it forward; sleep(seconds) records the sleep in sleeps and advances by the same amount. Pass it as Bot(clock=...) or to rate_limit_middleware.

FakeRootApi

FakeRootApi(self_id: str = "bot-user", communities: list | None = None,
            channels: dict | None = None, messages: dict | None = None,
            presence: dict | None = None)

In-memory stand-in for RootApi with the same method signatures. Seed it with Community and Channel models, scripted Message lists per container, and voice presence per (community_id, container_id) pair. Everything the bot sends is recorded on public attributes: sent, edited, pinned and deleted, each a list of tuples. Sent messages are also added to the message store, so a later poll can see them.

Test-facing helpers beyond the RootApi surface:

  • add_message(message): inserts a message at the head of a container's store, as if it just arrived.
  • set_presence(community_id, container_id, members): replaces the voice presence for one channel, to script join and leave events.
  • session_create(...) returns the fixed tuple (2, "wss://fake.invalid", "fake-jwt").

fake_community

fake_community(community_id: str, name: str = "Community") -> Community

Builds a Community model with the given id and name.

fake_channel

fake_channel(channel_id: str, name: str = "general", type: int = 1,
             community_id: str | None = None) -> Channel

Builds a Channel model. type defaults to 1 (text); pass 4 for a voice channel.

fake_message

fake_message(message_id: str, user_id: str, content: str,
             container_id: str, community_id: str,
             user_name: str | None = None) -> Message

Builds a Message model with every field set explicitly.

fake_voice_member

fake_voice_member(user_id: str, channel_id: str,
                  community_id: str) -> VoiceMember

Builds a VoiceMember model for presence scripting.

Client

Defined in rootbot.adapters.root.client. RootApi speaks grpc-web to https://api.rootapp.com with the account's Bearer token and hand-encoded protobuf bodies. Requests time out after 30 seconds.

RootApi

RootApi(token: str, retry: RetryPolicy | None = None,
        sleep: Callable[[float], None] | None = None,
        rand: Callable[[], float] | None = None)

Creates a client for one account. token is the bare session token, with no Bearer prefix. sleep and rand are the retry delay and jitter sources, injectable for tests. The token is registered with the logging redaction filter at construction.

RootApi.call

RootApi.call(service: str, method: str, payload: bytes) -> bytes | None

The one transport method everything else builds on. POSTs the grpc-web-framed payload to root.<service>/<method> and returns the deframed response body. Transient failures (HTTP 429, 500, 502, 503, 504 and connection errors) are retried under the retry policy. HTTP 401 and 403 raise AuthError, 404 raises NotFoundError, and other failures raise APIError once attempts run out.

RootApi.get_self

RootApi.get_self() -> bytes | None

Calls UserGrpcService/GetSelf with an empty payload and returns the raw response body.

RootApi.self_id

RootApi.self_id() -> str | None

Returns the account's own user id, parsed from the GetSelf response, or None when it cannot be read.

RootApi.list_communities

RootApi.list_communities() -> list[Community]

Calls CommunityGrpcService/ListMine and returns a Community model for every community the account belongs to.

RootApi.list_channels

RootApi.list_channels(community_id: str) -> list[Channel]

Calls CommunityGrpcService/GetExtended and returns the community's channels as Channel models.

RootApi.webrtc_members

RootApi.webrtc_members(community_id: str, container_id: str) -> list[str]

Read-only presence: the user ids currently in a voice channel, from WebRtcGrpcService/List. No join is required.

RootApi.webrtc_presence

RootApi.webrtc_presence(community_id: str,
                        container_id: str) -> list[VoiceMember]

The same presence call as webrtc_members, returning full VoiceMember models with the mute, deafen, video and screen flags.

RootApi.list_messages

RootApi.list_messages(container_id: str, community_id: str,
                      limit: int = 20) -> list[Message]

Calls v2.MessageGrpcService/List, newest first, and returns Message models. limit is clamped to the server's accepted range of 10 to 50.

RootApi.send_message

RootApi.send_message(container_id: str, community_id: str,
                     text: str) -> str | None

Calls v2.MessageGrpcService/Create and returns the new message's id, or None when the response carries none.

RootApi.edit_message

RootApi.edit_message(container_id: str, community_id: str,
                     message_id: str, text: str) -> str | None

Calls v2.MessageGrpcService/Edit, replacing the message content with text. Returns the message id, or None.

RootApi.delete_message

RootApi.delete_message(container_id: str, community_id: str,
                       message_id: str) -> bool

Calls v2.MessageGrpcService/Delete and returns True. Built from the mapped schema; not yet live-verified.

RootApi.pin_message

RootApi.pin_message(container_id: str, community_id: str,
                    message_id: str) -> bool

Calls v2.MessageGrpcService/PinCreate and returns True.

RootApi.list_pins

RootApi.list_pins(container_id: str,
                  community_id: str) -> list[Message]

Calls v2.MessageGrpcService/PinList and returns the pinned messages as Message models.

RootApi.session_create

RootApi.session_create(community_id: str,
                       container_id: str) -> tuple[int | None, str, str]

Calls WebRtcGrpcService/SessionCreate with supports_v2 = 1 and returns (backend, url, jwt): the backend selector varint, the LiveKit server URL, and the short-lived join JWT. Missing fields come back as empty strings rather than raising.

RetryPolicy

RetryPolicy(max_attempts: int = 3, base_delay: float = 0.5,
            max_delay: float = 8.0)

Dataclass controlling RootApi retries. delay_for(attempt, rand) returns the delay before the next attempt: exponential backoff from base_delay, capped at max_delay, scaled by jitter from the given random source.

Music and voice

Optional modules. The music example's helpers (examples/musicbot/music.py) use only the standard library; rootbot.voice.player needs the LiveKit Python SDK (livekit), which is an optional dependency of the package.

Lavalink(base_url: str = "http://127.0.0.1:2333",
         password: str | None = None,
         password_file: str | None = None)

Client for one Lavalink server, used by the music example to resolve and stream YouTube audio. Lavalink.from_env() builds one from the LAVALINK_BASE and LAVALINK_PASSWORD_FILE environment variables.

Lavalink.password() -> str

Resolves the server password: the constructor value first, then the LAVALINK_PASSWORD environment variable, then the password file. Raises SetupError (RB-E014) when none is configured; there is no default password file, and an unconfigured client never proceeds with an empty password. Lavalink.from_env() raises the same error when the environment configures no password.

Lavalink.available() -> bool

True when a password resolved, which is the framework's signal that Lavalink playback is usable.

Lavalink.fetch(identifier: str) -> dict

Calls GET /v4/loadtracks on the Lavalink server with the password header and returns the parsed JSON.

Lavalink.resolve(query: str) -> tuple[str | None, list]

Resolves a URL, video id or search terms into tracks. Plain terms become a ytsearch: query, and pasted Root link markup is unwrapped first. Returns (kind, tracks) where kind is "track", "search", "playlist" or None, and tracks are Track models.

Lavalink.search(query: str, limit: int = 5) -> list

The first limit tracks from Lavalink.resolve.

Lavalink.load(query: str) -> Track | None

The first track from Lavalink.resolve, or None.

Lavalink.open_stream(video_id: str) -> subprocess.Popen

Starts curl against the server's /youtube/stream/<video_id> endpoint with the password header and returns the process, whose stdout is the audio byte stream. Feed it to Player.stream_feed.

clean_query

clean_query(text: str | None) -> str | None

Normalises a pasted argument before resolution: extracts the first bare URL when one is present, unwraps Markdown link markup to its label when the whole text is a link, and otherwise returns the text stripped. None and empty input pass through unchanged.

youtube_id

youtube_id(url: str) -> str | None

Extracts the video id from youtu.be, watch, shorts, embed and live URLs. Returns None for anything else.

info_track

info_track(track: dict | None) -> Track | None

Normalises one Lavalink track object into a Track model. Returns None when the object has no URI.

Player

Player(url: str, jwt: str)

One LiveKit room connection publishing one audio track, from rootbot.voice.player. url and jwt come from RootApi.session_create. Audio throughout is 48 kHz, mono, s16le PCM in 20 ms frames (module constants SAMPLE_RATE = 48000, CHANNELS = 1, FRAME_MS = 20, SAMPLES_PER_FRAME = 960). Public attributes include gain (1.0 is 100 percent), paused, and last_elapsed, the pause-adjusted position captured when the last track ended.

Player.connect

async Player.connect() -> None

Joins the room and publishes a microphone-source audio track fed by an internal AudioSource.

Player.play_process

async Player.play_process(proc: subprocess.Popen) -> None

Pumps a PCM-producing process into the track, one 20 ms frame at a time, until its stdout ends or stop_current kills it. Honours paused and gain, and resets the position clock at the start.

Player.play_tone

async Player.play_tone(seconds: float = 10, freq: float = 440) -> None

Publishes a generated sine tone. The simplest end-to-end voice check.

Player.set_paused

Player.set_paused(value: bool) -> None

Pauses or resumes the pump. While paused the pump stops reading, so the producer blocks on its pipe and the position is preserved exactly.

Player.played_seconds

Player.played_seconds() -> float

Pause-adjusted elapsed seconds for the current track. Returns 0.0 when nothing is playing.

Player.to_pcm

Player.to_pcm(source_stdout: Any, seek: float = 0) -> subprocess.Popen

Wraps a byte stream in ffmpeg, decoding it to the standard PCM format, and returns the ffmpeg process. seek skips that many seconds into the stream, used to resume after an early end of stream.

Player.stream_feed

Player.stream_feed(feed_proc: subprocess.Popen,
                   seek: float = 0) -> subprocess.Popen

Registers an arbitrary producer process (for example the curl stream from Lavalink.open_stream) as the current feed and returns its PCM pump process from to_pcm.

Player.stream_ytdlp

Player.stream_ytdlp(url: str, seek: float = 0) -> subprocess.Popen

Starts yt-dlp -f bestaudio for a URL (the binary next to the Python executable first, then PATH) and returns its PCM pump process.

Player.stop_current

Player.stop_current() -> None

Kills the pump and feed processes and clears the pause state.

Player.disconnect

async Player.disconnect() -> None

Stops the current track and leaves the room.

scale_pcm

scale_pcm(data: bytes, gain: float) -> bytes

Module-level helper in rootbot.voice.player. Multiplies s16le samples by gain, clamping to the int16 range. This is how Player.gain is applied, per frame.

Entity cache

Exported from rootbot and defined in rootbot.core.cache.

EntityCache

EntityCache(maxsize: int = 1024)

Bounded LRU cache for entity models, keyed by kind and id. Bot owns one and fills it from discovery and dispatch. Typed helpers: put_user / get_user, put_channel / get_channel, put_community / get_community, put_member / get_member, plus the generic put(kind, entity_id, entity), get(kind, entity_id), discard(kind, entity_id), clear(), and len() support.