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

custom-discord-bot

v3.0.0

Published

A powerful, customizable Discord bot framework with embeds, cooldowns, aliases, middleware, function commands, and real-time stats — built with OceanicJS.

Readme

Custom Discord Bot 🤖

Free to use!
⚡ A powerful, feature-rich Discord bot framework built with Oceanic.js. Create bots in minutes with embeds, cooldowns, aliases, function commands, middleware, real-time stats, and more!

NPM Version
Downloads
License


🆕 What's New in v3.0.0

🔥 Embed Support – Send rich embed messages as command responses
🔥 Cooldown System – Prevent command spam with configurable cooldowns
🔥 Command Aliases – Multiple triggers for the same command
🔥 Function Commands – Execute custom logic with (message, args) => {}
🔥 Middleware – Intercept and filter messages before command processing
🔥 Dynamic Placeholders – Use {user}, {server}, {args}, {uptime} in responses
🔥 Runtime Commands – Add/remove commands while bot is running
🔥 Event System – Listen to ready, message, commandUsed, error, disconnect
🔥 Bot Stats – Track uptime, command usage, and more
🔥 Class-based API – New DiscordBot class with full control
🔥 100% Backwards CompatiblestartBot() still works!


📦 Installation

npm install custom-discord-bot

🚀 Quick Start (Simple)

const { startBot } = require("custom-discord-bot");

startBot({
  token: "YOUR_DISCORD_BOT_TOKEN",
  prefix: "!",
  status: "online",
  statusMessage: "Listening to commands! 🎧",
  statusType: 2,
  cooldown: 3, // 3 second cooldown between commands
  commands: {
    "ping": "Pong! 🏓",
    "hello": "Hello {user}! Welcome to **{server}**! 👋",
    "say": "You said: {args}",
    "uptime": "🕐 Bot uptime: {uptime}",
  },
  aliases: {
    "p": "ping",
    "hi": "hello",
  }
});

🏗️ Advanced Usage (Class API)

const { DiscordBot } = require("custom-discord-bot");

const bot = new DiscordBot({
  token: "YOUR_DISCORD_BOT_TOKEN",
  prefix: "!",
  cooldown: 5,
  logCommands: true,
  commands: {
    "ping": "Pong! 🏓",
    
    // 🔥 Embed response
    "info": DiscordBot.createEmbed({
      title: "Bot Information",
      description: "I'm a powerful custom bot!",
      color: 0xff6b6b,
      fields: [
        { name: "Version", value: "3.0.0", inline: true },
        { name: "Library", value: "Oceanic.js", inline: true },
      ],
      footer: "Made with ❤️",
    }),

    // 🔥 Function command with custom logic
    "roll": (message, args) => {
      const max = parseInt(args[0]) || 6;
      const result = Math.floor(Math.random() * max) + 1;
      message.channel.createMessage({ content: `🎲 You rolled a **${result}**!` });
    },

    // 🔥 Function command with async
    "userinfo": async (message, args) => {
      const user = message.author;
      const embed = DiscordBot.createEmbed({
        title: `${user.username}'s Info`,
        thumbnail: user.avatarURL(),
        fields: [
          { name: "ID", value: user.id, inline: true },
          { name: "Created", value: new Date(user.createdAt).toLocaleDateString(), inline: true },
        ],
        color: 0x5865f2,
      });
      message.channel.createMessage({ embeds: [embed] });
    },
  },
  aliases: {
    "dice": "roll",
    "me": "userinfo",
  },
});

// 📡 Event listeners
bot.on("ready", (client) => {
  console.log(`Connected to ${client.guilds.size} servers!`);
});

bot.on("commandUsed", ({ command, user, args }) => {
  console.log(`📊 ${user} used !${command} with args: [${args}]`);
});

bot.on("error", (err) => {
  console.error("Bot error:", err.message);
});

// 🚀 Start the bot
bot.start();

// ➕ Add commands at runtime
setTimeout(() => {
  bot.addCommand("late", "I was added after the bot started! ⏰", ["delayed"]);
}, 5000);

📌 Configuration Options

| Option | Type | Default | Description | |---|---|---|---| | token | string | Required | Your Discord bot token | | prefix | string | "!" | Command prefix | | status | string | "online" | Bot status (online, dnd, idle) | | statusMessage | string | "" | Custom status message | | statusType | number | 0 | Activity type (0: Playing, 1: Streaming, 2: Listening, 3: Watching) | | avatarUrl | string | "" | Bot avatar URL | | username | string | "" | Bot username | | commands | object | {} | Commands { "cmd": "response" \| embedObj \| function } | | aliases | object | {} | Aliases { "alias": "originalCommand" } | | cooldown | number | 0 | Cooldown per user per command in seconds | | onReady | function | null | Callback when bot is ready | | onMessage | function | null | Message middleware (return false to block) | | onError | function | null | Custom error handler | | autoReconnect | boolean | true | Auto-reconnect on disconnect | | logCommands | boolean | true | Log command usage to console |


🧩 Response Types

String Response (with placeholders)

"Hello {user}! Welcome to {server}!"

Available: {user}, {server}, {args}, {uptime}

Embed Response

DiscordBot.createEmbed({
  title: "My Embed",
  description: "Rich embed content",
  color: 0xff0000,
  fields: [{ name: "Field", value: "Value", inline: true }],
  footer: "Footer text",
  thumbnail: "https://example.com/image.png",
  image: "https://example.com/banner.png",
})

Function Response

(message, args) => {
  message.channel.createMessage({ content: `You said: ${args.join(" ")}` });
}

📊 Bot Stats

const stats = bot.getStats();
console.log(stats);
// { uptime: "2h 15m 30s", totalCommands: 142, commandBreakdown: { ping: 50, hello: 92 }, ... }

🛠️ Contributing

Pull requests are welcome! Fork the repo, create a branch, and submit a PR. 🚀


📜 License

This project is licensed under the MIT License.


🌟 Support & Contact

🚀 Now go build something awesome! 🎮✨