Skip to content

hyperdargo/DTEmpire-Ai-Chat-Bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DTEmpire AI Chat Bot

DTEmpire Banner

A fast, feature-rich Discord bot with AI capabilities, Minecraft integration, and per-user memory. Built with Node.js and Express.

➕ Add Bot to Discord

Features

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

Requirements

  • Node.js 18+
  • npm or yarn
  • Discord bot token
  • AI API access (any OpenAI-compatible endpoint: OpenRouter, OpenAI, etc.)

Installation

  1. Clone the repository
git clone https://github.com/hyperdargo/DTEmpire-Ai-Chat-Bot.git
cd DTEmpire-Ai-Chat-Bot
  1. Install dependencies
npm install
  1. Create .env file (or copy .env.example):
# Discord Bot
DISCORD_TOKEN=your_discord_bot_token

API Configuration (OpenAI-compatible)

AI_BASE_URL=https://openrouter.ai/api/v1 AI_API_KEY=sk-or-your-key FORCE_MODEL=openai/gpt-4o-mini

Bot Settings

BOT_PREFIX=? ALLOW_MESSAGE_CONTENT_INTENT=true

  1. Run the bot
npm start

The API will start on http://localhost:3000 and the Discord bot will connect automatically.

Setup Commands

Set AI Channel (Auto-reply)

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.

Set Minecraft Channel

Enables AI triggers for Minecraft chat via DiscordSRV.

?setmcchannel

Players in Minecraft can then use:

  • ai <message> - Get AI response
  • bot <message> - Alternative command
  • assistant <message> - Another alternative

Change Model (Admin Only)

?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.

Commands

Prefix Commands

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)

Slash Commands

Command Usage Description
/help /help Show help (ephemeral)
/ai /ai prompt:<message> Talk to AI
/models /models model:<choice> Set model (admin, ephemeral)

Buttons

  • Model Selection: Click DTEmpire, DeepSeek, Claude, Mistral, Gemini buttons to change model
  • Web UI: Open the web interface to chat

Configuration

Environment Variables

# 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)

File Structure

.
├── 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

API Endpoints

AI Smart (Main Endpoint)

POST /api/ai-smart
GET /api/ai-smart?prompt=...&userId=...&model=...

Body: { prompt, userId, model (optional) }
Response: { status, text, model, model_name, elapsedMs }

AI Identity (Personality)

GET /api/ai-identity?prompt=...&userId=...

Response: Fixed answers for name/maker/date, else AI response

Health Check

GET /api/health
Response: { status: "ok", date }

User Memory

GET /api/user?userId=...
Response: { status, user { messages, ... } }

Web UI

GET /ui

DiscordSRV Integration

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.

Features in Action

Discord Auto-Reply

  1. Set an AI channel with ?setchannel
  2. Type any message → Bot replies automatically
  3. Click buttons to change models
  4. Each guild can have different model preferences

Minecraft Chat

  1. Set Minecraft channel with ?setmcchannel
  2. Player types in Minecraft: ai hello
  3. Response appears in Discord and Minecraft chat
  4. No player name prefix in response

Model Selection

  • Per-guild model preferences
  • Automatic fallback to default
  • All models aliased for easy selection

Development

Run in Development

npm start

Debug Mode

Set DEBUG=* to see detailed logs:

DEBUG=* npm start

Testing

# Test AI endpoint
curl "http://localhost:3000/api/ai-smart?prompt=hello&userId=test"

# Test health
curl http://localhost:3000/api/health

Troubleshooting

Bot not responding to Minecraft chat

  • Ensure ALLOW_MESSAGE_CONTENT_INTENT=true in .env
  • Verify Minecraft channel is set with ?setmcchannel
  • Check bot has access to the channel
  • Restart the bot after changes

"Interaction failed" errors

  • Ensure Message Content intent is enabled in Discord Developer Portal
  • Check bot has proper permissions (Send Messages, Embed Links, etc.)

AI models not responding

  • Check API_URL is correct and accessible
  • Verify model endpoints are working
  • Check console for error logs
  • Ensure network connectivity

Commands not working

  • 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

Permissions Required

The bot needs these Discord permissions:

  • Send Messages
  • Send Messages in Threads
  • Embed Links
  • Read Message History
  • Add Reactions (for buttons)

Deploy on Pterodactyl

  1. Create a new Node.js server
  2. Set startup command: node index.js
  3. Configure environment variables (see Configuration section)
  4. Ensure port is accessible (default 3000)
  5. Start the server

Support

For issues or questions:

  1. Check the Troubleshooting section
  2. Review console logs for errors
  3. Verify all environment variables are set
  4. Make sure API is running and accessible

License

This project is licensed under the MIT License.

Credits

  • Built with discord.js
  • AI powered by Pollinations.ai
  • DiscordSRV integration for Minecraft

👤 Author

DargoTamber


DTEmpire Ai Chat Bot • Built with ❤️ for the Discord community

About

Just A New DTEmpire Ai Chat Bot With Minecraft Discord Chat

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors