Skip to content

Open source · Self-hosted

Your own AI, inside your Discord server

A self-hosted bot that connects your server to Ollama for chat, vision and file reading, and to AUTOMATIC1111 for images, all running on hardware you control.

Slash commands only · No Message Content intent · Docker ready

Example conversation: alex runs /chat in the ai-lab channel, the bot answers with stats buttons under the reply, and a second reply is still streaming with a red Stop button.

Everything runs on your machines

The bot only talks to the Ollama and AUTOMATIC1111 servers you point it at, so the models and the hardware stay yours.

  • Chat that remembers

    Each person gets their own history in every channel, saved in SQLite and kept across restarts.

    SQLite · last 50 messages

  • Sees your images

    Send an image to a vision model like llava or qwen2.5vl. Vision models are detected automatically.

    IMAGE_INPUT=auto

  • Reads your files

    Attach up to five text, code or PDF files to /generate and ask about them.

    Up to 5 attachments

  • Generates images

    /text2img renders your prompt on your AUTOMATIC1111 Stable Diffusion server.

    AUTOMATIC1111 API

  • Stop anytime

    A red Stop button cancels a running answer. Only the person who asked can press it.

    Requester only

  • Stats for every answer

    See the model, tokens per second, context used and load time under each reply.

    Ollama generation stats

  • Many servers, one fair queue

    Add several servers. Requests go to the first free one and wait in line, first come first served.

    Priority failover

  • Knows the room

    The bot knows its name, the server, the channel topic, who is asking and today's date.

    Bot context in the prompt

  • Respectful by default

    No Message Content intent, never pings anyone, optional channel allowlist and slow mode.

    Guilds intent only

Five slash commands

Everything happens through slash commands with typed options, so the bot only sees what you send it.

  • /chat

    memory

    Chat with memory. Your last 50 messages in each channel are kept.

    Options

    • [prompt]
    • [model]
    • [stream (experimental)]
    • [image]
  • /generate

    one-off

    One-off answers with file and image attachments. Not saved to your chat history.

    Options

    • [prompt]
    • [model]
    • [stream]
    • [attachment1–5]
  • /text2img

    sd-webui

    Turn text into images on your AUTOMATIC1111 server. Shown only when a Stable Diffusion server is set.

    Options

    • [prompt]
    • [width]
    • [height]
    • [steps]
    • [batch_count]
    • [batch_size]
  • /models

    lookup

    List the models installed on your Ollama or Stable Diffusion servers.

    Options

    • [provider]
  • /clearhistory

    history

    Delete your /chat history in this channel and cancel your running /chat requests.

    Options

    No parameters required

How it works

A fault-tolerant router sitting between your server and homelab GPUs.

DISCORD

Discord

Slash commands over the Gateway

THE BOT

Discord AI Bot

  • fair queue
  • SQLite history
  • stop & stats

Node.js · discord.js

  • Ollama #1

    LLM / Vision (GPU 0)

  • Ollama #2

    LLM Secondary (GPU 1)

  • AUTOMATIC1111

    Stable Diffusion WebUI

Servers are tried in priority order. Each answers one request at a time, and if one fails the next takes over.

Self-host in four steps

Deploy on any Linux box, homelab server, or desktop with Docker or native Node.js.

  1. Create a Discord application

    Create a bot in the Discord Developer Portal. No privileged intents or message content access needed.

  2. Run Ollama and pull a model

    Start Ollama and run ollama pull llama3.2, or any model you like.

  3. Fill in .env

    Configure your Discord Bot Token and point endpoints to your host IP and Ollama port.

  4. Start the bot

    Start it with Docker Compose, or run pnpm build and pnpm start. Slash commands register on startup.

git clone https://github.com/238SAMIxD/discord-ai-bot.gitcd discord-ai-botcp .env.example .envmake compose-up

Needs Docker Engine 20.10+ with Compose v2

Frequently Asked Questions

Clear answers about local compute requirements, permissions, and network setup.

Is there a hosted bot I can invite?

No. You run your own copy with your own Discord application, and the models run on hardware you control.

Which models can I use?

Any model you have pulled into Ollama. For images, pull a vision model like llava or qwen2.5vl and pick it with the model option.

Does it read every message?

No. It only answers slash commands, does not request the Message Content intent, and never pings users or roles.

Can it use several machines?

Yes. List several Ollama or AUTOMATIC1111 URLs. They are tried in priority order, and requests wait in a fair queue when all are busy.

Do I need a GPU?

The bot itself does not. Ollama and AUTOMATIC1111 do the heavy lifting, so their hardware requirements apply.

Where is chat history stored?

In a local SQLite file, ./data/chat-history.db by default. Each person keeps their last 50 messages per channel.