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 🙏

© 2024 – Pkg Stats / Ryan Hefner

discord-easy-slash

v1.1.2

Published

A library for making slash commands easy for discord bot developers!

Downloads

8

Readme

npm version

discord-easy-slash

A small library for making slash commands easy without using gateways or discord.js. Just the raw Discord Api.

Prerequisites

This project requires NodeJS (version 8 or later) and NPM. Node and NPM are really easy to install. To make sure you have them available on your machine, try running the following command.

$ npm -v && node -v
6.4.1
v8.16.0

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Installation

BEFORE YOU INSTALL: please read the prerequisites

To install and set up the library, run:

$ npm install discord-easy-slash

Or if you prefer using Yarn:

$ yarn add --dev discord-easy-slash

Usage

First, Start by importing the library

var client = require('discord-easy-slash');

Then, Provide all of your bot's details

client.PUBLIC_KEY = '<PUBLIC_KEY>'
client.TOKEN = '<TOKEN>'
client.APP_ID = '<APPLICATION_ID>'
client.GUILD_ID = 'GUILD_ID' // (you still need this, as you have to have a testing server)

Making a command:

client.command('help', 1, 'help command?', null)

The command function takes 4 arguments, Name (Of the command), Type (Of the command), Description (Of the command), and Options, any options that the command takes.

For types:

or look at this page by discord.

For options:

They look like this:

[ { "name": "nameofoption", "description": "descriptionofoption", "type": 4, "required": true, } ]

It takes an array, with all the options for the command. Because of this, you can have multiple options for a single command.

For types of objects: or look at this page by discord.

Main Event Listener:

client.on('slash_event', (command, data, res, type) => {
  console.log('slash event!')
})

The event listener only has 1 event to listen for as of 1.0.7: 'slash_event'(s).

slash_event takes 4 arguments, command, data, res, and type.

command is the name of the slash command that was sent.

data is the data that was sent with the command.

res is the response object that you can use to send a message back to the user.

and type is the type of the command.

client.on('slash-event', (command, data, res, type) => {
if(command == 'help'){
    client.reply(res, 'Help command?', null)
    }else {
        client.reply(res, 'Cound not find command..', null)
    }
});

client.reply takes 3 arguments, res, which is mandatory because it is used to send the message, message, which is the message to send, and embeds, which is an array of embeds for the command to send.

For embeds:

[ { "title": "title", "description": "description", "color": "color", "fields": [ { "name": "name", "value": "value", "inline": true }, { "name": "name", "value": "value", "inline": true } ] } ]

Making our bot search for interactions/logging-in/turning it on:

client.listen(80)

Telling Discord where to look for our bot:

Inside the INTERACTION ENDPOINTS URL box, put in the url of the server your bot is running on, with the endpoint "/event". For example: https://server_address/event

or discord.com/developers/applications/<APP_ID>/information

Serving the app

$ npm start

Contributing

You can contribute to the project by making a pull request on GitHub.

Credits

Amukh1.

Built With

Authors

See also the list of contributors who participated in this project.

License

MIT License © Amukh1