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

simply-discord

v1.2.1

Published

A simple and easy to use Discord bot command handler, built for Discord.js

Downloads

18

Readme

forthebadge forthebadge forthebadge

NPM

Simply Discord

A simple Discord bot command handler that is easy to use, built for Discord.js

const { client } = new SimplyDiscord({
  defaultPrefix: '-',
  commandsDir: './commands',
  eventsDir: './events',
  allowDMs: false
})

.setGuildPrefix('GUILD_ID', 'NEW_PREFIX')
.setCommandsDir('NEW_DIRECTORY')
.setEventsDir('NEW_DIRECTORY')
.setDefaultPrefix('NEW_DEFAULT_PREFIX')
.toggleDMs()
.reload();

Params:

| Param | Type | Info | ------------- | :---: | ------------- | | client | Discord.Client | The Discord client, if not passed one will be created | options | object | More info below

Available Options:

| Option | Type | Default | Info | | ------------- | :---: | :---: | ------------- | | options | object | undefined | Options to configure the handler | options.defaultPrefix | string | ! | Default prefix to use in-case of no guild prefix | options.commandsDir | string | ./commands | Folder containing all your commands | options.eventsDir | string | ./events | Folder containing your event files | options.allowDMs | boolean | true | Bot should respond in DMs?

Handler Functions:

// Example Functions
const Handler = new SimplyDiscord();

// Set the guild prefix
Handler.setGuildPrefix('714478443099873310', '-');

// Set the dir but do not reload commands
Handler.setCommandsDir('./commands/sub', false);

// Set the events dir
// By default it will reload commands/events
Handler.setEventsDir('./events/new');

// Manually reload commands/events (Default will reload both)
Handler.reload('commands'); // Reload just commands
Handler.reload('events'); // Reload just events
Handler.reload(); // Reload both

// Toggle DMs (Specify true/false or it will flip the current state)
console.log(Handler.allowDMs) // Output -> True
Handler.toggleDMs();
console.log(Handler.allowDMs) // Output -> False

| Function | Params | Info | | ------------- | :---: | ------------- | | setCommandsDir | ('Directory') | Update the folder where your commands are located | | setDefaultPrefix | ('Prefix') | Update the default prefix | | setGuildPrefix | ('GuildID', 'Prefix') | Set the guild prefix to the client.prefixes collection | | setEventsDir | ('Directory') | Update the folder where your events are located | | toggleDMs | (true/false) | Toggle if DMs should be allowed, sending nothing with switch it | | reload | ('commands'/'events') | Reload commands/events or both |

Usage

Using the handler:

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

new SimplyDiscord(client, {
  commandsDir: 'lib/commands'
});

Note: Simply Discord will create a client for you if you don't provide one

const SimplyDiscord = require('simply-discord');

/* Client is a property of the SimplyDiscord Class, use this to access the Discord Client */
const { client } = new SimplyDiscord({ commandsDir: 'lib/commands' });

/* Assign it to a variable and use that to access the props and functions */

const simply = new SimplyDiscord({ commandsDir: 'lib/commands' });
const client = simply.client;

/*  Minimum usage  */

const simply = new SimplyDiscord();

Command Structure Example:

module.exports = {
  name: 'ping',
  aliases: ['p'],
  category: 'Utils',
  cooldown: 10, /* In seconds, this example is 10 seconds */
  async run ({ client, handler, message, args }) {
    // Your command code ...
  }
};

Event Structure Example:

module.exports = {
  name: 'ready',
  once: true,
  async run (client, handler, EVENT_PARAMS) {
    /* 
       EVENT_PARAMS are any params from the event itself, 
        check the Discord.js Docs for more info.
    */ 
  }
};

TODO