1.1.5 • Published 6 years ago

bot-command-loader v1.1.5

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

Easily create and load bot commands. Simply create a directory and place your command files inside, specifying a single config, help, and run property as your exports (Examples - 1). Each FILE inside your commands folder represents a single command (file name is not required to be the command name, as your properties specify such). Each FOLDER inside your commands folder represents a command group (folder name matches the group name).

Installation

npm i bot-command-loader

Usage

1) function buildList(cmdDirPath, defCmdPrefix): creates and returns a list of commands for the directory reading to add to. Takes the path to your command directory and your preferred default prefix as parameters. 2) function createManager(cmdDirPath, defCmdPrefix): creates and returns a default manager to allow quick setup of parsing messages for commands and their required info. Takes the path to your command directory and your preferred default prefix as parameters.

Examples

1 (Ex. Command File Setup)

exports.config = {
  enabled: true,
  aliases: [],
  default: false,
  dm_usable: true;
};

exports.help = {
  name: 'ping',
  description: 'Ping/Pong command. I wonder what this does? /sarcasm',
  usage: 'ping'
};

exports.run = {
  discord: function(cmdParams) {
    var message = cmdParams['message'];
    message.channel.send('Ping?').then(function(msg) {
      msg.edit(`Pong! (${msg.createdTimestamp - message.createdTimestamp}ms)`);
    });
  }
};

2 (Ex. Function Calls)

const CommandManager = require('bot-command-loader').createManager('./commands', '>');
const CommandList = require('bot-command-loader').buildList('./commands', '>');
1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago