ChanakyaX is a Discord bot that allows users to interact with a local Large Language Model (LLM) backend (default: deepseek-r1:7b) via slash commands. ChanakyaX manages a queue for prompt processing and creates threads for each user prompt, streaming responses in real time.
- Slash command
/promptto send prompts to the LLM - Queue system to manage multiple user requests
- Automatic thread creation for each prompt
- Real-time streaming of LLM responses
- Built with discord.js and TypeScript
ChanakyaX requires a local LLM backend. We recommend Ollama for Windows.
- Go to the Ollama Windows Download Page
- Download the Windows installer (
.exefile) - Run the installer and follow the prompts
Open Command Prompt or PowerShell and run:
ollama run llama2- This will download and start the Llama 2 model. You can also use other models (see Ollama Models).
- Keep this terminal open and running while you use ChanakyaX.
Note: ChanakyaX expects Ollama's API to be available at
http://localhost:11434/api/generate.
- Go to the Discord Developer Portal
- Click New Application and give it a name (e.g., ChanakyaX)
- Go to Bot in the sidebar, then click Add Bot
- Under Token, click Reset Token and copy your Bot Token
- Go to OAuth2 > General and copy your Client ID
- Under OAuth2 > URL Generator, select
botandapplications.commandsscopes, and set permissions (e.g.,Send Messages,Create Public Threads) - Copy the generated URL, open it in your browser, and invite ChanakyaX to your server
Create a .env file in the root directory of this project:
DISCORD_LLM_BOT_TOKEN=your-discord-bot-token-here
DISCORD_LLM_BOT_CLIENT_ID=your-discord-client-id-hereReplace the values with your actual Bot Token and Client ID from the Discord Developer Portal.
- Clone the repository:
git clone <your-repo-url> cd discord-bot-llm
- Install dependencies:
npm install
- Build the project:
npx tsc
- Start your LLM backend (Ollama) as described above
- Start ChanakyaX:
Or, for development with TypeScript:
node dist/bot.js
npx ts-node src/bot.ts
- ChanakyaX will deploy slash commands automatically on startup
- Use the
/promptcommand in your Discord server:/prompt input: <your message>- ChanakyaX will create a thread and stream the LLM's response there
- ChanakyaX listens for the
/promptcommand - User prompts are queued and processed in order (up to 3 concurrently)
- For each prompt, a new thread is created in the channel
- The bot sends the prompt to the LLM backend and streams the response in real time, updating the thread message(s)
- The queue system ensures fair processing and rate limit compliance
- LLM Model: The default model is set to
deepseek-r1:7binsrc/queue/queue.ts. You can change this as needed - LLM Backend URL: The backend URL is hardcoded as
http://localhost:11434/api/generateinsrc/queue/queue.ts. Update this if your backend runs elsewhere
- TypeScript source is in
src/, compiled output indist/ - Add new commands in
src/commands/following the structure of thepromptcommand - Type definitions for custom Discord.js extensions are in
src/types/discord.d.ts
ISC
This project is not affiliated with Discord or any LLM provider. Use responsibly and ensure compliance with Discord's terms of service.