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