Ready-to-use template for starting a new Discord.js v14 bot in TypeScript. Clone or "Use this template" on GitHub, then follow the steps below.
src/
commands/ Slash commands, grouped by category (one folder = one category)
utility/
ping.ts
events/ Discord client event handlers
ready.ts
interactionCreate.ts
types/ Shared types (Command, BotEvent, Client augmentation)
index.ts Entry point: loads commands/events and logs the bot in
deploy-commands.ts Registers slash commands with Discord
- Create an application on the Discord Developer Portal and grab the bot token, the Client ID, and your test Guild ID.
- Install dependencies:
pnpm install
- Copy
.env.exampleto.envand fill in the values:DISCORD_TOKEN= CLIENT_ID= GUILD_ID=GUILD_IDis optional: if set, commands are deployed to that guild only (instant, ideal for dev). Without it, deployment is global (can take up to 1h to propagate). - Deploy the slash commands:
pnpm run deploy-commands
- Run the bot in dev mode (auto-reload):
pnpm run dev
pnpm run dev: runs the bot directly from TypeScript with auto-reload (tsx watch)pnpm run build: compilessrc/todist/pnpm start: runs the compiled bot (dist/index.js)pnpm run deploy-commands: registers/refreshes slash commands with the Discord API
Create a file in src/commands/<category>/<name>.ts that default-exports a Command object (data + execute), then re-run pnpm run deploy-commands.
Create a file in src/events/<name>.ts that default-exports a BotEvent object (name, optional once, execute).