Fisherman Command Loader
Loads commands from files in a directory
Set up
npm install --save command-loader-fisherman
Include the middleware to the bot:
...const CommandLoader = var commandLoader = path //the command dirbot...
Adding commands
As you can see, you initialize the CommandLoader with a directory, use path.resolve() to get the full path directory location (since fs.stat()
is used).
Commands are loaded once you initialize middlewares with fisherman.
Each commands should be in a subfolder, named like the register name.
A _register.json
as to be present in each register directory
Tree example (C = commands folder):
C:├───core│ help.js│ _register.json│└───giveaways giveaway.js _register.json
Each javascript file inside will be loaded, which should contains a exported command object
Javascript command file
You just have to export a command object, like this:
Example: help command (named help.js
, in core dir)
var helpMessageBuilt = nullmoduleexports = name: 'help' { if helpMessageBuilt res return var embed = title: 'Bot help' var description = '' var commands reqclientregisters embeddescription = description helpMessageBuilt = embed res } channelType: 'dm' 'text'
_register.json file
This file contain register properties, it has to appear in each register directory:
There are only 3 properties:
Name | Description |
---|---|
key | Register key name (used in register map of fisherman) |
name | Register name |
description | Register description |
All those property have default value = null
Example: