Skip to content

MostFeatured/DiscordBotInfrastructure

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ€– DBI - Discord Bot Infrastructure

npm version npm downloads License

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