<commit_before>const fs = require("fs-extra-promise");
const path = require("path");
const commands = path.resolve(`${__dirname.replace(/\/\w+$/, ``)}/Commands/`);

class CommandsManager {
    constructor(client, disabledCommands) {
        this.client = client;

        this.groups = {};
        this.data = new Map();

        this.disabledCommands = disabledCommands || [];

        this.loadAll();
    }

    load(name, groupName, path) {
        if(this.disabledCommands.includes(name)) return;
        var command = require(path);
        if (this.data.has(command.command)) {
            delete require.cache[require.resolve(path)];
        }
        this.data.set(command.command, command);
        if(!this.groups[groupName]) {
            this.groups[groupName] = [];
        }
        this.groups[groupName].push(command.command);
    }

    loadAll() {
        var loadCount = 0;
        var client = this.client;
        fs.walk(commands).on("data", item => {
            var file = path.parse(item.path);
            if (!file.ext || file.ext !== ".js") return;
            var dirPath = path.dirname(item.path);
            var groupName = dirPath == commands ? "Other" : path.basename(dirPath);
            this.load(file.name, groupName, `${file.dir}${path.sep}${file.base}`);

            loadCount += 1;
        }).on('end', function() {
          client.log(`Loaded ${loadCount} command${loadCount == 1 ? "" : "s"}!`);
        });
        return this;
    }

    reload(input) {
        return new Promise((resolve, reject) => {
            if (!this.data.has(input)) return reject("Invalid Command");
            var command = this.data.get(input);
            this.load(input, command.path);
        });
    }

    get(text) {
        text = text.toLowerCase();

        return new Promise((resolve, reject) => {
            if (this.data.has(text)) return resolve(this.data.get(text));
            this.data.forEach(c => {
                if (c.aliases && c.aliases.includes(text)) return resolve(c);
            });
            return resolve();
        });
    }
}

module.exports = CommandsManager;<commit_msg>LoadCount is broken because of anonymous dynamic command managers<commit_after>const fs = require("fs-extra-promise");
const path = require("path");
const commands = path.resolve(`${__dirname.replace(/\/\w+$/, ``)}/Commands/`);

class CommandsManager {
    constructor(client, disabledCommands) {
        this.client = client;

        this.groups = {};
        this.data = new Map();

        this.disabledCommands = disabledCommands || [];

        this.loadAll();
    }

    load(name, groupName, path) {
        if(this.disabledCommands.includes(name)) return;
        var command = require(path);
        if (this.data.has(command.command)) {
            delete require.cache[require.resolve(path)];
        }
        this.data.set(command.command, command);
        if(!this.groups[groupName]) {
            this.groups[groupName] = [];
        }
        this.groups[groupName].push(command.command);
    }

    loadAll() {
        var client = this.client;
        fs.walk(commands).on("data", item => {
            var file = path.parse(item.path);
            if (!file.ext || file.ext !== ".js") return;
            var dirPath = path.dirname(item.path);
            var groupName = dirPath == commands ? "Other" : path.basename(dirPath);
            this.load(file.name, groupName, `${file.dir}${path.sep}${file.base}`);
        })
        return this;
    }

    reload(input) {
        return new Promise((resolve, reject) => {
            if (!this.data.has(input)) return reject("Invalid Command");
            var command = this.data.get(input);
            this.load(input, command.path);
        });
    }

    get(text) {
        text = text.toLowerCase();

        return new Promise((resolve, reject) => {
            if (this.data.has(text)) return resolve(this.data.get(text));
            this.data.forEach(c => {
                if (c.aliases && c.aliases.includes(text)) return resolve(c);
            });
            return resolve();
        });
    }
}

module.exports = CommandsManager;
{'fraction_non_alphanumeric': 0.15916205152901516, 'fraction_numerical': 0.0007223693715386468, 'mean_word_length': 2.120961682945154, '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': '5366021', 'n_tokens_mistral': 1198, 'n_tokens_neox': 1189, 'n_words': 227}