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

dbotlang

v1.2.4

Published

A simple, English-like programming language for creating Discord bots

Readme

dBot - Discord Bot Programming Language

A simple, English-like programming language for creating powerful Discord bots. From basic commands to enterprise-grade features with AI, security, and multi-language support.

🚀 Quick Start

Installation

# Install dBot globally
npm install -g dbotlang

# Or clone and install locally
git clone https://github.com/your-username/dBot.git
cd dBot
npm install

Your First Bot

  1. Create a .dbot file:
on ready {
    log("🚀 My first dBot is online!");
    register slash command ("hello") with description ("Say hello");
}

on slash command {
    if (command-name == "hello") {
        reply("Hello {user}! Welcome to our server!");
    }
}
  1. Set your Discord token:
export DISCORD_TOKEN=your_bot_token_here
  1. Run your bot:
dbot run my-bot.dbot

📖 Language Syntax

Event Handlers

dBot uses simple event handlers to respond to Discord events:

on ready {
    log("Bot is online!");
    set bot status to ("Watching") to ("over {members} members!");
}

on message {
    if (message-content == "!ping") {
        reply("Pong!");
    }
}

on slash command {
    if (command-name == "info") {
        reply("Server: {server} has {members} members");
    }
}

on user join {
    reply("Welcome {user} to {server}!");
}

on user leave {
    log("{user} left the server");
}

Variables & Built-ins

// Built-in variables
reply("Hello {user}!");           // User's name
reply("Server: {server}");        // Server name  
reply("{members} members");       // Member count
reply("Avatar: {user-avatar}");   // User's avatar URL

// Custom variables
set my-variable to ("Hello World");
set number to (42);
set coins to (database get "coins" for {user});

// Environment variables
set token to (env("DISCORD_TOKEN"));

Database Operations

// Store data
database store "coins" for {user} value (100);
database store "level" for {user} value (5);

// Retrieve data
set user-coins to (database get "coins" for {user});
set user-level to (database get "level" for {user});

// Handle null values
if (user-coins == null) {
    set user-coins to (0);
}

Conditionals & Logic

// Basic conditions
if (command-name == "balance") {
    reply("You have {user-coins} coins!");
}

// Advanced conditions with logical operators
if (user has role "VIP" AND user-level greater than 50) {
    reply("Welcome VIP member!");
}
elif (user has permission "ADMINISTRATOR" OR user has role "Moderator") {
    reply("Hello staff member!");
}
elif (NOT user has role "Banned") {
    reply("Welcome to the server!");
}
else {
    reply("Access denied.");
}

// Comparison operators
if (user-level greater than 10) { /* ... */ }
if (user-coins less than 100) { /* ... */ }
if (message-content length greater than 50) { /* ... */ }

Loops & Iteration

// Repeat actions
repeat 5 times {
    log("This runs 5 times");
}

// Loop through server data
for each member in server {
    if (member has role "Inactive") {
        log("Found inactive member: {member.name}");
    }
}

for each role in server {
    log("Role: {role.name}");
}

// While loops
set counter to (0);
while (counter less than 10) {
    log("Counter: {counter}");
    set counter to (counter + 1);
}

Embeds

Create rich embeds with the new embed_builder syntax:

embed_builder {
    title("Welcome to our server!");
    description("Thanks for joining {user}!");
    color("#0099ff");
    thumbnail("{user-avatar}");
    field("Level", "1", true);
    field("Coins", "100", true);
    footer("Bot created with dBot");
}
reply with embed;

Or use the classic syntax:

create embed {
    title: "User Profile";
    description: "Profile for {user}";
    color: 0x0099ff;
    thumbnail: {user-avatar};
    field "Level" value "{user-level}" inline;
    field "Coins" value "{user-coins}" inline;
    footer: "dBot Profile System";
    timestamp: now;
}
reply with embed;

🎮 Gaming Features

Built-in Games

on slash command {
    if (command-name == "rps") {
        play game "rock-paper-scissors" with {user};
    }
    
    if (command-name == "coinflip") {
        play game "coinflip" with {user};
    }
    
    if (command-name == "dice") {
        play game "dice" with {user};
    }
}

Trivia System

create trivia "programming" question "What does HTML stand for?" 
    answers ["HyperText Markup Language", "Home Tool Markup Language", "Hyperlinks Text Mark Language"];

create trivia "general" question "What is 2+2?" 
    answers ["4", "3", "5", "6"];

Leaderboards

create leaderboard "games" {
    display: top 10;
    type: wins;
}

// Update leaderboard
on game win {
    update leaderboard "games" for {user} score (user-wins);
}

💰 Economy System

Coin Operations

