A feature-rich Discord bot written in Rust that brings AI-powered character chat, image generation, and content discovery to your server.
Have one-on-one conversations with customizable AI characters. Each character has a name, title, and personality traits defined in a configuration file.
- Persistent chat history per user per character
- Relationship system with dynamic likability tracking that influences character responses
- Web reference citations included in AI responses
- Daily usage limit per user
Start a group conversation between two or more AI characters on a given theme and watch them interact with each other in-character.
Generate images from text prompts. Daily usage limit per user.
Fetch random videos from a YouTube channel by providing its handle (e.g. @channel). Displays title, view count, duration, publish date, and link.
Fetch random clips from a Twitch streamer by providing their user ID. Displays title, view count, duration, creation date, and link.
/ping— Check bot status/choices— Randomly pick from a list of user-provided options
The project follows clean architecture principles with a Cargo workspace of four crates:
src/ Presentation layer (Discord command & modal handlers)
application/ Use cases and gateway/repository trait definitions
domain/ Business models and value objects
infrastructure/ Concrete implementations (API clients, in-memory repositories)
common/ Shared utilities (i18n, caching, collections)
Key design decisions:
- Dependency inversion — Traits are defined in
application/, implementations live ininfrastructure/ - In-memory storage — All state (chat history, activity counters, relationships) is currently held in
DashMapas a provisional implementation without transaction management. A migration to an RDBMS with proper transaction support is planned. - Localization — All user-facing strings are managed via Fluent (
.ftlfiles) with Japanese as the primary locale
- Rust 1.90.0 (pinned via
rust-toolchain.toml) - API keys for the external services (see Configuration)
Copy the template and fill in your credentials:
cp .env.template .env| Variable | Description |
|---|---|
DISCORD_TOKEN |
Discord bot token |
DISCORD_BOT_APPLICATION_ID |
Discord application ID |
GEMINI_API_KEY |
Google Gemini API key |
OPENAI_API_KEY |
OpenAI API key (for image generation) |
YOU_TUBE_DATA_API_KEY |
YouTube Data API v3 key |
TWITCH_APP_CLIENT_ID |
Twitch application client ID |
TWITCH_APP_CLIENT_SECRET |
Twitch application client secret |
LOGGING_WEB_HOOK_URL |
Discord webhook URL for error logging |
AI characters are configured in resource/character.toml. Copy the template to get started:
cp resource/character.toml.template resource/character.tomlEach character entry has the following fields:
[[characters]]
name = "Character Name"
title = "Title"
characteristics = ["trait1", "trait2", "trait3"]You can override any localized string by creating resource/locale/ja-JP.override.ftl. This file is gitignored and will not be committed.
cargo build --release
cargo runProduction:
docker build -t discord-bot .
docker run --env-file .env discord-botDevelopment (with Docker Compose):
docker compose up --buildThe development setup mounts the project directory and caches Cargo dependencies in a named volume for faster rebuilds.
The project includes a .railwayignore for deployment on Railway.
| Category | Technology |
|---|---|
| Language | Rust (Edition 2024) |
| Discord Library | Serenity |
| Async Runtime | Tokio |
| AI Text Generation | Google Gemini API |
| AI Image Generation | OpenAI API |
| HTTP Client | reqwest |
| Data Storage | In-memory (DashMap) |
| Localization | Fluent (Japanese) |
| Logging | tracing / tracing-subscriber |
This document was generated by Claude Opus 4.6 on Claude Code and reviewed and adjusted by @voidCaffeLatte.