better-handler
TypeScript icon, indicating that this package has built-in type declarations

0.2.0 • Public • Published

Better Handler


npm version github code size license


A DJS Command Handler to make it easier to handle both Prefixed Legacy Commands (e.g. !ping) and Slash Commands.

Table of Contents

Installation

npm install better-handler

Setup

const path = require('node:path');
// or require('path')

const { CommandHandler } = require('better-handler');

new CommandHandler(client, {
    prefix: 'PREFIX_HERE',
    path: path.join(__dirname, 'commands'),

    // If you don't want the
    // Command Handler to Log then
    // set 'log' property to false.
    log: false,
})

Note: It's important to use path.join otherwise the command handler won't find the folder!

Parameters

  • client (Client) - Requires you to pass in Client class from discord.js Client

  • options (CommandHandlerOptions) - Options for the Command Handler

    • CommandHandlerOptions
      • prefix (string) - Your prefix
      • path (string) - Path to the commands folder
      • log (boolean, optional) - If you want the Command Handler to Log the status of the Handler.

Command Options

Available Command Options for your commands:

name

The name of the command

  • [x] Required
  • type: string

execute

The main function to run your command

  • [x] Required
  • type: Function
(JS) Example
module.exports = {
    name: 'ping',

    async execute(message) {
        return [{
            content: `Pong! | ${message.client.ws.ping}ms`,
        }, true];
    },
};

Return type: CommandReturnOptions

CommandReturnOptions can be: string, [MessageOptions|MessagePayload|ReplyMessageOptions, boolean?], void

Links to Typedefs and Classes

MessageOptions

MessagePayload

ReplyMessageOptions

reqArgs

The required length of argument(s) needed to run the command

  • type: number

Status

Currently, better-handler is just your average command handler since I'm still thinking about how the design should be.

Package Sidebar

Install

npm i better-handler

Weekly Downloads

0

Version

0.2.0

License

MIT

Unpacked Size

13.5 kB

Total Files

7

Last publish

Collaborators

  • loldonut