# handle.djs

> A simple and lightweight Discord.js command handler builder.

Latest version **0.0.1** (published 2020-09-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install handle.djs
pnpm add handle.djs
yarn add handle.djs
bun add handle.djs
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2020-09-07 |
| First published | 2020-09-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sawyer |
| Maintainers | trqckpady |
| Keywords | discord.js, discord, commands, command-handler, handle, djs |

## Links

- npm: https://www.npmjs.com/package/handle.djs
- npm.io page: https://npm.io/package/handle.djs

## Recent versions

- 0.0.1 (latest) — 2020-09-07

## README

# Handle.djs

A simple and lightweight Discord.js command handler builder.

### Installation

In your terminal, type the following command:
```
npm i handle.djs@latest
```

### Examples

Heres an example of how to make a handler!

Create a file called `handler.js` in your root directory (or wherever you have your bot's file):
```js
const Handler = require('handle.djs');
const CommandHandler = new Handler();

CommandHandler.set('prefix', '!')

CommandHandler.register('ping', msg => {
  msg.channel.send('Pong!');
});

module.exports = CommandHandler;
```

Then, you need to import your `CommandHandler` into your bot file, as well as add a `Client#on('message')` method with the callback set to `CommandHandler#handle`:

```js
const CommandHanlder = require('./handler');

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

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

client.on('message', CommandHandler.handle);

client.login(process.env.YOUR_BOT_TOKEN);
```

### Syntax

  - `[Class]` `Handler`
    - Constructor: `new Handler()`
    - Methods:
      - `[func] set(type, value)`
        - Sets a config variable for your handler
        - Examples:
          - `Handler#set('prefix', '!')`
      - `[func] register(cmd, callback, options)`
        - Registers a command that can be handled
        - Examples:
          - `Handler#register('ping', msg => msg.channel.send('Pong!'))`
          - `Handler#register('hi', msg => msg.channel.send('Hey!'), { prefixed: false })`
        - Options:
          - `[bool] Prefixed`
            - Determines whether or not if the command handler should check if the command was ran with the prefix
      - `[func] handle(msg, ...data)`
        - Handles a command by command name
        - Examples:
          - `Handler#handle(message)`
        - Please note this should not be called anywhere other than in a `Client#on('message', Handler.handle)` method.

### Requirements
  - Discord.js

### Contributing

Want to contribute to handle.djs? Great! You can make a pull request, fork the project, or submit an issue on our GitHub, [here](https://github.com/sqwwy/handle.djs)!

---
_Source: https://npm.io/package/handle.djs · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
