main.js
function _registerCommands(basedir, globalObject) {
    var commandsDir = path.resolve(basedir, "commands");

    var files;
    try {
        files = Utils.getAllFilePathsUnderDirectory(commandsDir);
        LOG.info("Found the following potential command files: {}", files);
    }
    catch (e) {
        LOG.error("Unable to register commands from the base directory '{}'. Error: {}", commandsDir, e);
        return;
    }

    var commands = [];
    for (var i = 0; i < files.length; i++) {
        var filePath = files[i];
        if (filePath.lastIndexOf(".js") !== filePath.length - 3) {
            LOG.info("File {} doesn't appear to be a JS module. Ignoring.", filePath);
            continue;
        }

        var module = require(filePath);

        if (!module.triggers || !module.handler) {
            LOG.warn("Found a module at {} but it doesn't appear to be a command handler. Ignoring.", filePath);
            continue;
        }

        if (typeof module.init === "function") {
            module.init(globalObject);
        }

        commands.push(module);
        LOG.info("Registered command from file {}", filePath);
    }

    return commands;
}
function _registerCommands(basedir, globalObject) {
    var commandsDir = path.resolve(basedir, "commands");

    var files;
    try {
        files = Utils.getAllFilePathsUnderDirectory(commandsDir);
        LOG.info("Found the following potential command files: {}", files);
    }
    catch (e) {
        LOG.error("Unable to register commands from the base directory '{}'. Error: {}", commandsDir, e);
        return;
    }

    var commands = [];
    for (var i = 0; i < files.length; i++) {
        var filePath = files[i];
        if (filePath.lastIndexOf(".js") !== filePath.length - 3) {
            LOG.info("File {} doesn't appear to be a JS module. Ignoring.", filePath);
            continue;
        }

        var module = require(filePath);

        if (!module.triggers || !module.handler) {
            LOG.warn("Found a module at {} but it doesn't appear to be a command handler. Ignoring.", filePath);
            continue;
        }

        if (typeof module.init === "function") {
            module.init(globalObject);
        }

        commands.push(module);
        LOG.info("Registered command from file {}", filePath);
    }

    return commands;
}
function _registerCommands ( basedir , globalObject ) { var commandsDir = path . resolve ( basedir , "commands" ) ; var files ; try { files = Utils . getAllFilePathsUnderDirectory ( commandsDir ) ; LOG . info ( "Found the following potential command files: {}" , files ) ; } catch ( e ) { LOG . error ( "Unable to register commands from the base directory '{}'. Error: {}" , commandsDir , e ) ; return ; } var commands = [ ] ; for ( var i = 0 ; i < files . length ; i ++ ) { var filePath = files [ i ] ; if ( filePath . lastIndexOf ( ".js" ) !== filePath . length - 3 ) { LOG . info ( "File {} doesn't appear to be a JS module. Ignoring." , filePath ) ; continue ; } var module = require ( filePath ) ; if ( ! module . triggers || ! module . handler ) { LOG . warn ( "Found a module at {} but it doesn't appear to be a command handler. Ignoring." , filePath ) ; continue ; } if ( typeof module . init === "function" ) { module . init ( globalObject ) ; } commands . push ( module ) ; LOG . info ( "Registered command from file {}" , filePath ) ; } return commands ; }
Registers all of the eligible files from the commands
directory as commands with the bot.

@param {string} basedir - The base directory which holds the commands directory
@param {object} bot - An instance of DubBotBase.Bot
Registers all of the eligible files from the commands directory as commands with the bot .