@mostfeatured/dbi
v0.2.31
Published
The most advanced, modern, and developer-friendly Discord.js v14 bot infrastructure with slash commands, components, localization, sharding, and Svelte UI support.
Downloads
4,085
Maintainers
Readme
🤖 DBI - Discord Bot Infrastructure
The most advanced, modern, and developer-friendly Discord.js v14 bot infrastructure.
Getting Started • Features • Documentation • Examples
✨ Features
| Feature | Description | |---------|-------------| | 🎯 Slash Commands | Full support with 14 option types, autocomplete, and subcommands | | 🔘 Components | Buttons, Select Menus (5 types), and Modals with built-in state management | | 🌍 Localization | Multi-language support for both content and command translations | | 📨 Events | Discord events, custom events, and internal DBI events | | 💬 Message Commands | Automatic slash command emulation from prefix commands | | 🔗 Reference System | Pass complex data through component interactions | | 🚀 Multi-Client | Run multiple bots with namespace isolation | | ⚡ Hybrid Sharding | Scale to millions of servers with discord-hybrid-sharding | | 🎨 Svelte Components | Build reactive Discord UIs with Svelte 5 (HTMLComponentsV2) | | 🔄 Hot Reloading | Update features without restarting your bot | | 🛡️ Rate Limiting | Built-in rate limit management per user/channel/guild | | 📝 TypeScript | Full type safety with intelligent autocomplete |
📦 Installation
npm install @mostfeatured/dbi discord.js🚀 Quick Start
1. Create DBI Instance
// dbi.js
const { createDBI } = require("@mostfeatured/dbi");
const dbi = createDBI("my-bot", {
strict: true,
discord: {
token: process.env.DISCORD_TOKEN,
options: { intents: ["Guilds"] }
},
defaults: {
locale: { name: "en" },
directMessages: false
}
});
module.exports = dbi;2. Define Features
// src/commands/ping.js
const dbi = require("../dbi");
dbi.register(({ ChatInput }) => {
ChatInput({
name: "ping",
description: "Check bot latency",
onExecute({ interaction, dbi }) {
interaction.reply(`🏓 Pong! ${dbi.client().client.ws.ping}ms`);
}
});
});3. Start Bot
// index.js
const { Utils } = require("@mostfeatured/dbi");
const dbi = require("./dbi");
(async () => {
await Utils.recursiveImport("./src");
await dbi.load();
await dbi.login();
console.log(`✅ Logged in as ${dbi.client().client.user.tag}`);
})();4. Publish Commands
// publish.js
const { Utils } = require("@mostfeatured/dbi");
const dbi = require("./dbi");
(async () => {
await Utils.recursiveImport("./src");
await dbi.load();
await dbi.publish("Global"); // or dbi.publish("Guild", "GUILD_ID")
await dbi.unload();
console.log("✅ Commands published!");
})();💡 Examples
Slash Command with Options
dbi.register(({ ChatInput, ChatInputOptions }) => {
ChatInput({
name: "greet",
description: "Greet a user",
options: [
ChatInputOptions.user({
name: "target",
description: "User to greet",
required: true
}),
ChatInputOptions.string({
name: "message",
description: "Custom message"
})
],
onExecute({ interaction }) {
const user = interaction.options.getUser("target");
const message = interaction.options.getString("message") || "Hello!";
interaction.reply(`${message}, ${user}!`);
}
});
});Button with Reference Data
const Discord = require("discord.js");
dbi.register(({ ChatInput, Button }) => {
ChatInput({
name: "shop",
description: "View the shop",
onExecute({ interaction, dbi }) {
interaction.reply({
content: "🛒 Welcome to the shop!",
components: [{
type: Discord.ComponentType.ActionRow,
components: [
dbi.interaction("buy-item").toJSON({
overrides: { label: "Buy Sword - 100g" },
reference: { data: ["sword", 100] }
})
]
}]
});
}
});
Button({
name: "buy-item",
options: { style: Discord.ButtonStyle.Primary },
onExecute({ interaction, data }) {
const [item, price] = data;
interaction.reply(`✅ You bought **${item}** for **${price}g**!`);
}
});
});Multi-Language Support
dbi.register(({ Locale, ChatInput }) => {
Locale({
name: "en",
data: {
greeting: "Hello, {0}!",
farewell: "Goodbye!"
}
});
Locale({
name: "tr",
data: {
greeting: "Merhaba, {0}!",
farewell: "Hoşça kal!"
}
});
ChatInput({
name: "hello",
description: "Say hello",
onExecute({ interaction, locale }) {
const greeting = locale.user.data.greeting(interaction.user.username);
interaction.reply(greeting);
}
});
});📚 Documentation
Comprehensive documentation is available in the docs folder:
| Document | Description | |----------|-------------| | Getting Started | Installation, setup, and project structure | | Chat Input | Slash commands, options, and autocomplete | | Components | Buttons, select menus, and modals | | Events | Discord events, custom events, DBI events | | Localization | Multi-language support | | Advanced Features | Message commands, sharding, multi-client | | Svelte Components | HTMLComponentsV2 with Svelte 5 | | API Reference | Complete API documentation |
🏗️ Project Structure
my-bot/
├── dbi.js # DBI configuration
├── index.js # Bot entry point
├── publish.js # Command publisher
└── src/
├── commands/ # Slash commands
├── components/ # Buttons, modals, menus
├── events/ # Event handlers
└── locales/ # Language files🤝 Contributing
Contributions are welcome! Feel free to open issues or submit pull requests.
📄 License
GPL-3.0 © TheArmagan
"There will always be something free and valuable on earth."
Made with ❤️ by TheArmagan
