npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

dscaffold

v1.0.0

Published

A TypeScript framework for scaffolding modular Discord bot projects with dynamic command and event loading

Readme

Dscaffold

A TypeScript framework for scaffolding modular Discord bot projects with dynamic command and event loadinExamples:

dscaffold generate schema User --type mongoose
dscaffold g schema Post --type prisma
```# Features

- 🚀 **Dynamic Loading**: Commands and events are automatically loaded from directories
- 📁 **Nested Support**: Organize commands in subfolders (e.g., `admin/`, `moderation/`)
- 🔥 **Hot Reload**: Commands can be reloaded without restarting the bot
- 📝 **TypeScript & JavaScript Support**: Full TypeScript support with proper typing
- 🎯 **Category System**: Automatic command categorization
- 🏗️ **Framework Approach**: Import utilities rather than static code generation
- 🎨 **Beautiful CLI**: Styled output with chalk and ora spinners
- 🔧 **Configurable Templates**: Basic and advanced project templates
- 🐳 **Docker Support**: Optional Docker configuration
- 🔍 **Code Quality**: ESLint and Prettier integration
- 📊 **Database Integration**: Support for MongoDB, PostgreSQL, and more

## Installation

Install globally for easy access:

```bash
npm install -g dscaffold

Or use with npx:

npx dscaffold create my-bot

Quick Start

Create a New Bot Project

# Interactive creation
dscaffold create

# With project name
dscaffold create my-awesome-bot

# With options
dscaffold create my-bot --language typescript --template advanced

Generate Components

# Generate a new command
dscaffold generate command ping --category utility --description "Test connectivity"

# Generate a slash command
dscaffold generate command hello --slash --description "Say hello"

# Generate an event handler
dscaffold generate event messageCreate

# Generate a one-time event
dscaffold generate event ready --once

# Generate a database schema
dscaffold generate schema User --type mongoose

CLI Commands

create [project-name]

Creates a new Discord bot project with interactive setup.

Options:

  • -t, --template <template> - Template type (basic, advanced) [default: basic]
  • -l, --language <language> - Language (typescript, javascript) [default: typescript]
  • --skip-install - Skip npm install

Examples:

dscaffold create
dscaffold create my-bot --template advanced --language typescript

generate command <name>

Generates a new bot command.

Options:

  • -c, --category <category> - Command category [default: general]
  • -d, --description <description> - Command description
  • --slash - Generate as slash command

Examples:

dscaffold generate command ping
dscaffold g command moderation kick --category moderation --slash

generate event <name>

Generates a new event handler.

Options:

  • -o, --once - Event runs only once

Examples:

dscaffold generate event messageCreate
dscaffold g event ready --once

generate schema <name>

Generates a database schema/model.

Options:

  • -t, --type <type> - Database type (mongoose, prisma, sequelize) [default: mongoose]

Examples:

create-discord-bot generate schema User --type mongoose
create-discord-bot g schema Guild --type prisma

🔥 Dynamic Loading API

Dscaffold provides a powerful framework for dynamically loading commands and events from nested directories. Unlike traditional static generators, Dscaffold uses a runtime framework approach that automatically discovers and loads your bot components.

Basic Usage

import { Client, GatewayIntentBits } from 'discord.js';
import dscaffold from 'dscaffold';
import path from 'path';

const client = new Client({
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages],
});

async function initialize() {
  // Load commands from any directory structure
  await dscaffold.loadCommands(client, path.join(__dirname, 'commands'));
  
  // Load events from events directory
  await dscaffold.loadEvents(client, path.join(__dirname, 'events'));
  
  await client.login(process.env.DISCORD_TOKEN);
}

initialize();

Nested Folder Support

Commands can be organized in any nested structure:

