Skip to content

Quick Start

This guide will help you create your first Discord bot with Honocord in a few minutes.

src/index.ts
import { Honocord, SlashCommandHandler } from "honocord";
// Initialize Honocord
const bot = new Honocord();
// Create a simple command
const pingCommand = new SlashCommandHandler()
.setName("ping")
.setDescription("Replies with Pong!")
.addHandler(async (interaction) => {
await interaction.reply("🏓 Pong!");
});
// Load the command
bot.loadHandlers(pingCommand);
// Export the app
export default bot.getApp();
src/register.ts
import { registerCommands } from "honocord";
import { pingCommand } from "./index";
await registerCommands(process.env.DISCORD_TOKEN!, process.env.DISCORD_APPLICATION_ID!, pingCommand);

Run the registration script:

Terminal window
node --env-file=.env src/register.ts
bun --env-file=.env src/register.ts
npx tsx --env-file=.env src/register.ts

For local development with Bun:

Terminal window
bun --hot src/index.ts

For Node.js:

Terminal window
npx tsx --hot src/index.ts

Step 4: Configure Discord Interactions Endpoint

Section titled “Step 4: Configure Discord Interactions Endpoint”
  1. Use a tunneling service like ngrok:

    Terminal window
    ngrok http 3000
  2. Copy the HTTPS URL (e.g., https://abc123.ngrok.io)

  3. Go to your Discord Application

  4. Navigate to “General Information”

  5. Set “Interactions Endpoint URL” to: https://abc123.ngrok.io/

  6. Discord will verify the endpoint - it should show a green checkmark

  1. Invite your bot to a server using this URL format:

    https://discord.com/api/oauth2/authorize?client_id=<YOUR_APP_ID>&scope=applications.commands
  2. In Discord, type /ping

  3. Your bot should respond with ”🏓 Pong!”