GUIDEGetting started

Getting started

Mini Interaction is a modular, type-safe framework for building Discord bots on the HTTP interaction model. No gateway, no WebSocket management - just pure serverless functions.

Installation

Install the core package and the required Discord types:

bash
npm install @theminesastudios/mini-interaction discord-api-types

Peer dependencies: @vercel/functions and mongodb are optional but recommended for edge deployment and persistence.

Quick start

Create an app, register a command handler, and deploy. The framework handles verification, routing, and response formatting.

typescript
import { createApp, command } from "@theminesastudios/mini-interaction";
import { ApplicationCommandType } from "discord-api-types/v10";

const app = createApp({
  publicKey: process.env.DISCORD_PUBLIC_KEY!,
  applicationId: process.env.DISCORD_CLIENT_ID!,
});

const ping = command({
  name: "ping",
  description: "Check the bot's latency",
  async handler(ctx) {
    const latency = Date.now() - ctx.timestamp.getTime();
    return ctx.respond({
      content: `Pong! ${latency}ms`,
    });
  },
});

app.use(ping);

export const POST = app.handle();

Discord setup

To connect your app to Discord:

  1. Create an application in the Discord Developer Portal
  2. Copy the Application ID and Public Key
  3. Generate a bot token and invite the bot to your server
  4. Set DISCORD_PUBLIC_KEY and DISCORD_CLIENT_ID in your environment
  5. Deploy your endpoint and set the Interactions Endpoint URL in the portal

Project structure

A typical Mini Interaction project follows this structure:

text
src/
  commands/        # Slash command definitions
    ping.ts
    info.ts
  components/      # Component handlers (buttons, selects)
    ticket.ts
  modals/          # Modal submit handlers
    feedback.ts
  routers/         # Composed router modules
    mod.ts
  index.ts         # App entry point
  env.ts           # Environment variable types

Next steps