src/commands/
├── ping.ts                    # General command
├── utility/
│   ├── help.ts                # Utility category
│   └── info.ts
├── admin/
│   ├── ban.ts                 # Admin category
│   ├── kick.ts
│   └── moderation/
│       ├── mute.ts            # Nested admin commands
│       └── warn.ts
└── economy/
    ├── balance.ts             # Economy category
    └── shop.ts

API Methods

dscaffold.loadCommands(client, path, options?)

Dynamically loads all commands from a directory and subdirectories.

await dscaffold.loadCommands(client, './src/commands', {
  recursive: true,                          // Load from subdirectories
  fileExtensions: ['.js', '.ts'],          // File types to load
  excludeDirs: ['node_modules', 'dist']    // Directories to skip
});

dscaffold.loadEvents(client, path, options?)

Dynamically loads all events from a directory.

await dscaffold.loadEvents(client, './src/events', {
  recursive: true,
  fileExtensions: ['.js', '.ts']
});

dscaffold.getCommand(name)

Retrieve a loaded command by name.

const pingCommand = dscaffold.getCommand('ping');
if (pingCommand) {
  await pingCommand.execute(message, args);
}

dscaffold.getCommandsByCategory(category)

Get all commands in a specific category.

const adminCommands = dscaffold.getCommandsByCategory('admin');
const utilityCommands = dscaffold.getCommandsByCategory('utility');

dscaffold.getCategories()

Get all available command categories.

const categories = dscaffold.getCategories();
console.log('Available categories:', categories);

dscaffold.reloadCommands(client, path)

Hot reload all commands (useful for development).

// Reload all commands
await dscaffold.reloadCommands(client, './src/commands');

dscaffold.reloadCommand(name, path)

Reload a specific command.

// Reload just the ping command
await dscaffold.reloadCommand('ping', './src/commands');

Command Structure

Commands are simple function-based modules:

// src/commands/utility/ping.ts
import { Message } from 'discord.js';

module.exports = {
  name: 'ping',
  description: 'Test bot latency',
  category: 'utility',  // Automatically categorized
  
  async execute(message: Message, args: string[]) {
    const sent = await message.reply('🏓 Pinging...');
    const latency = sent.createdTimestamp - message.createdTimestamp;
    await sent.edit(`🏓 Pong! Latency: ${latency}ms`);
  },
};

Event Structure

Events are also simple function-based modules:

// src/events/ready.ts
import { Client } from 'discord.js';

module.exports = {
  name: 'ready',
  once: true,  // Run only once
  
  execute(client: Client) {
    console.log(`✅ ${client.user?.tag} is online!`);
  },
};

Project Templates

Basic Template

  • Essential Discord.js setup
  • Command and event structure
  • Environment configuration
  • TypeScript/JavaScript support

Advanced Template

  • Everything from basic template
  • Database integration (MongoDB/PostgreSQL)
  • Advanced logging with Winston
  • Docker configuration
  • ESLint and Prettier setup
  • GitHub Actions workflow

Generated Project Structure

my-discord-bot/
├── src/
│   ├── commands/          # Bot commands
│   ├── events/            # Discord event handlers
│   ├── models/            # Database models (if enabled)
│   └── index.ts           # Main bot file
├── config/
│   └── bot.ts             # Bot configuration
├── .env.example           # Environment template
├── package.json
├── tsconfig.json          # TypeScript config
├── .eslintrc.json         # ESLint config (if enabled)
├── .prettierrc            # Prettier config (if enabled)
├── Dockerfile             # Docker config (if enabled)
└── README.md

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/your-org/create-discord-bot.git
cd create-discord-bot

# Install dependencies
npm install

# Start development mode
npm run dev

# Build the project
npm run build

# Link for local testing
npm link

Testing Your Changes

After linking, you can test the CLI globally:

create-discord-bot create test-bot

Architecture

Core Components

  • CLI: Command-line interface using Commander.js
  • Generators: Template-based file generators
  • Templates: Mustache-based templates for different file types
  • Utils: Shared utilities for file operations and formatting

Related Projects


Made with ❤️ for the Discord bot development community