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

discord-bot-express

v1.1.1

Published

Discord Bot Framework for managing commands

Readme

Discord Bot Express

Discord Bot Framework for command management inspired by Express written in Typescript

Quick Start

$ npm install discord.js
$ npm install discord-bot-express

Setting up the commands

Check here for better example

var CommandManager=require("discord-bot-express").CommandManager;
const {NotABot}=require("discord-bot-express").BotMiddleware;

CommandManager.setPrefix("Bot "); //Bot prefix not required
CommandManager.use(NotABot); //Middleware that prevents bot from calling itself

// :<name> defines a parameter for the command with the given name
CommandManager.command("tts :langCode", setLanguage);  //Example
// :<name>* defines a multi-parameter for the command with the given name
CommandManager.command("tts :text*", speak);  //Example
// ?<name> defines a optional parameter for the command with the given name
CommandManager.command("news ?day", news);  //Example
// ?<name>* defines a multi-optional parameter for the command with the given name
CommandManager.command("news ?withWords*", newsSearch);

//With annonymous function
CommandManager.command("pick :option1 or :option2", function(msg, client, params){
    var options=[params.option1, params.option2];
    var rng=(Math.floor(Math.random() * 2) + 1) -1;
    msg.channel.send(options[rng]);
});

//with declared function
function sayHello(msg,client,params){
  msg.channel.send("Hello");
}
CommandManager.command("say hello", sayHello)
.setDescription("Says Hello");

//Example of middleware that prevents non shinobi users to use command
CommandManager.command("slap :user",Permissions.isShinobi, slap)
.setDescription("Slaps user");

//Example of a trigger word for the bot
CommandManager.trigger(StartsWith("Ok"),triggers.okBoomer);

//Export the CommandManager you defined
module.exports=CommandManager;

Setting up the bot

const CommandManager=require("./CommandManager"); //The CommandManager defined in the Setting up commands section
const secret = require("./secret.json"); //Json file with token given by discord
const discord = require("discord.js");
const client = new discord.Client();

client.login(secret.token);

client.on("ready",()=>console.log("Online"));

client.on("message",msg=>CommandManager.handleMessage(msg, client));

Making your own middleware functions

//Creating your own middleware function
function(msg,client,params,next){
  var condition;//Your condition for the middleware to pass
  if(condition){
    next();
  }
}

Examples

To view a working example of a bot with this framework, check here

Features

  • Command parsing abstraction
  • Simple command creation and organization
  • Simple trigger word creation and organization
  • Middleware pattern for modular command pipeline
  • Create your own middlewares and plug them in
  • Based on Express

Available Functions

CommandManager.setTriggerRate // Sets the rate with trigger words trigger
CommandManager.setPrefix //Sets the Bot prefix
CommandManager.use //Adds middleware that is going to be called before checking for commands or triggers
CommandManager.handleMessage //Takes in the msg and client from discord and runs the command or trigger if its called correctly
CommandManager.command //adds the command text and function that is going to be called
CommandManager.trigger //adds the trigger function and function that is going to be called
//Predefined functions to use as a trigger function you can you your own
TriggerBuilder.StarsWith
TriggerBuilder.EndsWith
TriggerBuilder.Includes
TriggerBuilder.Regex
TriggerBuilder.Matches

Contributing

$ git clone https://github.com/mundoex/discord-bot-express
$ npm install

Make a pull request with your changes Contributions, features request or any other kind of help are very welcome :)

License

MIT