// Give coins
give coins {user} amount (100);
give coins {user} amount (random(50, 200));

// Remove coins
subtract coins {user} amount (50);

// Check balance
set user-coins to (database get "coins" for {user});
reply("💰 You have {user-coins} coins!");

Daily Rewards

on slash command {
    if (command-name == "daily") {
        if (user last daily greater than 24 hours ago) {
            set reward to (random(50, 200));
            give coins {user} amount (reward);
            reply("🎁 Daily reward claimed! You received {reward} coins!");
            database store "last_daily" for {user} value (current time);
        } else {
            reply("⏰ You already claimed your daily reward! Try again tomorrow.");
        }
    }
}

Shop System

create shop {
    item "VIP Role" price 1000 coins action (give user role "VIP");
    item "Custom Color" price 500 coins action (create role for {user});
    item "Server Boost" price 2000 coins action (boost server);
}

on slash command {
    if (command-name == "shop") {
        embed_builder {
            title("🛒 Server Shop");
            description("Spend your coins on awesome items!");
            color("#FFD700");
            field("VIP Role", "1000 coins", true);
            field("Custom Color", "500 coins", true);
            field("Server Boost", "2000 coins", true);
        }
        reply with embed;
    }
}

🤖 AI Integration

AI Chat

enable ai chat {
    model: "gpt-3.5-turbo";
    personality: "friendly coding assistant";
    trigger: mention bot OR dm;
}

on message {
    if (message mentions bot) {
        set response to (ai generate text message-content);
        reply(response);
    }
}

AI Image Generation

on slash command {
    if (command-name == "generate") {
        set prompt to (command option "prompt");
        set image to (ai generate image prompt);
        
        embed_builder {
            title("🎨 AI Generated Image");
            description("Prompt: {prompt}");
            image(image);
            color("#FF6B6B");
        }
        reply with embed;
    }
}

Smart Moderation

create smart moderation {
    detect: spam, toxicity, nsfw;
    action: warn, timeout, ban;
    toxicity threshold: 0.7;
    spam detection: enabled;
}

on message {
    set moderation to (ai moderate content message-content);
    
    if (moderation.toxic == true AND moderation.confidence > 0.8) {
        delete message;
        timeout user {user} for ("5 minutes");
        reply("⚠️ Message removed for inappropriate content.");
    }
}

🔒 Security & Privacy

Advanced Security

enable security monitoring {
    detect: suspicious_links, mass_mentions, raid_attempts;
    response: auto_ban, alert_staff, lockdown_server;
}

on message {
    set activity to (detect suspicious activity for {user});
    if (activity.suspicious == true) {
        log security event "suspicious_activity" for {user} with {
            confidence: activity.confidence;
            reason: activity.reason;
        };
        
        if (activity.confidence > 0.9) {
            alert security team;
            timeout user {user} for ("1 hour");
        }
    }
}

Privacy Controls

create privacy settings {
    data_retention: 90 days;
    user_data_export: enabled;
    gdpr_compliance: true;
}

on slash command {
    if (command-name == "export-data") {
        set user-data to (export user data for {user});
        send dm to {user} with "📄 Your data export is ready!";
    }
    
    if (command-name == "delete-data") {
        delete user data for {user};
        reply("✅ Your data has been deleted from our systems.");
    }
}

🎵 Music & Voice

Music Playback

on slash command {
    if (command-name == "play") {
        if (user not in voice channel) {
            reply("❌ You must be in a voice channel!");
            return;
        }
        
        join voice channel;
        set song to (command option "song");
        play music from youtube (song);
        reply("🎵 Now playing: {song}");
    }
    
    if (command-name == "queue") {
        set queue to (get music queue);
        embed_builder {
            title("🎵 Music Queue");
            description("Current queue");
            color("#1DB954");
        }
        reply with embed;
    }
}

Voice Activity Rewards

on voice join {
    if (voice channel name contains "Gaming") {
        set bonus-multiplier to (2);
        log("{user} joined gaming voice - 2x rewards active!");
    }
}

on voice leave {
    set session-time to (get voice session time);
    if (session-time > 600000) { // 10 minutes
        set coins-earned to (session-time / 60000 * bonus-multiplier);
        give coins {user} amount (coins-earned);
        send dm to {user} with "🎤 Voice session complete! Earned {coins-earned} coins!";
    }
}

🌍 Multi-Language Support

Language Detection & Translation

on message {
    set user-language to (detect language from message-content);
    set language for {user} to (user-language);
}

on slash command {
    if (command-name == "help") {
        reply in user language ("Welcome to our server!");
        // Automatically translates to user's language
    }
}

Custom Translations

