|
|
@ -12,7 +12,7 @@ let logger = require('winston'),
|
|
|
|
exports.Servant = class {
|
|
|
|
exports.Servant = class {
|
|
|
|
constructor(prefix) {
|
|
|
|
constructor(prefix) {
|
|
|
|
this.commands = {};
|
|
|
|
this.commands = {};
|
|
|
|
this.createCommand(((prefix || '~')+'help') || "~help", () => {
|
|
|
|
this.createCommand(((prefix || '~') + 'help') || "~help", () => {
|
|
|
|
let helpstr = "```markdown\n";
|
|
|
|
let helpstr = "```markdown\n";
|
|
|
|
helpstr += "Commands\n---\n";
|
|
|
|
helpstr += "Commands\n---\n";
|
|
|
|
// TODO: Duplicate commands should not appear or make two sections, one with global commands, one with server commands
|
|
|
|
// TODO: Duplicate commands should not appear or make two sections, one with global commands, one with server commands
|
|
|
@ -78,7 +78,7 @@ exports.Servant = class {
|
|
|
|
* Getting the logger
|
|
|
|
* Getting the logger
|
|
|
|
* @param {Object} newLogger
|
|
|
|
* @param {Object} newLogger
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
exports.setLogger = function(newLogger) {
|
|
|
|
exports.setLogger = function (newLogger) {
|
|
|
|
logger = newLogger;
|
|
|
|
logger = newLogger;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -89,7 +89,7 @@ exports.setLogger = function(newLogger) {
|
|
|
|
* @param args
|
|
|
|
* @param args
|
|
|
|
* @param description
|
|
|
|
* @param description
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
exports.createGlobalCommand = function(command, call, args, description) {
|
|
|
|
exports.createGlobalCommand = function (command, call, args, description) {
|
|
|
|
globCommands[command] = {
|
|
|
|
globCommands[command] = {
|
|
|
|
'args': args || [],
|
|
|
|
'args': args || [],
|
|
|
|
'description': description,
|
|
|
|
'description': description,
|
|
|
@ -104,16 +104,16 @@ exports.createGlobalCommand = function(command, call, args, description) {
|
|
|
|
* @param msg
|
|
|
|
* @param msg
|
|
|
|
* @returns {boolean|*}
|
|
|
|
* @returns {boolean|*}
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
exports.parseMessage = function(msg) {
|
|
|
|
exports.parseMessage = function (msg) {
|
|
|
|
return parseGlobalCommand(msg);
|
|
|
|
return parseGlobalCommand(msg);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Initializes the module by creating a help command
|
|
|
|
* Initializes the module by creating a help command
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
exports.init = function(prefix) {
|
|
|
|
exports.init = function (prefix) {
|
|
|
|
logger.verbose("Created help command");
|
|
|
|
logger.verbose("Created help command");
|
|
|
|
this.createGlobalCommand((prefix+'help') || "~help", () => {
|
|
|
|
this.createGlobalCommand((prefix + 'help') || "~help", () => {
|
|
|
|
let helpstr = "```markdown\n";
|
|
|
|
let helpstr = "```markdown\n";
|
|
|
|
helpstr += "Commands\n---\n";
|
|
|
|
helpstr += "Commands\n---\n";
|
|
|
|
Object.entries(globCommands).forEach(([key, value]) => {
|
|
|
|
Object.entries(globCommands).forEach(([key, value]) => {
|
|
|
|