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

patron.js

v3.1.0

Published

The cleanest command framework for discord.js and eris.

Downloads

1,427

Readme

About

Patron.js is an efficient, stable and reliable command framework for discord.js and eris, that aims for true flexibility. This framework does not have it's own client, it does not manage the message event for you, it does not clutter the library's classes with extensions and it most certainly does not send messages on your behalf.

Official example

Patron.js has an official example filled with useful comments, allowing you to build your code on a solid base while learning at the same time. This example will be maintained and updated to ensure it will always be a useful reference for beginners. The example may be viewed here.

Command Results

Every single command execution returns a result object. This result object will always have the success property. If the command execution was unsuccessful, this property will be set to false. If this is the case, the result will also have the commandError property, allowing you to handle the error and respond (or not) accordingly. These are the current command errors:

  • BotPermission
  • Command
  • Cooldown
  • Exception
  • InvalidArgCount
  • InvalidContext
  • MemberPermission
  • Precondition
  • TypeReader
  • UnknownCmd

Depending on which error occurred, the result object will have different properties. This is an example (discord.js/eris) of how these errors may be handled.

Arguments

Patron.js's arguments allow for contextual default values. For example, if you have a user argument in your command, you can set the default of this argument to ArgumentDefault.Author. This enum allows you to set defaults of arguments based on the context in which the command was used.

Furthermore, this framework has featured, efficient and reliable type readers. For example, the user type reader can parse a user object based off of an id, mention, username, or nickname (if they are in a guild). If there are multiple matches found, it will return an unsuccessful TypeReaderResult with the matches in question in the error reason. If there are too many matches to list, it will simply ask the user to be more specific. All available type readers are here.

This is an example (discord.js/eris) of how to make use of this argument system. As you can see, all examples are argument specific, which is the best approach for maintainability. Most command frameworks will allow you to provide an example string for each command, however, these examples are often forgetten and not updated while the arguments themselves change, leaving inconsistencies throughout the commands. Not to mention this system allows you to create a single commonly used argument object, such as a user, and share this accross all files, to prevent redudancy and code repetition, while still allowing for the command usage example to always be up to date.

Preconditions

There are currently two types of preconditions: Preconditions and Argument Preconditions. Normal preconditions can be added on any on Command or Group, while argument preconditions may only be added to arguments. All preconditions must return a PreconditionResult. If the result in question is unsuccessful, it will be the returned result in the command handler.

Support

The best place to get support for patron.js is in our official support server. We try to keep things spicy, so you can joke around while getting good, pretty slamming combo. Keep in mind this framework is not meant for new coders, it is meant for people that want a genuinely reliable command framework and more maintainable code overall.