create translations {
    english: "Welcome to the server!";
    spanish: "¡Bienvenido al servidor!";
    french: "Bienvenue sur le serveur!";
    german: "Willkommen auf dem Server!";
    japanese: "サーバーへようこそ!";
}

add translation "goodbye" "spanish" "¡Adiós!";
add translation "goodbye" "french" "Au revoir!";

🔧 Advanced Features

Custom Functions

define function calculate-level(xp) {
    return (sqrt(xp / 100));
}

define function get-bonus(level) {
    return (level * 10 + random(5, 15));
}

// Use functions
set user-level to (calculate-level(user-xp));
set bonus to (get-bonus(user-level));

Rate Limiting

set rate limit for command "daily" to (1 per 24 hours);
set rate limit for command "work" to (3 per 1 hour);

on slash command {
    if (NOT check rate limit for {user} command "daily") {
        reply("⏰ You can only use this command once per day!");
        return;
    }
}

Permission Groups

create permission group "Moderators" with permissions ["KICK_MEMBERS", "BAN_MEMBERS"];
create permission group "VIP" with permissions ["MANAGE_MESSAGES"];

on slash command {
    require permission "ADMINISTRATOR";
    // Command only works for administrators
}

Scheduled Tasks

schedule task every (1 hour) {
    log("Hourly maintenance task running");
    clear cache;
}

schedule task in (5 minutes) {
    send message to channel ("announcements") with ("Server restart in 5 minutes!");
}

Webhooks & External Integrations

// GitHub integration
connect github "username/repo" {
    on push: notify channel "dev-updates";
    on issue: create ticket;
    on release: announce in channel "releases";
}

// Custom webhooks
create webhook endpoint "/github" {
    on receive {
        set commit-message to (webhook data commits[0].message);
        send message to channel ("dev-log") with ("New commit: {commit-message}");
    }
}

// Send webhooks
send webhook to "https://example.com/webhook" with "Hello from dBot!";

Forms & Modals

on slash command {
    if (command-name == "feedback") {
        create modal "feedback-form" {
            field "subject" type "text" {
                label: "Subject";
                required: true;
            }
            field "message" type "textarea" {
                label: "Your feedback";
                required: true;
            }
        }
        show modal to {user};
    }
}

on form submit {
    if (form-id == "feedback-form") {
        set subject to (form field "subject");
        set message to (form field "message");
        
        send message to channel ("feedback") with ("New feedback from {user}: {subject}");
    }
}

Backup & Recovery

schedule backup every day at 3:00 AM {
    backup: [user_data, server_settings, custom_commands];
    storage: cloud;
    retention: 30 days;
}

on server crash {
    restore from latest backup;
    notify administrators;
    log incident;
}

📊 Analytics & Monitoring

Built-in Analytics

track metrics {
    command_usage: enabled;
    user_activity: enabled;
    error_tracking: enabled;
}

on slash command {
    track event "command_used" with {
        command: command-name;
        user: {user};
        server: {server};
    };
}

Performance Monitoring

on ready {
    enable debug mode {
        log_level: info;
        show_performance: true;
        error_reporting: enabled;
    };
}

schedule health check every 1 minute {
    check: database_connection, memory_usage, response_time;
    
    if (any check fails) {
        alert monitoring system;
        attempt auto recovery;
    }
}

🏢 Enterprise Features

Multi-Bot Configuration

configure bot "MainBot" {
    token: env("MAIN_BOT_TOKEN");
    intents: ["guilds", "guild messages", "message content"];
}

configure bot "MusicBot" {
    token: env("MUSIC_BOT_TOKEN");
    intents: ["guilds", "guild voice states"];
}

on ready {
    if (event-bot == "MainBot") {
        log("Main bot online");
    }
    elif (event-bot == "MusicBot") {
        log("Music bot online");
    }
}

Multi-Server Management

for server "ServerID1" {
    enable features ["economy", "games", "moderation"];
    set welcome-channel to ("welcome");
}

for server "ServerID2" {
    enable features ["music", "voice-rewards"];
    set music-channel to ("music-commands");
}

sync data between servers ["ServerID1", "ServerID2"] {
    sync: user_levels, global_bans;
    frequency: hourly;
}

📁 File Structure & Imports

Modular Code Organization

// main.dbot
import "commands/economy.dbot";
import "commands/games.dbot";
import "features/moderation.dbot";
import "config/settings.dbot";

on ready {
    log("Main bot loaded with all modules!");
}
// commands/economy.dbot
on slash command {
    if (command-name == "balance") {
        set coins to (database get "coins" for {user});
        reply("💰 Balance: {coins} coins");
    }
    
    if (command-name == "work") {
        set earnings to (random(10, 50));
        give coins {user} amount (earnings);
        reply("💼 You worked and earned {earnings} coins!");
    }
}

