Claude Code Discord Bot - A Discord bot that proxies Claude Code sessions to Discord channels, allowing multiple users to interact with Claude AI through Discord.
This bot enables Discord users to interact with Claude Code (claude.ai/code) directly within Discord channels. It manages Claude CLI sessions, forwards messages between Discord and Claude, and supports multiple concurrent sessions across different bot instances.
- Claude Code Proxy: Forward Discord messages to Claude CLI and stream responses back.
- Session Management: Start, stop, and resume Claude sessions within Discord channels.
- Multi-Instance Support: Run multiple bot instances with separate session namespaces.
- Session Persistence: Resume sessions using session IDs after bot restarts.
- Command Forwarding: Claude CLI commands like
/helpand/modelwork seamlessly.
- Slash Commands: Modern Discord slash command structure.
- Rate Limiting: Built-in cooldowns to prevent spam.
- Multi-Language Support: Internationalization using Linguini.
- Welcome Messages: Automated messages when joining servers.
- Server Statistics: Shows server count in bot status.
- TypeScript: Fully typed codebase for better development experience.
- discord.js v14: Uses the latest Discord.js framework.
- ESM Modules: Modern JavaScript module system.
- Testing: Vitest test suite with coverage reports.
- Linting & Formatting: ESLint and Prettier configured.
- Docker Support: Containerization ready.
- PM2 Support: Process management for production.
- Sharding: Automatic sharding for 2500+ server deployments.
- Clustering: Multi-machine deployment support.
- HTTP API: Inter-process communication for distributed setups.
Starts a new Claude Code session in the current channel. The bot will create a new Claude CLI process and begin forwarding messages.
Stops the active Claude session in the current channel. The session can be resumed later using its session ID.
Resumes a previously stopped Claude session. Useful after bot restarts or to continue conversations in different channels.
Get help on different areas of the bot or contact support. Includes categories for different topics.
Get information about the bot, including version, uptime, and useful links.
A simple test command to verify the bot is working correctly.
Developer-only command showing technical information about the bot instance.
- View Date Sent: Right-click a message to see when it was sent.
- View Date Joined: Right-click a user to see when they joined the server.
- Node.js 18.x or higher
- npm or yarn
- Claude CLI installed and configured (for Claude features)
- Discord Bot Token
-
Clone the repository:
git clone <repository-url> cd ccdiscord
-
Install dependencies:
npm install
-
Configure the bot:
- Navigate to the
configfolder - Copy all
.example.jsonfiles and remove the.examplesuffix:config.example.json→config.jsonbot-sites.example.json→bot-sites.jsondebug.example.json→debug.json
- Navigate to the
-
Set up Discord Bot:
- Create a new application in the Discord Developer Portal
- Create a bot and copy the token
- Enable the following intents:
- Server Members Intent
- Message Content Intent
- Edit
config/config.json:- Set
client.idto your bot's application ID - Set
client.tokento your bot token
- Set
-
Register slash commands:
npm run commands:register
To run multiple bot instances with different identities:
-
Create additional config files:
config-bot1.jsonfor Bot1 (port 3001)config-bot2.jsonfor Bot2 (port 3002)
-
Configure each instance with unique:
- Bot tokens
- API ports
- Bot identity (name, colors)
- Session prefixes
-
Start specific instances:
npm run start:bot1 # Uses config-bot1.json npm run start:bot2 # Uses config-bot2.json
npm start # Single instance with config.json
npm run start:bot1 # Bot1 instance with config-bot1.json
npm run start:bot2 # Bot2 instance with config-bot2.jsonnpm run start:manager # Sharding manager for scaling
npm run start:pm2 # PM2 process manager# Development
npm run build # Compile TypeScript
npm run dev # Watch mode (if configured)
# Code Quality
npm run lint # Run ESLint
npm run lint:fix # Auto-fix linting issues
npm run format # Check Prettier formatting
npm run format:fix # Auto-format code
# Testing
npm test # Run tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage report
# Discord Commands
npm run commands:view # View registered commands
npm run commands:register # Register commands
npm run commands:rename # Rename commands
npm run commands:delete # Delete specific commands
npm run commands:clear # Clear all commandsstart-bot.ts: Single bot instance entry pointstart-manager.ts: Sharding manager for multi-process scalingClaudeSessionManager: Manages Claude CLI processes and message routing- Event Handlers: Modular handlers for Discord events
- Command System: Slash commands with metadata and permissions
- Session Management: In-memory storage of Claude sessions
- Message Routing: Bi-directional message flow between Discord and Claude
- Multi-Instance Support: Different bot identities with isolated sessions
- Error Handling: Graceful error recovery and session cleanup
{
"client": {
"id": "YOUR_BOT_ID",
"token": "YOUR_BOT_TOKEN"
},
"api": {
"port": 3000
}
}BOT_CONFIG: Specify which config file to use (e.g.,bot1,bot2)NODE_ENV: Set toproductionfor production deployments
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and linting
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For issues and feature requests, please use the GitHub Issues page.