Getting Started

Project Structure

This is the minimal directory structure for a djs-core Discord bot project:

This is the minimal directory structure for a djs-core Discord bot project:

src/interactions/commands/ping.ts
import { Command } from "@djs-core/runtime";

export default new Command()
  .setDescription("Ping the bot")
  .run(async (interaction) => {
    await interaction.reply("Pong!");
  });

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
The file path determines the command structure
ping.ts
file
/ping
admin/kick.ts
file
/admin kick
shop/buy.ts
file
/shop buy

src/interactions/contexts/

This directory contains your context menu commands (user and message context menus).

user/
directory
User context menus - appear when right-clicking on users
message/
directory
Message context menus - appear when right-clicking on messages

src/events/

This directory contains your Discord event handlers. Common events include:

ready.ts
file
Fired when the bot successfully connects to Discord
messageCreate.ts
file
Fired when a message is created in a channel
guildMemberAdd.ts
file
Fired when a member joins a guild

src/components/

This directory contains reusable interaction components:

buttons/
directory
Button components - interactive clickable buttons
modals/
directory
Modal components - form-like dialogs with text inputs
selects/
directory
Select menu components organized by type:
  • string/ - Text-based options
  • user/ - User selection
  • role/ - Role selection
  • channel/ - Channel selection
  • mentionable/ - User or role selection

djs.config.ts

This is the configuration file for your bot. It defines essential settings like your Discord bot token and server IDs:

djs.config.ts
import type { Config } from "@djs-core/dev";

export default {
  token: process.env.TOKEN,
  servers: ["YOUR_GUILD_ID"],
} satisfies Config;

package.json

This file contains all the dependencies and scripts for your bot application:

package.json
{
  "scripts": {
    "dev": "djs-core dev",
    "build": "djs-core build",
    "start": "djs-core start"
  },
  "dependencies": {
    "@djs-core/runtime": "^6.0.0",
    "discord.js": "^14.25.1"
  },
  "devDependencies": {
    "@djs-core/dev": "^6.0.0",
    "typescript": "^5"
  }
}

tsconfig.json

TypeScript configuration file for type checking and compilation settings.