Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

discordjs-bot-template

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.

Structure

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

Getting started

  1. Create an application on the Discord Developer Portal and grab the bot token, the Client ID, and your test Guild ID.
  2. Install dependencies:
    pnpm install
  3. Copy .env.example to .env and fill in the values:
    DISCORD_TOKEN=
    CLIENT_ID=
    GUILD_ID=
    
    GUILD_ID is 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).
  4. Deploy the slash commands:
    pnpm run deploy-commands
  5. Run the bot in dev mode (auto-reload):
    pnpm run dev

Scripts

  • pnpm run dev: runs the bot directly from TypeScript with auto-reload (tsx watch)
  • pnpm run build: compiles src/ to dist/
  • pnpm start: runs the compiled bot (dist/index.js)
  • pnpm run deploy-commands: registers/refreshes slash commands with the Discord API

Adding a command

Create a file in src/commands/<category>/<name>.ts that default-exports a Command object (data + execute), then re-run pnpm run deploy-commands.

Adding an event

Create a file in src/events/<name>.ts that default-exports a BotEvent object (name, optional once, execute).

About

Discord.js v14 (TypeScript) bot template - clone/fork to bootstrap a new bot

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages