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

commands-easy-discord

v2.3.8

Published

A simple command handler for Discord bots.

Readme

Commands Easy Discord

A simple command handler for Discord.js bots.

📦 Installation

To install the package, run the following command in the terminal:

npm install commands-easy-discord

🚀 Usage

1️⃣ Project Structure

Your project structure might look like this:

/my-bot
 ├── /commands
 │   ├── ping.js
 ├── bot.js

2️⃣ Create Commands

Create a file in the /commands folder, for example ping.js:

commands/ping.js

module.exports = {
    name: 'ping',
    description: 'Replies with Pong!',
    execute(message, args) {
        message.reply('🏓 Pong!');
    }
};

In this file, you're defining the ping command. When someone types !ping in the chat, the bot will respond with "🏓 Pong!".

3️⃣ Set up the Bot Code

Create a bot.js file (or name it whatever you like) in your main project folder and import commands-easy-discord:

bot.js

const { Client, GatewayIntentBits } = require('discord.js');
const { loadCommands } = require('commands-easy-discord');
require('dotenv').config();

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

// Load commands from the 'commands' folder
const commands = loadCommands('./commands');

client.on('messageCreate', async (message) => {
    if (!message.content.startsWith("!") || message.author.bot) return;

    const args = message.content.slice(1).trim().split(/ +/);
    const commandName = args.shift().toLowerCase();

    const command = commands.get(commandName);
    if (command) {
        command.execute(message, args);  // Execute the command
    }
});

client.login(process.env.TOKEN);  // Your bot token

4️⃣ Start the Bot

Once you've set up the code, you can start the bot by running the following command in the terminal:

node bot.js

Now, your bot will respond to commands like !ping and reply with "🏓 Pong!".

🌟 Features

Automatic Command Loading – All commands in the specified folder are automatically loaded.
Prefix Commands Support – Commands are triggered using a prefix (e.g., !).
Easy to configure – The command handler is simple to integrate and use.
Clean Code Structure – Each command is placed in its own file in the commands folder.

📂 Directory Structure

  • /commands – This folder contains all your command files.
  • bot.js – This file contains the Discord bot setup and command handler.

Troubleshooting:

  • Command not found: Ensure that the name property in your command file is correctly set (e.g., name: 'ping').
  • Bot is not responding: Make sure the bot is logged in with a valid token, and that the commands folder exists and contains correctly named files.

📝 License

This package is licensed under the MIT License.


---