Skip to main content
Home

Built and signed on GitHub Actions

Works with
This package works with Deno
This package works with Deno
JSR Score70%
Publisheda year ago (1.5.1)

This bot is designed to load and manage plugins dynamically, handling their respective events and commands.

This bot is designed to load and manage plugins dynamically, handling their respective events and commands.

Example Usage

const bot = new Bot({ token: token });
bot.start();

Custom Intents

const customIntents = [
  IntentsBitField.Flags.Guilds,
  IntentsBitField.Flags.GuildMessages,
];

const bot = new Bot({ token: token, intents: customIntents });
bot.start();

Custom Plugin Directory

const bot = new Bot({ token: token, pluginsDir: "./custom_plugins" });
bot.start();

Load Within A Server

const bot = new Bot({ token: token, server: "123456789101112" });
bot.start();

Project Structure

The project is organized into a clear directory structure that separates the core bot code, configuration, and plugin functionality. Each plugin can define its own commands and events, making it easy to add or remove functionality as needed.

.
├── bot.ts                  
└── plugins                
    └── plugin_1
        ├── blitz.config.yaml           
        ├── events          
        │   └── ready.ts    
        └── commands        
            └── ping.ts

Explanation of Key Files and Directories

  • bot.ts: The main entry point for the bot. This file is responsible for initializing the bot, loading configuration settings, and dynamically importing plugins along with their events and commands.
  • plugins/: Contains all plugins. Each plugin is organized into subdirectories for events and commands, which helps in managing individual plugin functionality independently. Each plugin contains a blitz.config.yaml file which contains all metadata and config for a plugin.

Example Plugin Structure

Each plugin follows a standardized structure within the plugins/ folder. For example:

plugin_1
├── blitz.config.yaml
├── events
│   └── ready.ts            
└── commands
    └── ping.ts

This structure helps keep the bot modular and scalable. Adding a new plugin is as simple as creating a new folder under plugins and adding corresponding event or command files.

Examples

Example 1

import { Bot } from './Bot';
import { IntentsBitField } from 'discord.js';

// Using default intents
const bot = new Bot('your-discord-bot-token');
bot.start();

// Using custom intents and custom plugin directory
const customIntents = [
    IntentsBitField.Flags.Guilds,
    IntentsBitField.Flags.GuildMessages,
];
const customBot = new Bot({
    token: 'your-discord-bot-token',
    intents: customIntents,
    pluginsDir: './custom_plugins',
});
customBot.start();

Also, use deno fmt to format the files for consistent formatting.

Built and signed on
GitHub Actions

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@blitz-bots/bot

Import symbol

import * as bot from "@blitz-bots/bot";
or

Import directly with a jsr specifier

import * as bot from "jsr:@blitz-bots/bot";