Skip to main content

Bot Commands

Overview

Cross-platform custom command system. Users create commands in the dashboard, assign them to platforms, and bots execute them with template variable support, cooldowns, and automation triggers.

Command Types

TypeDescription
TextFixed text response
TemplateText with variables: {user}, {uptime}, {song}, {count}, {random:a,b,c}
AutomationTriggers an automation flow instead of sending text

Platform Assignment

Each command has a platforms JSON array. When creating, user selects which platforms the command is active on via checkboxes. Discord commands support both slash commands and prefix commands (configurable per command).

Permission Levels

Hierarchical — higher includes lower:

broadcaster > moderator > vip > subscriber > follower > everyone

Each bot maps platform-specific user data to this hierarchy.

Cooldowns

Redis-based, per-command:

  • Global: lumio:cmd_cd:{account_id}:{command_name}:global (TTL = cooldown seconds)
  • Per-user: lumio:cmd_cd:{account_id}:{command_name}:user:{user_id} (TTL = cooldown seconds)

Template Variables

Extensible via VariableResolver trait in crates/lo-bot-commands/:

VariableFeature GateDescription
{user}Display name of invoker
{channel}Channel/server name
{platform}Platform name
{uptime}Stream uptime (from Redis cache)
{song}widget:spotify_now_playingCurrently playing Spotify track
{count}Command use count
{random:a,b,c}Random selection from list

Adding new variables: implement VariableResolver trait + register in VariableRegistry.

Global Commands & Overrides

  • Global commands: account_id IS NULL, created by admins, inherited by all accounts
  • Account commands: account_id set, owned by specific account
  • Overrides: Accounts can override global commands (customize response, platforms, cooldowns) or disable them
  • Shadowing: Account commands with same name as globals take priority
  • Security: Overrides cannot make min_role less restrictive than global

Database

  • bot_commands — command definitions (global + account-scoped)
  • bot_command_overrides — per-account overrides of global commands
  • bot_command_stats — usage statistics (Redis live counter, periodic DB flush)

Shared Crate: lo-bot-commands

Used by all 5 bots:

  • context.rsCommandExecutionContext, UserRole, ApiCallback, CommandApiProvider
  • registry.rsLoadedCommand, AccountCommands, execute_command
  • permission.rs — Role hierarchy + checking
  • cooldown.rs — Redis cooldown check/set/increment
  • template.rs{variable} parser with right-to-left replacement
  • variables.rsVariableResolver trait, VariableRegistry, 7 built-in resolvers

Bot Integration

All 5 bots (Twitch, YouTube, Kick, Trovo, Discord):

  1. Load commands per account via botCommandsForAccount(accountId, platform) system query
  2. Store in-memory CommandStore (HashMap<AccountId, AccountCommands>)
  3. On chat message: check dynamic commands → permission → cooldown → execute
  4. command_sync Redis action triggers reload
  5. Discord: also registers slash commands per guild (bulk overwrite, 200/day rate limit)

API

TypeEndpointPermission
GraphQL QuerybotCommandsbot-commands:read
GraphQL MutationcreateBotCommand(input)bot-commands:create
GraphQL MutationupdateBotCommand(id, input)bot-commands:edit
GraphQL MutationdeleteBotCommand(id)bot-commands:delete
GraphQL MutationoverrideGlobalCommand(commandId, input)bot-commands:edit
GraphQL MutationremoveGlobalCommandOverride(commandId)bot-commands:delete
System QuerybotCommandsForAccount(accountId, platform)System key only

REST Endpoints

All paths live under /v1 and mirror the GraphQL mutations.

MethodPathPermissionDescription
GET/v1/bot-commandsbot-commands:readList account commands (+ inherited globals)
POST/v1/bot-commandsbot-commands:createCreate an account command
PUT/v1/bot-commands/{id}bot-commands:editUpdate a command
DELETE/v1/bot-commands/{id}bot-commands:deleteDelete a command
POST/v1/bot-commands/{id}/overridebot-commands:editOverride a global command for the account
DELETE/v1/bot-commands/{id}/overridebot-commands:deleteRemove the account's override of a global command

Plan Limits

TierMax Commands
Free25
Pro200
EnterpriseUnlimited

RBAC Permissions

Account: bot-commands:read/create/edit/delete Admin: bot-commands:read/create/edit/delete (via require_admin_permission)

Key Files

PathDescription
crates/lo-bot-commands/Shared command execution crate (context, registry, permission, cooldown, template, variables)
apps/api/src/db/bot_commands.rsDatabase operations
apps/api/src/graphql/bot_commands.rsGraphQL queries and mutations
apps/api/src/rest/bot_commands.rsREST endpoints

See Also