AI-powered Discord bot that answers community questions using your docs, source code, and taught facts.
- Auto-answers questions — monitors channels and replies when @mentioned, with source citations
- Hybrid RAG pipeline — vector search + keyword matching + LLM query expansion for high retrieval accuracy
- Thread mode — replies in threads to keep channels clean (configurable: ephemeral / thread / inline)
- Teach the bot — add facts, corrections, or domain knowledge via
/lemonaidebot teach - Auto-discovers docs — fetches and indexes your repo's documentation on startup
- Works with any LLM — any OpenAI-compatible server (Ollama, LM Studio, vLLM, llama.cpp, Lemonade, or cloud APIs)
- Eval suite — 60-question test harness with LLM-as-judge grading to measure answer quality
- Bring your own project — point it at any repo and docs site; not tied to a specific project
- Node.js 20+
- A Discord bot — create one here
- An LLM server — Ollama, LM Studio, Lemonade, or any OpenAI-compatible endpoint
- An embedding model — for vector search (e.g.
nomic-embed-text)
git clone https://github.com/your-org/lemonaidebot.git
cd lemonaidebot
npm installcp .env.example .env
# Edit .env with your values| Variable | Description | Example |
|---|---|---|
DISCORD_BOT_TOKEN |
Bot token from Discord Developer Portal | MTQ5... |
DISCORD_CLIENT_ID |
Application client ID | 149691... |
LLM_BASE_URL |
LLM server endpoint | http://localhost:11434/v1 |
LLM_MODEL |
Chat model name | qwen3:8b |
LLM_PROVIDER |
API provider (openai for all local LLMs) |
openai |
DATABASE_URL |
Database connection string | file:./lemonaidebot.db |
PROJECT_NAME |
Your project name (used in answers) | My Project |
DOCS_URL |
Documentation site URL | https://docs.example.com |
SOURCE_REPO_URL |
Source repository URL | https://github.com/you/repo |
EMBEDDING_MODEL |
Embedding model for vector search | nomic-embed-text |
See .env.example for the full list with documentation.
npm run db:pushnpm run deploy-commandsnpm start
# or with auto-reload:
npm run devDiscord bot permissions required: Send Messages, Read Message History, Add Reactions, Create Public Threads, Send Messages in Threads, Manage Threads
| Command | Description |
|---|---|
/lemonaidebot help |
Show all commands |
/lemonaidebot teach |
Teach the bot a new fact or correction |
/lemonaidebot facts |
List all taught facts |
/lemonaidebot forget |
Remove a taught fact |
/lemonaidebot model |
View or switch the active LLM model |
/lemonaidebot settings |
Configure reply mode and thread settings (admin) |
/lemonaidebot cleanup |
Archive old bot threads |
/lemonaidebot refresh |
Refresh docs from GitHub and rebuild knowledge base |
/briefing channel |
Summarize recent activity in a channel |
/briefing day |
Daily summary of what was resolved |
LemonAIde uses a hybrid retrieval-augmented generation pipeline. When a question comes in, the LLM generates alternate search queries, then both vector search and keyword search run in parallel. Results are merged with a 60/40 vector/keyword weighting, and the top chunks are injected into the system prompt for answer generation.
User asks a question
│
▼
┌─────────────────┐
│ LLM Query │──→ Generates 3 alternate search queries
│ Expansion │
└────────┬────────┘
│
┌────┴────┐
▼ ▼
┌────────┐ ┌────────┐
│ Vector │ │Keyword │──→ Searches with expanded query terms
│ Search │ │ Search │
└───┬────┘ └───┬────┘
│ │
▼ ▼
┌─────────────────┐
│ Hybrid Merge │──→ 60/40 vector/keyword weighting + tier boost
│ + Force-Include│──→ High-priority docs always available
└────────┬────────┘
│
▼
┌─────────────────┐
│ Top 12 Chunks │──→ Injected into the system prompt
│ + Version Info │──→ Auto-extracted from repo
└────────┬────────┘
│
▼
┌─────────────────┐
│ LLM Answer │──→ JSON response with answer + source links
│ Generation │
└────────┬────────┘
│
▼
┌─────────────────┐
│ Post to Discord│──→ Ephemeral DM, thread, or inline reply
│ (configurable) │
└─────────────────┘
npm run eval # Full eval (60 questions)
npm run eval:quick # Quick eval (5 questions)
npm run eval -- --tag "my-test" # Tag a run for comparisonResults are saved to eval-results/ as JSON. Uses keyword matching as a fast first pass, then LLM-as-judge for semantic grading.
src/
ai/ # LLM client, prompts, knowledge base, vector store
commands/ # Discord slash commands
db/ # Prisma database client
discord/ # Embeds, buttons, modals, pagination
engines/ # Scanner engine (RAG pipeline)
models/ # Data models
utils/ # Logger, time, dedup, sanitize
scripts/ # Eval runner, docs fetcher
prompts/ # Markdown prompt templates
prisma/ # Database schema
test/ # Vitest test suite
All settings are documented in .env.example. Admin settings (reply mode, thread archive time, active model) can be changed at runtime via /lemonaidebot settings without restarting.
- Open an issue to discuss your idea before submitting a PR.
- Run
npm testto make sure tests pass. - PRs welcome — keep changes focused and include tests where applicable.