Skip to content

Discord Bot

mold includes a built-in Discord bot that connects to mold serve, allowing users to generate images via slash commands.

Running

bash
# Server + bot in one process
MOLD_DISCORD_TOKEN="your-token" mold serve --discord

# Or run the bot separately (connects to a remote server)
MOLD_HOST=http://gpu-host:7680 MOLD_DISCORD_TOKEN="your-token" mold discord

Setup

  1. Create a Discord application at the Developer Portal
  2. Create a bot user and copy the token
  3. Invite with: https://discord.com/api/oauth2/authorize?client_id=YOUR_APP_ID&permissions=51200&scope=bot%20applications.commands (Send Messages, Attach Files, Embed Links + slash command registration)
  4. No privileged intents are needed (slash commands only)

Slash Commands

CommandDescription
/generateGenerate an image (prompt, model, width, height, steps, guidance, seed)
/expandExpand a short prompt into detailed generation prompts
/modelsList available models with download/loaded status
/statusShow server health, GPU info, uptime

Configuration

VariableDefaultDescription
MOLD_DISCORD_TOKENBot token (required)
MOLD_HOSThttp://localhost:7680mold server URL
MOLD_DISCORD_COOLDOWN10Per-user cooldown (s)

NixOS

nix
services.mold.discord = {
  enable = true;
  # tokenFile is loaded via systemd EnvironmentFile —
  # the file must contain: MOLD_DISCORD_TOKEN=your-token-here
  tokenFile = config.age.secrets.discord-token.path;
  moldHost = "http://localhost:7680";
  cooldownSeconds = 10;
};