DisAI is a Discord bot that integrates with Ollama to provide AI capabilities to your Discord server. It allows users to interact with AI models through a simple chat interface.
- Discord integration with slash commands
- AI chat capabilities using Ollama models
- Support for function calling through Model Control Plane (MCP)
- Customizable system and user templates
- Load balancing across multiple Ollama servers
- User whitelisting for access control (TODO)
- Go 1.18 or higher
- Discord bot token
- Ollama server(s) running with your desired models
- MCP server (optional, for function calling)
-
Clone the repository:
git clone https://github.com/FlameInTheDark/disai.git cd disai
-
Build the application:
go build -o disai ./cmd/disai
-
Create a configuration file (see Configuration section below)
-
Run the application:
./disai --config ./config.yaml
Create a config.yaml
file based on the provided config.example.yaml
:
token: "discord_application_token"
model: "qwen3:8b" # Model name and revision
whitelist:
- 79216925611139072
# Ollama servers (name: url)
ollamaServers:
local: "http://localhost:11434"
remote: "http://192.168.1.58:11434"
# MCP servers (supports HTTP and stdio transports)
mcpServers:
# HTTP-based MCP server
general:
url: "http://localhost:8089"
# Stdio-based MCP server
local:
command: "./tool"
args: []
# Templates for the model. Probably never going to change.
templates:
system: "./system.tmpl"
user: "./user.tmpl"
# Rename the original tool names to your own (original_tool_name: "This will be shown in the chat when tool called")
toolNames:
search: "🔍 Searching web..."
jina_fetch_url: "🌐 Opening url with Jina.AI..."
fetch_url: "🌐 Opening url..."
get_weather_forecast: "⛅ Getting weather forecast..."
The bot uses two template files to format messages sent to the AI model:
- System Template (
system.tmpl
): Defines the AI's persona and behavior - User Template (
user.tmpl
): Formats user messages and provides instructions
You can customize these templates to change the AI's behavior and response format.
Once the bot is running and added to your Discord server, you can interact with it using the /chat
command:
/chat message: What's the weather like today?
The bot will process your message through the AI model and respond with the AI's reply.
- Create a new application at the Discord Developer Portal
- Create a bot for your application
- Enable the "Message Content Intent" under the Bot settings
- Generate a bot token and add it to your configuration file
- Use the OAuth2 URL Generator to create an invite link with the following permissions:
- Scopes:
bot
,applications.commands
- Bot Permissions:
Send Messages
,Use Slash Commands
- Scopes:
- Invite the bot to your server using the generated link
cmd/disai
: Main application codecmd/tool
: Additional tools (MCP)internal/config
: Configuration handlinginternal/mcp
: Model Control Plane clientinternal/model
: AI model integration
go build -o disai ./cmd/disai
And if you need tools, for example:
go build -o tool ./cmd/tool
- Add message queue for Ollama server load balancing
- Add user whitelisting