<commit_before>/*
response.reply("", response.embedFactory.createInformativeEmbed("Module Manager", message.member).setDescription("```---AVAILABLE MODULES---\nco.dynastic.steamboat\nco.dynastic.melania```"))
*/
const Command = require("../../Util/Command");
const Moderation = require("../../Util/Moderation");
const GuildConfig = require("../../Model/guild");

module.exports = new Command("modules", "A module manager", null, [],
    (client, message, response, args) => {
        var operations = {
            list: function(config) {
                var modules = Array.from(message.client.modulesManager.modules.keys());
                var content = '```--- AVAILABLE MODULES ---';
                
                modules.forEach(identifier => content += `\n${identifier}  ${config.disabledModules ? config.disabledModules.includes(identifier) ? "(DISABLED)" : "(ENABLED)" : "(ENABLED)"}`);
                content += '\n--- AVAILABLE MODULES ---```';
                return response.reply("", response.embedFactory.createInformativeEmbed("Available Modules").setDescription(content));
            }, toggle: function(config) {
                var identifier = args[1].toLowerCase();
                var modules = Array.from(message.client.modulesManager.modules.keys());
                if(!modules.includes(identifier)) return response.reply("", response.embedFactory.createErrorEmbed("Invalid Module").setDescription(`\`${identifier}\` is not a valid module.\nRun \`.modules list\` for a list of valid modules.`));
                var enabling = config.disabledModules ? config.disabledModules.includes(identifier) : false;
                if (enabling) {
                    config.disabledModules.splice(config.disabledModules.indexOf(identifier), 1);
                    config.save();
                    message.guild.manager.properties = config;
                } else {
                    config.disabledModules.push(identifier);
                    config.save();
                    message.guild.manager.properties = config;
                }
                return response.reply("", response.embedFactory.createSuccessEmbed().setDescription(`Successfully ${enabling ? "enabled" : "disabled"} ${identifier}`));
            }
        }
        
        GuildConfig.findOne({snowflake: message.guild.id}, (err, doc) => {
            if (err || !doc) return response.reply("", respnose.embedFactory.createErrorEmbed().setDescription(`An unknown error occured while validating your request:\n\`\`\`${err}\`\`\``));
            if (doc.delegate != message.author.id && !message.client.config.admins.includes(message.member.id)) return response.reply("", response.embedFactory.createBadPermsEmbed());
            if (!operations[args[0]]) {
                var content = '```--- Unknown command, here is a list of commands. ---';
                Object.keys(operations).forEach(command => content += `\n.modules ${command}`);
                content += "```";
                return response.reply("", response.embedFactory.createInformativeEmbed("Module Help").setDescription(content));
            }
            return operations[args[0]](doc);
        })

    }
);<commit_msg>Made output prettier<commit_after>/*
response.reply("", response.embedFactory.createInformativeEmbed("Module Manager", message.member).setDescription("```---AVAILABLE MODULES---\nco.dynastic.steamboat\nco.dynastic.melania```"))
*/
const Command = require("../../Util/Command");
const Moderation = require("../../Util/Moderation");
const GuildConfig = require("../../Model/guild");

module.exports = new Command("modules", "A module manager", null, [],
    (client, message, response, args) => {
        var operations = {
            list: function(config) {
                var modules = Array.from(message.client.modulesManager.modules.keys());
                var content = '';
                modules.forEach(identifier => content += `\n\`${identifier}  ${config.disabledModules ? config.disabledModules.includes(identifier) ? "(Disabled)" : "(Enabled)" : "(Enabled)"}\``);
                return response.reply("", response.embedFactory.createInformativeEmbed("Available Modules").setDescription(content));
            }, toggle: function(config) {
                var identifier = args[1].toLowerCase();
                var modules = Array.from(message.client.modulesManager.modules.keys());
                if(!modules.includes(identifier)) return response.reply("", response.embedFactory.createErrorEmbed("Invalid Module").setDescription(`\`${identifier}\` is not a valid module.\nRun \`.modules list\` for a list of valid modules.`));
                var enabling = config.disabledModules ? config.disabledModules.includes(identifier) : false;
                if (enabling) {
                    config.disabledModules.splice(config.disabledModules.indexOf(identifier), 1);
                    config.save();
                    message.guild.manager.properties = config;
                } else {
                    config.disabledModules.push(identifier);
                    config.save();
                    message.guild.manager.properties = config;
                }
                return response.reply("", response.embedFactory.createSuccessEmbed().setDescription(`Successfully ${enabling ? "enabled" : "disabled"} ${identifier}`));
            }
        }
        
        GuildConfig.findOne({snowflake: message.guild.id}, (err, doc) => {
            if (err || !doc) return response.reply("", respnose.embedFactory.createErrorEmbed().setDescription(`An unknown error occured while validating your request:\n\`\`\`${err}\`\`\``));
            if (doc.delegate != message.author.id && !message.client.config.admins.includes(message.member.id)) return response.reply("", response.embedFactory.createBadPermsEmbed());
            if (!operations[args[0]]) {
                var content = '';
                Object.keys(operations).forEach(command => content += `\n\`.modules ${command}\``);
                return response.reply("", response.embedFactory.createInformativeEmbed("ModuleManager Commands").setDescription(content));
            }
            return operations[args[0]](doc);
        })

    }
);
{'fraction_non_alphanumeric': 0.1559839357429719, 'fraction_numerical': 0.001285140562248996, 'mean_word_length': 2.576105686387134, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1347030', 'n_tokens_mistral': 1598, 'n_tokens_neox': 1546, 'n_words': 287}