🛠️ CLI Usage

Command Line Interface

# Run a bot file
dbot run my-bot.dbot

# Transpile to JavaScript without running
dbot transpile my-bot.dbot --output bot.js

# Validate syntax
dbot validate my-bot.dbot

# Create new bot template
dbot create my-new-bot --template gaming

# Install dependencies
dbot install

# Update dBot
dbot update

Environment Configuration

Create a .env file:

DISCORD_TOKEN=your_bot_token_here
OPENAI_API_KEY=your_openai_key_here
DATABASE_URL=your_database_url_here

Load environment variables:

load env from (".env");

set bot token to (env("DISCORD_TOKEN")) with name ("MyBot");

🎯 Complete Bot Examples

Community Bot

import "games.dbot";
import "economy.dbot";

set bot status to ("Managing") to ("{members} community members!");

on ready {
    log("🏠 Community Bot Online!");
    register slash command ("balance") with description ("Check your coins");
    register slash command ("daily") with description ("Claim daily reward");
    register slash command ("rps") with description ("Play Rock Paper Scissors");
}

on user join {
    give coins {user} amount (100);
    
    embed_builder {
        title("👋 Welcome to the Community!");
        description("Thanks for joining {server}!");
        color("#43b581");
        field("Starter Coins", "100 🪙", true);
        field("Daily Reward", "Use /daily", true);
        thumbnail("{user-avatar}");
    }
    send message to channel ("welcome") with embed;
}

on message {
    if (message-content length > 10) {
        set reward to (random(1, 3));
        give coins {user} amount (reward);
    }
}

Gaming Bot

import "games.dbot";
import "music.dbot";

set bot status to ("Playing") to ("games with {members} gamers!");

on ready {
    log("🎮 Gaming Bot Online!");
    register slash command ("tournament") with description ("Start tournament");
    register slash command ("stats") with description ("Gaming statistics");
}

on slash command {
    if (command-name == "tournament") {
        create tournament "weekly-rps" {
            game: rock-paper-scissors;
            duration: 1 week;
            prizes: [1000 coins, 500 coins, 250 coins];
        }
        reply("🏆 Tournament started! Use /rps to participate!");
    }
}

on voice join {
    if (voice channel name contains "Gaming") {
        set bonus-multiplier to (2);
        log("{user} joined gaming voice - 2x rewards!");
    }
}

Enterprise Bot

import "ai-features.dbot";
import "security-privacy.dbot";
import "backup-recovery.dbot";

enable security monitoring {
    detect: suspicious_links, mass_mentions, raid_attempts;
    response: auto_ban, alert_staff;
}

enable ai chat {
    model: "gpt-3.5-turbo";
    personality: "professional assistant";
}

schedule backup every day at 3:00 AM {
    backup: [user_data, server_settings, analytics];
    retention: 90 days;
    encryption: enabled;
}

on ready {
    log("🏢 Enterprise Bot Online - Full Security Suite Active!");
}

🔍 Troubleshooting

Common Issues

  1. Bot not responding to commands

    • Check if bot has proper permissions
    • Verify Discord token is correct
    • Ensure message content intent is enabled for message commands
  2. Database errors

    • Check database connection
    • Verify user data exists before accessing
  3. Permission errors

    • Bot needs appropriate server permissions
    • Check role hierarchy

Debug Mode

enable debug mode {
    log_level: debug;
    show_performance: true;
    error_reporting: enabled;
}

on error {
    log error to channel ("error-log");
    if (error-type == "permission-denied") {
        reply("❌ I don't have permission to do that!");
    }
}

📚 API Reference

Built-in Variables

  • {user} - Username of message author
  • {server} - Server name
  • {members} - Server member count
  • {user-avatar} - User avatar URL
  • {user-level} - User level (if using leveling system)
  • {user-coins} - User coin balance

Core Functions

  • database get "key" for {user} - Get user data
  • database store "key" for {user} value (data) - Store user data
  • give coins {user} amount (number) - Give coins to user
  • play game "game-name" with {user} - Start a game
  • ai generate image "prompt" - Generate AI image
  • reply("message") - Reply to command/message
  • log("message") - Log to console

Event Handlers

  • on ready - Bot startup
  • on message - Message received
  • on slash command - Slash command used
  • on user join - User joins server
  • on user leave - User leaves server
  • on voice join - User joins voice channel
  • on voice leave - User leaves voice channel
  • on error - Error occurred

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

📄 License

MIT License - see LICENSE file for details.

🔗 Links


dBot - Making Discord bot development accessible to everyone! 🚀