{"size": 1987, "ext": "js", "max_stars_repo_path": "src/plugins/commands/help.js", "max_stars_repo_name": "Blazzike/Pandaaa-Cosbot", "max_stars_repo_stars_event_min_datetime": "2020-05-29T19:17:14.000Z", "max_stars_repo_stars_event_max_datetime": "2020-05-29T19:17:14.000Z", "max_issues_repo_path": "src/plugins/commands/help.js", "max_issues_repo_name": "Pandaaa2507/Pandaaa-Cosbot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/plugins/commands/help.js", "max_forks_repo_name": "Pandaaa2507/Pandaaa-Cosbot", "max_forks_repo_forks_event_min_datetime": "2020-05-29T19:09:52.000Z", "max_forks_repo_forks_event_max_datetime": "2020-06-26T17:38:50.000Z"}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": 5, "avg_line_length": 38.2115384615, "max_line_length": 324, "alphanum_fraction": 0.4720684449}
const PluginUtil = require('../../util/plugin');
const { RichEmbed } = require('discord.js');
const config = require('../../config');

const HelpCommand = {
    name: 'help',
    depends: ['Commands'],
    config: {
        themeColor: config.color
    },
    commands: {
        help: {
            aliases: ['commands'],
            description: 'This message.',
            category: 'Useful',
            exec(label, args, msg) {
                let categories = {};
                Object.values(PluginUtil.plugins).forEach((plugin) => {
                    if(!plugin.hasOwnProperty('commands')) {
                        return;
                    }

                    let commands = plugin.commands;
                    Object.keys(commands).forEach((label) => {
                        let cmd = commands[label];
                        if(cmd.hasOwnProperty('hidden') && cmd.hidden) {
                            return;
                        }

                        if(!categories.hasOwnProperty(cmd.category)) {
                            categories[cmd.category] = '';
                        }

                        categories[cmd.category] += `${PluginUtil.plugins.Commands.config.commandPrefix}${label}${cmd.hasOwnProperty('includeAliasesInHelp') && cmd.includeAliasesInHelp ? `, ${cmd.aliases.join(', ')}` : ''} ${cmd.hasOwnProperty('parameters') ? `*${cmd.parameters.join(' ')}* ` : ''}**${cmd.description}**\n`;
                    });
                });

                let response = '';
                Object.keys(categories).forEach((category) => {
                    response += `__**${category}**__\n${categories[category]}\n`;
                });

                msg.channel.send(new RichEmbed()
                .setTitle(config.name + ' Commands')
                .setColor(HelpCommand.config.themeColor)
                .setDescription(response.substr(0, response.length - 1)));
            }
        }
    }
};

module.exports = HelpCommand;