Quick Start
This guide will help you create your first Discord bot with Honocord in a few minutes.
Step 1: Create Your Bot File
Section titled “Step 1: Create Your Bot File”import { Honocord, SlashCommandHandler } from "honocord";
// Initialize Honocordconst bot = new Honocord();
// Create a simple commandconst pingCommand = new SlashCommandHandler() .setName("ping") .setDescription("Replies with Pong!") .addHandler(async (interaction) => { await interaction.reply("🏓 Pong!"); });
// Load the commandbot.loadHandlers(pingCommand);
// Export the appexport default bot.getApp();Step 2: Register Commands with Discord
Section titled “Step 2: Register Commands with Discord”import { registerCommands } from "honocord";import { pingCommand } from "./index";
await registerCommands(process.env.DISCORD_TOKEN!, process.env.DISCORD_APPLICATION_ID!, pingCommand);Run the registration script:
node --env-file=.env src/register.tsbun --env-file=.env src/register.tsnpx tsx --env-file=.env src/register.tsStep 3: Run Your Bot Locally
Section titled “Step 3: Run Your Bot Locally”For local development with Bun:
bun --hot src/index.tsFor Node.js:
npx tsx --hot src/index.tsStep 4: Configure Discord Interactions Endpoint
Section titled “Step 4: Configure Discord Interactions Endpoint”-
Use a tunneling service like ngrok:
Terminal window ngrok http 3000 -
Copy the HTTPS URL (e.g.,
https://abc123.ngrok.io) -
Go to your Discord Application
-
Navigate to “General Information”
-
Set “Interactions Endpoint URL” to:
https://abc123.ngrok.io/ -
Discord will verify the endpoint - it should show a green checkmark
Step 5: Test Your Bot
Section titled “Step 5: Test Your Bot”-
Invite your bot to a server using this URL format:
https://discord.com/api/oauth2/authorize?client_id=<YOUR_APP_ID>&scope=applications.commands -
In Discord, type
/ping -
Your bot should respond with ”🏓 Pong!”
Adding More Features
Section titled “Adding More Features” Typings Learn about typings
Handlers Learn how to use handlers
Cloudflare Workers How to build and deploy on Cloudflare Workers