Skip to main content
This is the minimal directory structure for a djs-core Discord bot project:
my-bot/
├── src/
│   ├── interactions/
│   │   ├── commands/       # Slash commands (/ping, /admin kick)
│   │   ├── contexts/       # Context menus (User, Message)
│   │   │   ├── user/
│   │   │   └── message/
│   ├── events/             # discord.js event listeners (ready, messageCreate)
│   └── components/         # Reusable interaction components
│       ├── buttons/
│       ├── modals/
│       └── selects/
├── djs.config.ts           # Core configuration
├── package.json
└── tsconfig.json

src/ directory

This is where you organize your bot’s code using the file-based routing system.
The file-based routing system means the structure of your files determines how commands, components, and events are registered. Keep your files organized to match your bot’s functionality.

src/interactions/commands/

This directory contains your slash commands. Each file automatically becomes a command, and subdirectories create command groups.
  • File Path → Command Name Mapping:
    • ping.ts/ping
    • admin/kick.ts/admin kick
    • shop/buy.ts/shop buy

src/interactions/contexts/

This directory contains your context menu commands (user and message context menus).
  • user/ - User context menus (right-click on users).
  • message/ - Message context menus (right-click on messages).

src/events/

This directory contains your Discord event handlers. Common events include:
  • ready.ts - Fired when the bot connects to Discord.
  • messageCreate.ts - Fired when a message is created.
  • guildMemberAdd.ts - Fired when a member joins a server.

src/components/

This directory contains reusable interaction components:
  • buttons/ - Interactive clickable buttons.
  • modals/ - Form-like dialogs with text inputs.
  • selects/ - Select menu components (string, user, role, channel, mentionable).

djs.config.ts

The configuration file for your bot. It defines settings like your token and server IDs.

package.json

Contains dependencies and scripts. Essential dependencies include @djs-core/runtime and discord.js.

tsconfig.json

TypeScript configuration for the project.