Last active
January 29, 2018 00:55
-
-
Save eritbh/c1571903ce5d09659b2ed6f82cb3e62c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// replaces https://github.com/abalabahaha/eris/blob/master/lib/command/CommandClient.js#L78-L123 | |
this.registerCommand("help", (msg, args) => { | |
var result = ""; | |
if(args.length > 0) { | |
var cur = this.commands[this.commandAliases[args[0]] || args[0]]; | |
if(!cur) { | |
return "Command not found"; | |
} | |
var label = cur.label; | |
for(var i = 1; i < args.length; ++i) { | |
cur = cur.subcommands[cur.subcommandAliases[args[i]] || args[i]]; | |
if(!cur) { | |
return "Command not found"; | |
} | |
label += " " + cur.label; | |
} | |
result += `**${msg.prefix}${label}** ${cur.usage}\n${cur.fullDescription}`; | |
if(Object.keys(cur.aliases).length > 0) { | |
result += `\n\n**Aliases:** ${cur.aliases.join(", ")}`; | |
} | |
if(Object.keys(cur.subcommands).length > 0) { | |
result += "\n\n**Subcommands:**"; | |
for(var subLabel in cur.subcommands) { | |
if(cur.subcommands[subLabel].permissionCheck(msg)) { | |
result += `\n **${subLabel}** - ${cur.subcommands[subLabel].description}`; | |
} | |
} | |
} | |
} else { | |
result += `${this.commandOptions.name} - ${this.commandOptions.description}\n`; | |
if(this.commandOptions.owner) { | |
result += `by ${this.commandOptions.owner}\n`; | |
} | |
result += "\n"; | |
result += "**Commands:**\n"; | |
for(label in this.commands) { | |
if(this.commands[label] && this.commands[label].permissionCheck(msg) && !this.commands[label].hidden) { | |
result += ` **${msg.prefix}${label}** - ${this.commands[label].description}\n`; | |
} | |
} | |
result += `\nType ${msg.prefix}help <command> for more info on a command.`; | |
} | |
this.getDMChannel(msg.author.id).then(channel => { | |
channel.createMessage(result) | |
}) | |
}, { | |
description: "This help text", | |
fullDescription: "This command is used to view information of different bot commands, including this one." | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment