A fast, feature-rich Discord bot with AI capabilities, Minecraft integration, and per-user memory. Built with Node.js and Express.
✨ AI Responses
- Works with any OpenAI-compatible API (OpenRouter, OpenAI, Groq, Ollama, etc.)
- Fast parallel model selection
- Per-user memory storage
- Identity overrides (name, creator, date)
🎮 Minecraft Integration
- DiscordSRV webhook support
- Minecraft chat AI triggers (
ai <message>,bot <message>) - Automatic message extraction from Minecraft chat
💬 Discord Features
- Prefix commands (
?help,?ai,?models, etc.) - Slash commands (
/help,/ai,/models) - Configurable AI channels
- Model selection per guild
- Beautiful embeds and buttons
- Typing indicators
⚙️ Flexible Configuration
- Configurable Message Content intent
- Environment-based settings
- Per-guild model preferences
- Easy setup commands
- Node.js 18+
- npm or yarn
- Discord bot token
- AI API access (any OpenAI-compatible endpoint: OpenRouter, OpenAI, etc.)
- Clone the repository
git clone https://github.com/hyperdargo/DTEmpire-Ai-Chat-Bot.git
cd DTEmpire-Ai-Chat-Bot- Install dependencies
npm install- Create
.envfile (or copy.env.example):
# Discord Bot
DISCORD_TOKEN=your_discord_bot_tokenAI_BASE_URL=https://openrouter.ai/api/v1 AI_API_KEY=sk-or-your-key FORCE_MODEL=openai/gpt-4o-mini
BOT_PREFIX=? ALLOW_MESSAGE_CONTENT_INTENT=true
- Run the bot
npm startThe API will start on http://localhost:3000 and the Discord bot will connect automatically.
Makes a channel auto-reply to all messages with AI responses.
?setchannel
Users can also set multiple AI channels. Regular Discord users will get auto-replies, and Minecraft chat will respond to ai <message> commands.
Enables AI triggers for Minecraft chat via DiscordSRV.
?setmcchannel
Players in Minecraft can then use:
ai <message>- Get AI responsebot <message>- Alternative commandassistant <message>- Another alternative
?models <ModelName>
The bot communicates with any OpenAI-compatible API endpoint. Set AI_BASE_URL, AI_API_KEY, and FORCE_MODEL in .env to choose your model.
| Command | Usage | Description |
|---|---|---|
?help |
?help |
Show help embed |
?ai |
?ai <message> |
Talk to AI |
?models |
?models <model> |
Set model (admin) |
?setchannel |
?setchannel |
Set AI channel (admin) |
?setmcchannel |
?setmcchannel |
Set Minecraft channel (admin) |
| Command | Usage | Description |
|---|---|---|
/help |
/help |
Show help (ephemeral) |
/ai |
/ai prompt:<message> |
Talk to AI |
/models |
/models model:<choice> |
Set model (admin, ephemeral) |
- Model Selection: Click DTEmpire, DeepSeek, Claude, Mistral, Gemini buttons to change model
- Web UI: Open the web interface to chat
# Required
DISCORD_TOKEN= # Discord bot token
# API (OpenAI-compatible)
AI_BASE_URL= # API base URL (e.g. https://openrouter.ai/api/v1)
AI_API_KEY= # API key
FORCE_MODEL= # Model name (e.g. openai/gpt-4o-mini)
DEFAULT_MODEL= # Fallback model
# Server Settings
PORT=25607 # API server port
# Bot
BOT_PREFIX=? # Prefix for commands (?, !, etc.)
ALLOW_MESSAGE_CONTENT_INTENT=true # Enable Message Content intent (required for Minecraft).
├── index.js # Main entry point
├── package.json # Dependencies
├── .env # Environment variables
├── data/
│ ├── bot.json # Guild settings (auto-created)
│ └── users.json # User memory (auto-created)
├── public/
│ └── index.html # Web UI
└── src/
├── server.js # Express API
├── discordBot.js # Discord bot
├── aiClient.js # AI API client
├── botConfig.js # Config manager
├── memoryStore.js # User memory
└── config/
└── models.js # Model configuration
POST /api/ai-smart
GET /api/ai-smart?prompt=...&userId=...&model=...
Body: { prompt, userId, model (optional) }
Response: { status, text, model, model_name, elapsedMs }
GET /api/ai-identity?prompt=...&userId=...
Response: Fixed answers for name/maker/date, else AI response
GET /api/health
Response: { status: "ok", date }
GET /api/user?userId=...
Response: { status, user { messages, ... } }
GET /ui
The bot automatically detects Minecraft chat messages from DiscordSRV webhooks using patterns:
[Member] PlayerName » message[Member] PlayerName > message[Member] PlayerName: message
When a message matches ai <text> or bot <text>, it triggers the AI to respond.
- Set an AI channel with
?setchannel - Type any message → Bot replies automatically
- Click buttons to change models
- Each guild can have different model preferences
- Set Minecraft channel with
?setmcchannel - Player types in Minecraft:
ai hello - Response appears in Discord and Minecraft chat
- No player name prefix in response
- Per-guild model preferences
- Automatic fallback to default
- All models aliased for easy selection
npm startSet DEBUG=* to see detailed logs:
DEBUG=* npm start# Test AI endpoint
curl "http://localhost:3000/api/ai-smart?prompt=hello&userId=test"
# Test health
curl http://localhost:3000/api/health- Ensure
ALLOW_MESSAGE_CONTENT_INTENT=truein.env - Verify Minecraft channel is set with
?setmcchannel - Check bot has access to the channel
- Restart the bot after changes
- Ensure Message Content intent is enabled in Discord Developer Portal
- Check bot has proper permissions (Send Messages, Embed Links, etc.)
- Check API_URL is correct and accessible
- Verify model endpoints are working
- Check console for error logs
- Ensure network connectivity
- Verify prefix matches BOT_PREFIX in .env
- For slash commands, wait for them to register (may take ~1 hour globally)
- Restart bot if slash commands don't appear
The bot needs these Discord permissions:
Send MessagesSend Messages in ThreadsEmbed LinksRead Message HistoryAdd Reactions(for buttons)
- Create a new Node.js server
- Set startup command:
node index.js - Configure environment variables (see Configuration section)
- Ensure port is accessible (default 3000)
- Start the server
For issues or questions:
- Check the Troubleshooting section
- Review console logs for errors
- Verify all environment variables are set
- Make sure API is running and accessible
This project is licensed under the MIT License.
- Built with discord.js
- AI powered by Pollinations.ai
- DiscordSRV integration for Minecraft
DargoTamber
- GitHub: https://github.com/hyperdargo
- Discord: DargoTamber
- Website: https://ankitgupta.com.np
DTEmpire Ai Chat Bot • Built with ❤️ for the Discord community
