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

zoro-utils

v3.7.4

Published

discord.js utilities, command handler, event handler

Downloads

20

Readme

zoro-utils

npm install zoro-utils

handler

example

main file

const zoroUtils = require('zoro-utils');
const discordJS = require('discord.js');
const client = new discordJS.Client();

new zoroUtils.handler(client, {
	commands: './commands',
	events: './events',
	commandTable: false,
})
	.setPrefix(';')
	.setOwners([]);

client.login('super_secret_token');

takes 2 paramaters. A instance of a discord.js Client, and options

options

commands - relative path to commands folder - String

events - relative path to events folder - String

commandTable - whether or not you want a table to print with commands - Boolean

methods

setPrefix(prefixString)

sets the bot prefix

default: !

setOwners(ownerArray)

sets the bots owners

default: []

setDefaultCooldown(cooldownNumber)

set the default command cooldown aka rate limit

cooldown is in seconds

default: 3

commands

all commands should export an object

the object must have a name property, and an execute function to load

paramaters use object destructuring, available paramaters incude:

message - message object

args - args array

handler - handler instance

client - client instance

folder structure

commands can be in as many subfolders as you would like, or not in a subfolder at all

for example

commands/general/dir/dir2/dir3/ping.js would still work

and so would commands/ping.js

properties

name - name of command - String

aliases - array of names the command can be run from - Array

reqArgs - args array length requried - Number

usage - command usage - String

nsfw - if command should only work in nsfw channels - Boolean

ownerOnly - if command should only let owners use command - Boolean

botPerms - list of required permissions for the bot to run the command - Array

userPerms - list of required permissions for the user to run the command - Array

reqRole - certain role needed for a user to run a command. must be a role name - String

you can add some if you would like, for a help command you may want a description as well.

example

commands/pings.js

module.exports = {
	name: 'ping',
	aliases: ['p'],
	cooldown: 10, // seconds
	reqArgs: 0,
	usage: 'example',
	nsfw: false,
	ownerOnly: false,
	userPerms: ['ADMINISTRATOR', 'more', 'more'],
	botPerms: ['ADMINISTRATOR'],
	reqRole: 'role name',
	init(client, handler) {
		console.log('This function runs when the command loads');
		/*
		This is useful for things like caching
		or just more logging.
		This is optional
		*/
	},
	execute({ message, args, handler, client }) {
		message.channel.send('pong');
	},
};

events

all events export a function.

name of file is the name of the event

all default events can be over rided by making an event with the same name as the default event

paramaters include (client, handler, whatever, params, required, for, event)

folder structure

events can be in as many subfolders as you would like, or not in a subfolder at all

for example

events/message/dir/dir2/dir3/message.js would still work

and so would events/message.js

example

events/ready.js

module.exports = (client, handler) => {
	console.log(`Logged in as ${client.user.tag}`);
};

events/message.js

module.exports = (client, handler, message) => {
	console.log('I seen that');
};

Features

features can be in as many subfolders as you would like. Or not in any.

for example

features/dir/dir2/dir3/message.js would work and so would features/message.js

features should export a function with 2 paramaters. paramaters are client and handler

for example

features/test.js

module.exports = (client, handler) => {
	client.on('message', (message) => {
		console.log(message.content);
	});

	client.on('ready', () => {
		console.log('ready');
	});
};

You can have as many features as you would like in the same file, or in different files.

utils

to use utils inside of commands use handler.utils.function

for example

module.exports = {
	name: 'formatNumber',
	execute({ message, args, handler }) {
		const num = parseInt(args[0]);
		const formattedNum = handler.utils.formatNumber(num);

		message.channel.send(formattedNum);
	},
};

formatNumber(Number) if a number is not passed in returns NaN if number is passed in, returns number with commas in correct place


comparePerms(member, target)

member and target, both need to be 2 differnt member objects

returns if the target has higher roles in the hierarchy or not