This page focuses on the main bot service. If you want to test
/register end to end, also set up the Auth service.Prerequisites
Ensure you have the following installed:- Rust 1.94 or later - Install via rustup
- PostgreSQL - For database storage
- Redis - For caching API responses
- Diesel CLI (optional) - For creating or running migrations manually during development
Install Diesel CLI
Clone the Repository
Configuration
Environment Variables
Create a.env file in the project root with the following variables:
Get a Discord Bot Token
Get a Discord Bot Token
- Go to Discord Developer Portal
- Create a new application
- Navigate to Bot section
- Click Reset Token and copy the token
- Copy the token into
DISCORD_TOKEN
Get Spotify API Credentials
Get Spotify API Credentials
- Go to Spotify Developer Dashboard
- Create a new app
- Copy the Client ID and Client Secret
Set up Sentry DSN
Set up Sentry DSN
The current app startup expects For production, sign up at sentry.io and create a Rust project.
SENTRY_DSN to be set. For local development, you can use a dummy DSN:Set up AniList OAuth linking
Set up AniList OAuth linking
- Set up the Auth service
- Use the same value for
OAUTH_CONTEXT_SIGNING_SECRETin both services - Set
AUTH_SERVICE_BASE_URLto the auth service origin, for examplehttps://auth.example.com - Start the bot after both services are configured and reachable
Database Setup
Run Migrations
Apply all database migrations using Diesel if you want to prepare the database before starting the bot:Annie Mei also runs embedded migrations automatically on startup, so this step is optional for a normal local run. See the Database guide for more details.
Redis Setup
Start a local Redis instance:Running Locally
Development Mode
The repo includes abacon.toml configuration. Install bacon once:
dev job by default, which executes cargo run and restarts the bot whenever a source file changes. Other useful jobs:
| Key | Job | What it does |
|---|---|---|
c | clippy-all | Run Clippy on all targets |
d | dev | Run and restart the bot on changes |
r | run-long | Same as dev, explicit alias |
p | pedantic | Run Clippy in pedantic mode |
Fast Type Checking
For quick feedback without running the bot:cargo build and catches most errors.
Production Build
Compile an optimized release binary:target/release/annie-mei.
Invite Bot to Test Server
Generate an OAuth2 invite link:- Go to your app in Discord Developer Portal
- Navigate to OAuth2 β URL Generator
- Select scopes:
botapplications.commands
- Select bot permissions:
- Send Messages
- Embed Links
- Read Message History
- Copy the generated URL and open it in your browser
- Select your test server and authorize
Verify Installation
Once the bot is running and invited:- Open Discord
- Type
/pingin a channel - The bot should respond with a greeting
Troubleshooting
Bot doesn't show online
Bot doesn't show online
- Check that
DISCORD_TOKENis correct - Check logs for connection errors:
RUST_LOG=serenity=debug cargo run
Slash commands not appearing
Slash commands not appearing
- Commands are registered globally and can take up to 1 hour to propagate
- For faster development, use guild-specific commands (requires code changes)
- Check logs for command registration errors
Database connection errors
Database connection errors
- Verify PostgreSQL is running:
pg_isready - Check
DATABASE_URLformat:postgresql://user:password@host/database - Ensure the database exists:
psql -l | grep annie_mei
Redis connection errors
Redis connection errors
- Verify Redis is running:
redis-cli ping - Check
REDIS_URLformat:redis://127.0.0.1:6379 - For password-protected Redis:
redis://:password@host:port
Next Steps
Architecture
Understand the project structure and technology stack
Adding Commands
Create your first slash command
Database
Learn database migration workflows
Testing
Run tests and ensure code quality
