Discord bot with an AI agent that can manage roles, channels, permissions, and more via natural language commands.
# Backend
cd backend
uv sync --dev
uv run python server.py # FastAPI + Discord bot on :8000
# Frontend (separate terminal)
cd frontend
npm install
npm run dev # React SPA on :5173
Copy backend/.env and fill in:
| Variable | Description |
|---|---|
DISCORD_BOT_TOKEN |
Bot token |
DISCORD_CLIENT_ID, DISCORD_CLIENT_SECRET |
Discord OAuth2 app |
JWT_SECRET |
Secret for JWT tokens |
GOOGLE_AI_API |
Gemini API key (fallback LLM) |
x0auto to activate agent modehttp://localhost:5173/links page) → key saved to api_links DB tablex0auto command: key fetched via get_user_api_key(user_id, "openrouter") and stored in the agent stateagent_core/agent.py:get_llm()):get_user_api_key() from DBChatOpenAI with that key (OpenRouter endpoint)backend/
├── server.py # Entry point — starts FastAPI + Discord bot
├── app/
│ ├── api.py # FastAPI routes (auth, sessions, links)
│ ├── bot.py # Discord bot (commands, message handler)
│ ├── database.py # SQLite via SQLAlchemy async
│ ├── agent_core/
│ │ ├── agent.py # LangGraph agent + LLM setup
│ │ ├── models.py # Agent state schema
│ │ ├── prompts.py # System prompts
│ │ └── tools/ # Discord tool implementations
│ └── auth.py # Discord OAuth2
frontend/ # Vite + React SPA