A complete step-by-step guide to building a Discord bot using Bun and TypeScript in 2026. Covers project setup, Discord application creation, slash commands (ping, userinfo, serverstats), event handling, embed responses, command deployment, and production deployment via VPS with PM2 or Docker. Highlights Bun's advantages over Node.js: native TypeScript execution without a build step, automatic .env loading, 12ms startup time, built-in file watcher, and faster package installs.
Table of contents
What You Need Before StartingStep 1: Create Your Discord ApplicationStep 2: Initialize the ProjectStep 3: Set Up Environment VariablesStep 4: Extend the Discord.js Client TypeStep 5: Create the Bot Entry PointStep 6: Add Event HandlersStep 7: Build Your First Slash CommandsStep 8: Add a More Useful CommandStep 9: Register Slash Commands with DiscordStep 10: Add Scripts and RunStep 11: DeploymentWhy Bun Instead of Node.jsCommon Mistakes to AvoidWhat to Build NextThe Bun Advantage in PracticeSort: