Discord Bot Boilerplate

A Discord bot using HTTP interactions (webhooks) instead of the Gateway API.

Features

  • HTTP-based Discord interactions using webhooks
  • Hono.js web framework
  • discord-interactions middleware for signature verification
  • Simple /ping slash command

Setup

  1. Create a Discord application at https://discord.com/developers/applications
  2. Get your application's public key and bot token
  3. Set environment variables:
    • DISCORD_PUBLIC_KEY: Your application's public key
    • DISCORD_BOT_TOKEN: Your bot token
  4. Register the slash commands (run the registration endpoint once)
  5. Set your Discord application's Interactions Endpoint URL to your Val Town HTTP endpoint

Environment Variables

  • DISCORD_PUBLIC_KEY: Required for verifying Discord requests
  • DISCORD_BOT_TOKEN: Required for registering slash commands

Endpoints

  • POST / - Main Discord interactions endpoint
  • POST /register-commands - Register slash commands with Discord (run once)

Commands

  • /ping - Simple ping command that responds with "Pong!"