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 🙏

© 2025 – Pkg Stats / Ryan Hefner

simple-commands.js

v1.0.6

Published

This is a simple command loader and clearer for discord.js

Readme

Simple-commands.js

A module for creating and registering commands in a Discord bot.

Installation

To install the simple-commands.js module, run the following command:

npm i simple-commands.js

Usage

First, import the module into your code:

const { commands } = require('simple-commands.js');

To use the module, you can make the following function calls:

await commands.load(process.env.CLIENT_ID)
await commands.register(client, loadedCommands, guildId)
await commands.clear(client, process.env.CLIENT_ID)

The loadedCommands variable represents the result of the commands.load function:

const loadedCommands = await commands.Load(process.env.CLIENT_ID);

Once you have set up your code correctly, you can run it. When you run the code, it will prompt you to create a commands folder.

The module will create two subfolders: "Admin" and "Entertainment". However, you are not restricted to these. You can have as many subfolders as you want with any name.

Here's an example of how to use the simple-commands.js module in your Discord bot:

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

// Load the environment variables from the .env file
config();

// State which intents your bot will need
const client = new Client({
  intents: [
    GatewayIntentBits.Guilds,
    GatewayIntentBits.GuildMessages,
    GatewayIntentBits.MessageContent,
    GatewayIntentBits.GuildVoiceStates,
  ],
});

// Login with the provided token
client.login(process.env.TOKEN).then(async () => {
  // Check if the user wants the commands to be cleared from the Discord commands list
  if (process.env.CLEAR_COMMANDS === 'yes') {
    // Use simple-commands.js to clear the commands
    await commands.clear(client, process.env.CLIENT_ID);
  } else {
    // If the user stated they do not want to clear commands,
    // then load the commands into the bot file using the simple-commands.js module
    const loadedCommands = await commands.load(process.env.CLIENT_ID); // Await the result of the load function
    const guildId = process.env.GUILD_ID;
    // Use the simple-commands.js module to finally register the commands with Discord
    commands.register(client, loadedCommands, guildId);
  }
});

Configuration

Before using the simple-commands.js module, make sure to set the following environment variables:

  • TOKEN: Your bot's authentication token.
  • GUILD_ID: The ID of your bot's test server.
  • CLIENT_ID: Your bot's client ID.
  • CLEAR_COMMANDS: Specify whether to clear your bot's commands from the Discord commands list (set to "yes" or "no").

Make sure to set these variables in a .env file in the root directory of your project.

Commands Format

Unfortunately simmple-commands.Js was based off of @discordJs/builders As of right now this will prevent you using legacy commands e.g. !ping. you will have to use /ping. Although nothing is preventing you from leaving legacy commands in your main file. Do not worry we will change this in the future, I have lots of plans before i do that though.

const { SlashCommandBuilder } = require('@discordjs/builders');

module.exports = {
  // Define the slash command data
  // The name and description are required
  data: new SlashCommandBuilder()
    .setName('command')
    .setDescription('Does command stuff')
    .addStringOption((option) =>
      option
        .setName('commandOption')
        .setDescription('Tells the user what the option includes, e.g., has to be a user')
        .setRequired(true)
    ),

  async execute(interaction) {
    // Add your command code here
    const command = interaction.options.getString('commandOption').toLowerCase();
  },
};