Last active
January 29, 2018 01:00
-
-
Save eritbh/eaa665fb5e8aaeef85fa3584664317f7 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
bot.registerCommand("help", (msg, args) => { | |
var result = ""; | |
if(args.length > 0) { | |
var cur = bot.commands[bot.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 += `${bot.commandOptions.name} - ${bot.commandOptions.description}\n`; | |
if(bot.commandOptions.owner) { | |
result += `by ${bot.commandOptions.owner}\n`; | |
} | |
result += "\n"; | |
result += "**Commands:**\n"; | |
for(label in bot.commands) { | |
if(bot.commands[label] && bot.commands[label].permissionCheck(msg) && !bot.commands[label].hidden) { | |
result += ` **${msg.prefix}${label}** - ${bot.commands[label].description}\n`; | |
} | |
} | |
result += `\nType ${msg.prefix}help <command> for more info on a command.`; | |
} | |
bot.getDMChannel(msg.author.id).then(channel => { | |
channel.createMessage(result) | |
}) | |
}, { | |
description: "bot help text", | |
fullDescription: "bot command is used to view information of different bot commands, including bot one." | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment