Discord Bot

Phase 2 feature. Lightweight Discord bot interface for FlowDice, powered by the MCP Server and integrated with the dice engine.

Design

Stateless, self-hostable bot using Discord slash commands (not legacy ! prefix, which is reserved for Exploding Dice). Acts as a thin interface layer between Discord and the FlowDice engine — all logic lives in the engine, bot just handles Discord interactions.

Deployment: single Node.js process running discord.js + MCP Client SDK. Connects to your FlowDice instance via MCP (local or remote). No database required.

Core Commands

  • /roll [notation] — Roll the given notation. Returns result with individual die values in an embed.
  • /roll [name] — If name matches a Favorites entry (fetched via list_favorites MCP), roll that favorite.

Interactive Parameters

After posting a roll result, Discord buttons appear for Named Parameters. Examples:

Attack Flow with Damage Options:

  • Roll /roll longsword (notation: d20+5 -> d8+3)
  • Result embeds shows attack roll and prompt for damage modifiers
  • Buttons below: Smite (adds +2d8), Sneak Attack (adds +3d6), GWM (adds +10 flat)
  • Click → re-evaluate flow segment with modifier enabled
  • New damage total posts as a follow-up message

Advantage Toggling:

  • Initial roll: 2d20kh+5 (advantage D&D 5e)
  • Buttons: Roll as Normal, Roll as Disadvantage (or toggle between)
  • Clicking changes the notation mid-stream, re-rolls that segment

Button interactions are transient — they disappear after ~5 min or first click. Stateless design means the bot doesn’t track session state; the user’s follow-up click sends the modified notation back through the engine.

Implementation

Uses discord.js v14+ with slash command registration. MCP Client library wraps roll_flow, list_favorites, and parse calls to the FlowDice engine.

Interaction handler:

  1. User inputs /roll longsword → bot calls list_favorites → confirms it’s a favorite
  2. Parse notation → call roll_flow with empty parameters
  3. Post result embed with buttons for each <name> parameter in the flow
  4. User clicks button → bot calls roll_flow with modified parameters
  5. Post follow-up or edit message

No caching of user preferences, rolls, or state. Each command is independent.

Self-Hosting

  1. Clone bot repo, npm install
  2. Provide Discord bot token and FlowDice MCP Server URL (local or remote)
  3. npm start
  4. Register slash commands (one-time per server)
  5. Invite bot to your Discord server

Requirements: Node.js 18+, FlowDice instance with MCP Server running.

See also: MCP Server, Named Parameters, Flows, Architecture