Bot Control
Overview
The Bot Control dashboard allows users to manage their chat bots across all platforms (Twitch, YouTube, Kick, Trovo) and Discord servers from a single page. Users can pause/resume bots per platform, trigger reconnects, and manage Discord server connections with feature-channel mappings.
Chat Bot Control
Per-platform bot management at /dashboard/bots:
- Status: Active (bot_enabled=true + channel connection exists), Paused (bot_enabled=false), No Connection
- Toggle: Pause/Resume bot for a platform via
toggleBotForPlatformmutation (updatesbot_enabledonchannel_connections) - Reconnect: Send
bot_joinaction via Redis pub/sub to trigger immediate channel rejoin
Database
channel_connections.bot_enabled (BOOLEAN, default true) — when false, bots ignore this channel during sync.
API
| Type | Endpoint | Permission |
|---|---|---|
| GraphQL Query | botStatus | bot-connections:read |
| GraphQL Mutation | toggleBotForPlatform(platform, enabled) | bot-connections:create |
| GraphQL Mutation | rejoinBot(platform) | bot-connections:create |
| REST | GET /bot-status | bot-connections:read |
| REST | POST /bot-toggle | bot-connections:create |
| REST | POST /bot-rejoin | bot-connections:create |
| System Query | botChannels(platform) | System key only |
Bot Worker Actions
All chat bots listen for Redis pub/sub actions on lumio:bot:action:{platform}:{account_id}:
bot_join/bot_sync— Log and let periodic sync apply changesbot_leave— Immediately remove account's channels from in-memory map + clear Redis cache
Discord Server Mapping
Discord guilds are mapped to Lumio accounts via discord_guild_connections table.
Tables
discord_guild_connections— guild_id → account_id mapping (UNIQUE on guild_id)discord_guild_settings— per-guild JSONB settingsdiscord_guild_channel_mappings— feature → Discord channel routing (live_notification, event_feed, chat_mirror, etc.)
OAuth Flow
- User clicks "Add Server" →
authorizeDiscordGuildmutation generates Discord OAuth URL - Discord redirects to
/api/discord-guilds/callback - Callback calls
exchangeDiscordGuildmutation viaserverGql - Guild connection created in DB
- Discord bot receives
GuildCreateevent → caches channels/roles/features in Redis, updates guild name/icon in DB
Redis Cache
| Key | Content | TTL |
|---|---|---|
lumio:discord_guild:{guild_id} | account_id | 1h |
lumio:discord_guild:{guild_id}:channels | JSON array of channels | 1h |
lumio:discord_guild:{guild_id}:roles | JSON array of roles | 1h |
lumio:discord_guild:{guild_id}:features | JSON array of feature mappings | 1h |
lumio:discord_channel_guild:{channel_id} | guild_id (reverse lookup) | 1h |
Feature-Channel Mappings
Predefined features (extensible without migration):
| Feature Key | Description |
|---|---|
live_notification | Stream live alerts |
event_feed | Follows, subs, donations |
chat_mirror | Platform chat → Discord |
announcement | Announcements |
moderation_log | Ban/timeout logs |
clip_feed | New clips |
API
| Type | Endpoint | Permission |
|---|---|---|
| GraphQL Query | discordGuildConnections | bot-connections:read |
| GraphQL Mutation | authorizeDiscordGuild | bot-connections:create |
| GraphQL Mutation | exchangeDiscordGuild(...) | bot-connections:create |
| GraphQL Mutation | disconnectDiscordGuild(guildId) | bot-connections:delete |
| GraphQL Query | discordGuildChannels(guildId) | bot-connections:read |
| GraphQL Query | discordGuildRoles(guildId) | bot-connections:read |
| GraphQL Query | discordGuildFeatures(guildId) | bot-connections:read |
| GraphQL Mutation | setDiscordGuildFeature(...) | bot-connections:create |
| System Query | discordBotGuilds | System key only |
| System Mutation | updateDiscordGuildInfo(...) | System key only |
| System Mutation | removeDiscordGuildByBot(guildId) | System key only |
Admin
Admin permissions: bot-control:read/edit, discord-guilds:read/delete (enforced via require_admin_permission).
/admin/bot-control— View/toggle bots per account/admin/discord-guilds— View all guild-to-account mappings, delete connections
Security
- Guild ownership verified before channel/role queries
- Channel ownership verified in Discord bot actions (post_message)
- GuildDelete with
unavailable=trueonly cleans cache, preserves DB - Admin middleware on API routes
- Snowflake validation on all Discord IDs
- UUID validation on action listener account_id
Key Files
| Path | Description |
|---|---|
apps/api/src/graphql/bot_connections.rs | GraphQL queries and mutations for bot status/toggle/rejoin |
apps/api/src/graphql/discord_guilds.rs | GraphQL for Discord guild management |
apps/api/src/db/discord_guilds.rs | Database operations for Discord guilds |
apps/discord-bot/src/handlers/events.rs | Discord bot gateway event handling |
crates/lo-bot-modules/ | Bot module system used by all chat bots |
See Also
- Bot Connections — Custom bot identity OAuth flow
- Bot Commands — Dynamic command system for all bots
- Bot Modules — Chat moderation modules
- Provider Management — Feature flag controls