Project Structure

Understand how Disflow organizes your bot project.

Directory Layout

Project Structure
my-bot/
ā”œā”€ā”€ commands/ # Your slash commands
│ ā”œā”€ā”€ ping.js
│ ā”œā”€ā”€ hello.js
│ └── dice.js
│
ā”œā”€ā”€ emoji/ # Custom emoji dictionary
│ └── emoji.js
│
ā”œā”€ā”€ vals/ # Global values
│ └── values.js
│
ā”œā”€ā”€ utils/ # Helper files (optional)
│ └── events.js
│
ā”œā”€ā”€ .env # Bot token
ā”œā”€ā”€ index.js # Entry point
└── package.json

šŸ“‚ commands/

Every .js file in this folder automatically becomes a slash command.

Auto-Loading

  • āœ… All .js files are loaded automatically
  • āœ… Commands register to Discord on startup
  • āœ… No manual registration needed
  • āœ… Hot reload support (restart to see changes)

Example Structure

commands/
ā”œā”€ā”€ ping.js # /ping command
ā”œā”€ā”€ hello.js # /hello command
ā”œā”€ā”€ moderation/
│ ā”œā”€ā”€ ban.js # /ban command
│ └── kick.js # /kick command
└── fun/
ā”œā”€ā”€ dice.js # /dice command
└── 8ball.js # /8ball command

šŸ˜€ emoji/

Define custom emoji shortcuts for your bot.

emoji/emoji.js
// emoji/emoji.js
export default {
wave: 'šŸ‘‹',
check: 'āœ…',
cross: 'āŒ',
loading: 'ā³',
tada: 'šŸŽ‰',
// Custom server emojis
customEmoji: '<:name:id>',
animatedEmoji: '<a:name:id>'
}

Usage in Commands

bot.command.new('test', 'Test', async function() {
await this.reply(`${this.emoji.wave} Hello!`);
// Output: šŸ‘‹ Hello!
});

šŸ“Š vals/

Store global configuration values for your bot.

vals/values.js
// vals/values.js
export default {
bot: {
name: 'My Bot',
version: '1.0.0',
prefix: '!'
},
colors: {
primary: 0x00d9ff,
success: 0x00ff00,
error: 0xff0000
},
limits: {
maxUsers: 100,
cooldown: 5000
}
}

Usage in Commands

bot.command.new('info', 'Bot info', async function() {
await this.reply({
embeds: [{
title: this.vals.bot.name,
description: `Version ${this.vals.bot.version}`,
color: this.vals.colors.primary
}]
});
});

⚔ index.js

The entry point of your bot - keep it simple!

index.js
import { createBot } from 'disflow';
// That's it! Bot starts automatically
await createBot();

✨ No configuration needed! Disflow handles client creation, login, command loading, and more.

šŸ’” Best Practices

āœ… Do

  • • Keep commands in separate files
  • • Use descriptive command names
  • • Organize with subfolders
  • • Store config in vals/

āŒ Don't

  • • Put all commands in one file
  • • Hardcode values in commands
  • • Modify src/ or node_modules/
  • • Commit .env to git