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-constructor

v0.4.0

Published

Simple bot constructor for discord, based on Discord.js

Readme

Simple bot constructor for Discord

Overview

Simple bot constructor for discord, based on Discord.js, and written with TypeScript. Important! if you want to use randomMember slug, you need to turn on option SERVER MEMBERS INTENT in your application bot settings.

Links:

Requirements

Node.js 12 or newer.

Installation

For installation type npm i discord-bot-constructor

Documentation

See example here.

1. Init

Options:

  • token - your bot token
  • prefix - sign to start your command like / or $
  • config - see config section

Example:

const { BotConstructor } = require("discord-bot-constructor");

const botConstructor = new BotConstructor({
  token: string,
  prefix: string,
  config: BotConfig
});

2. Config

Options:

  • actions - list of actions
  • botState - set bot presence state (optional)
  • i18n - internalization (optional)

See example here.

Interface:

BotConfig {
  actions: BotAction[];
  botState?: BotState;
  i18n?: IterableData<string>;
}

2.1 Config actions

List of bot actions Options:

  • name - action name
  • type - list of available action types:
    • simple simple action without any params such as /rand
    • mention action that mention user /mention @User
    • text action with text parameter /bot random joke
    • nested for text type of action, using for nested text options
  • helpInfo - needed for /help action (optional)
  • children - combines with text action type, contains nested actions (optional)
  • phrases - list of text responses (can contain link) (optional), randomly take one from list. You can also use slugs in text:
    • {author} - insert message author
    • {mentionedUser} - insert mentioned user in action (works only witn mention action type)
    • {randomNumber} - insert random number between 1 and 100
    • {randomMember} - insert random guild member (if you want to use this one, you need to turn on option SERVER MEMBERS INTENT in your application bot settings)

Simple action example:

{
  name: "joke",
  type: "simple",
  helpInfo: "example of usage: '/joke'",
  phrases: [
    "{author}, may be you tell us one?",
    "Random decided, it's time {randomMember} to telling joke",
    "Most people are shocked when they find out how bad I am as an electrician"
  ]
}

Mention action example:

{
  name: "ping",
  type: "mention",
  helpInfo: "example of usage: '/ping @User'",
  phrases: [
    "{author} pinging {mentionedUser}",
    "{mentionedUser} is not answering"
  ]
}

Text action example:

{
  name: "random",
  type: "text",
  helpInfo: "example of usage: '/random command' (number, member)",
  children: [
    {
      name: "number",
      type: "nested",
      phrases: [
        "Random number is {randomNumber}"
      ]
    },
    {
      name: "member",
      type: "nested",
      phrases: [
        "Random member is {randomMember}"
      ]
    },
    {
      name: "image",
      type: "nested",
      phrases: [
        "https://cdn.spacetelescope.org/archives/images/wallpaper2/heic1509a.jpg",
        "https://cdn.spacetelescope.org/archives/images/wallpaper2/heic1501a.jpg",
        "https://cdn.spacetelescope.org/archives/images/wallpaper2/heic0506a.jpg",
      ]
    }
  ]
}

Interface:

BotAction {
  name: string;
  type: 'simple' | 'mention' | 'text' | 'nested';
  helpInfo?: string;
  children?: BotAction[];
  phrases?: string[];
}

2.2 Config botState (optional)

Setting bot status and presence.

Options:

  • activity - available options:
    • name - activity name
    • type - activity type:
      • PLAYING
      • STREAMING
      • LISTENING
      • WATCHING
    • url - url link (optional)
  • status - available bot statuses:
    • online
    • idle
    • dnd

Example:

{
  activity: {
    name: "testing bot",
    type: "PLAYING"
  },
  status: "online"
}

Interface:

BotState {
  activity: {
    name: string;
    type: 'PLAYING' | 'STREAMING' | 'LISTENING' | 'WATCHING';
    url?: string;
  }
  status: 'online' | 'idle' | 'dnd'
}

2.3 Config i18n (optional)

Translate default system messages.

Options:

  • actionNotFound - action not found
  • argumentNotFound - action not found
  • wrongMention - No user mentioned
  • wrongArgument - Invalid argument
  • helpInfoList - '/help list' - to see all actions
  • helpInfoAction - '/help action' - to get help about specific action
  • helpList - List of available actions:

Example:

{
  actionNotFound: "action not found",
  argumentNotFound: "action not found",
  wrongMention: "No user mentioned",
  wrongArgument: "Invalid argument",
  helpInfoList: "'/help list' - to see all actions",
  helpInfoAction: "'/help action' - to get help about specific action",
  helpList: "List of available actions:"
}