Skip to main content
This guide walks you through setting up Annie Mei for local development.
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.95 or later - Install via rustup
  • PostgreSQL - For database storage
  • Redis - For caching API responses
  • SQLx CLI (optional) - For auth service schema work

Install SQLx CLI

Clone the Repository

1

Clone from GitHub

2

Install Dependencies

Rust dependencies are managed via Cargo.toml. Download and compile all dependencies:
This will take a few minutes on first run as it compiles all dependencies.

Configuration

Environment Variables

Create a .env file in the project root with the following variables:
  1. Go to Discord Developer Portal
  2. Create a new application
  3. Navigate to Bot section
  4. Click Reset Token and copy the token
  5. Copy the token into DISCORD_TOKEN
  1. Go to Spotify Developer Dashboard
  2. Create a new app
  3. Copy the Client ID and Client Secret
The current app startup expects SENTRY_DSN to be set. For local development, you can use a dummy DSN:
For production, sign up at sentry.io and create a Rust project.
  1. Set up the Auth service
  2. Use the same value for OAUTH_CONTEXT_SIGNING_SECRET in both services
  3. Set AUTH_SERVICE_BASE_URL to the auth service origin, for example https://auth.example.com
  4. Start the bot after both services are configured and reachable

Database Setup

1

Create PostgreSQL Database

Or using psql:
2

Run Migrations

The bot runs its own SQLx migrations at startup for settings tables. If you are testing /register, run the auth service once to apply its OAuth SQLx migrations to the shared database.
This step is optional for a bot-only local run. See the Database guide for more details.
3

Verify Schema

Check that the expected tables exist:

Redis Setup

Start a local Redis instance:
Verify Redis is running:

Running Locally

Development Mode

The repo includes a bacon.toml configuration. Install bacon once:
Then run the bot with auto-restart on code changes:
This runs the dev job by default, which executes cargo run and restarts the bot whenever a source file changes. Other useful jobs: You can also run a specific job directly:
To run the bot without bacon:
To enable detailed tracing:
Filter logs to specific modules:

Fast Type Checking

For quick feedback without running the bot:
This is much faster than cargo build and catches most errors.

Production Build

Compile an optimized release binary:
The binary will be at target/release/annie-mei.

Invite Bot to Test Server

Generate an OAuth2 invite link:
  1. Go to your app in Discord Developer Portal
  2. Navigate to OAuth2URL Generator
  3. Select scopes:
    • bot
    • applications.commands
  4. Select bot permissions:
    • Send Messages
    • Embed Links
    • Read Message History
  5. Copy the generated URL and open it in your browser
  6. Select your test server and authorize

Verify Installation

Once the bot is running and invited:
  1. Open Discord
  2. Type /ping in a channel
  3. The bot should respond with a greeting
If you see the response, your development environment is ready!

Troubleshooting

  • Check that DISCORD_TOKEN is correct
  • Check logs for connection errors: RUST_LOG=serenity=debug cargo run
  • 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
  • Verify PostgreSQL is running: pg_isready
  • Check DATABASE_URL format: postgresql://user:password@host/database
  • Ensure the database exists: psql -l | grep annie_mei
  • Verify Redis is running: redis-cli ping
  • Check REDIS_URL format: 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