better-handler
v0.2.0
Published
A package for DJS to both handle Slash Commands and Prefixed (Legacy) Commands
Downloads
4
Maintainers
Readme
Better Handler
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.jsClient
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.
- CommandHandlerOptions
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
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
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.