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

slash-command-discord.js

v1.3.0

Published

It is a simple module for discordjs with the intention of facilitating and accelerating the process of creating slash commands.

Downloads

2

Readme

Documentation

Here you can learn how to use this module.

Note: The discord api updates the commands every hour, if you want your command to be seen before just eject and install your bot back to your server.

Note: This command is oriented to discord.js so it is recommended that you have it installed.

Note: All methods and events in the module are recommended to be placed in the bot's ready event, because if the client is not ready, the module is quite prone to failure (except for classes and their methods, they do not need it).

Note: Remember to invite your bot with the oauth guilds.commands, if you don't do this, slash commands won't work.

Classes

SlashBaseModule()

Properties

data: This property stores the data as it will be sent to the discord api.

Methods

setName(string Name): Sets the command name.

setDescription(string Description): Sets the command description.

SlashMessage()

Properties

interaction: The interaction returned by the discord api.

member: this is the interaction returned by the discord api.

name: The command name.

id: the interaction id.

createdAt: this is the interaction returned by the discord api.

client: the client who received the command.

options: returns an array containing the options that were chosen or specified by the user.

Methods

reply(string message): responds to the command.

SlashCommand(guildId [Optional]) extended from SlashBaseModule

Properties

data.options: Here are stored the options that the command will have.

guildId: This is the id of the server for which the command was created, in case no server is specified, the command will be global and this property will be undefined.

Methods

addOption(class slashOption): An option is added to the command.

slashOption() extended from SlashBaseModule

Properties

data.choices: Here are stored the choices that are added.

data.type: Here you specify the type of option that will be this,

Methods

setType(string type): Sets the option type, these are the types availables: subCommand, subCommandGroup, string, integer, boolean, user, channel, role.

isRequired(bool enabled): Make this option a obligatory option.

addChoice(string name, string value): A choice is added to the option.

Module Methods

post(client Client): With this method you create or update the commands created.

getPostedCommands(client Client, snowflake guildId [Optional]): returns an array with all the commands created and usable for the user.

removeCommand(client Client, snowflake id, snowflake guildId [Optional]): deletes a command already created using its id, it can be obtained with the getPostedCommands method.

Module Events

onSlashCommand(client, function): returns a slashMessage each time a command is used.

Examples

const Discord = require('discord.js');
const client = new Discord.Client();

const slashManager = require('slash-command-discord.js'); 

client.login(process.env.token)

const test = new slashManager.command() // creating a new command

test.setName("My first command") // setting the command name
test.setDescription("This is my first slash command.") // setting the command description

client.on('ready', () => {

     slashManager.onSlashCommand(client, (command, interaction) => { // a listener for every time a command is used
    
         console.log(command);

         command.reply(`Used command: ` + command.name); // respond to the user

    })

    slashManager.post(client); // Posting the command, to make it visible on all servers

})