This document describes how to configure Mirrobot for your Discord server.
- Create a Discord bot application from the Discord Developer Portal
- Copy your bot token and add it to the
.envfile or directly intoconfig.json - Invite the bot to your server using the generated OAuth2 URL
The main configuration file is config.json. You can copy config_example.json as a starting point. Here's what each field means:
{
"token": "See environment variable DISCORD_BOT_TOKEN", // Your Discord bot token (RECOMMENDED: Use environment variable)
"command_prefix": "!", // Default command prefix
"ocr_worker_count": 2, // Number of parallel OCR workers
"ocr_max_queue_size": 100, // Maximum OCR queue size
"thread_purge_interval_minutes": 10, // How often to purge old thread data
"ocr_read_channels": {}, // Channels where OCR scanning is active
"ocr_response_channels": {}, // Channels where OCR responses are sent
"ocr_response_fallback": {}, // Fallback channels for OCR responses
"server_prefixes": {}, // Server-specific command prefixes
"command_permissions": {}, // Command permission settings
"ocr_channel_config": {}, // OCR language settings per channel
"maintenance": { // Auto-restart and maintenance settings
"restart_threshold_seconds": 86400, // Auto-restart after 24 hours
"check_interval_minutes": 15, // Check interval for restart conditions
"auto_restart_enabled": true // Enable automatic restarts
}
}- token: Your Discord bot token. STRONGLY RECOMMENDED to use the
DISCORD_BOT_TOKENenvironment variable instead - ocr_read_channels: Format:
{"guild_id": [channel_id1, channel_id2]}- Channels to monitor for images - ocr_response_channels: Format:
{"guild_id": [channel_id1, channel_id2]}- Where to send OCR results - ocr_response_fallback: Format:
{"guild_id": [channel_id1, channel_id2]}- Backup channels if primary unavailable - server_prefixes: Format:
{"guild_id": "prefix"}- Custom prefixes per server (e.g.,"ocr!") - command_permissions: Format:
{"guild_id": {"command": ["role_id1"]}}- Role-based command access - ocr_channel_config: Format:
{"guild_id": {"channel_id": {"lang": "eng"}}}- Language per channel
The bot can be configured to re-upload Discord media attachments to third-party services to prevent links from expiring. This is useful for preserving conversation history that is passed to the LLM.
- media_caching:
- enabled:
trueorfalse. Enables or disables the media caching feature. - services: A list of services to use for uploading. Supported services are
"litterbox","catbox", and"pixeldrain". - upload_timeout_seconds: The timeout in seconds for each upload attempt.
- permanent_host_fallback:
trueorfalse. Iftrue, the bot will fall back to a permanent host if the temporary host (litterbox) fails. - pixeldrain_api_key: Your API key for the Pixeldrain service.
- catbox_user_hash: Your user hash for the Catbox service.
- enabled:
RECOMMENDED APPROACH: Use environment variables for sensitive data:
- Create a
.envfile based on the.env.exampletemplate - Add your Discord bot token:
DISCORD_BOT_TOKEN=your_token_here - Optionally add Google AI API key:
GOOGLE_AI_API_KEY=your_key_here
The bot will automatically use environment variables when available, overriding config file values.
To enable OCR in specific channels:
- Use
!add_ocr_read_channel #channel-nameto add a channel for OCR scanning - Use
!add_ocr_response_channel #channel-nameto designate where responses go - Optionally set language:
!set_ocr_language #channel-name eng(eng = English, rus = Russian)
- Increase
ocr_worker_countfor faster processing (but higher CPU usage) - Adjust
ocr_max_queue_sizebased on your server's activity level
Patterns are stored in patterns.json. Each pattern associates a regex pattern with a response.
You can manage patterns using:
!add_response "response text" "name" "note"!add_pattern_to_response "response-name" "regex pattern" "IGNORECASE|DOTALL"!remove_pattern_from_response "response-name" pattern_id
Manage command permissions:
!add_command_role @role command_name- Give a role permission to use a command!remove_command_role @role command_name- Remove permission!add_bot_manager @role- Give a role access to all non-system commands
- Change the command prefix:
!set_prefix $ - Reset to default prefix:
!reset_prefix - View all server settings:
!server_info