main.js
function _createCommandHandler(commands) {
    return function(chatEvent, globalObject) {

        if (!chatEvent.command) {
            return;
        }

        var commandName = chatEvent.command;

        if (!globalObject.config.DubBotBase.areCommandsCaseSensitive) {
            commandName = commandName.toLowerCase();
        }

        for (var i = 0; i < commands.length; i++) {
            var command = commands[i];

            if (command.triggers.indexOf(commandName) >= 0) {
                if (command.minimumRole && chatEvent.userRole.level < command.minimumRole.level) {
                    // user doesn't have sufficient permissions; notify the command module if possible
                    if (command.insufficientPermissionsHandler) {
                        command.insufficientPermissionsHandler.call(command.context, chatEvent, globalObject);
                    }

                    continue;
                }

                command.handler.call(command.context, chatEvent, globalObject);
            }
        }
    };
}
function _createCommandHandler(commands) {
    return function(chatEvent, globalObject) {

        if (!chatEvent.command) {
            return;
        }

        var commandName = chatEvent.command;

        if (!globalObject.config.DubBotBase.areCommandsCaseSensitive) {
            commandName = commandName.toLowerCase();
        }

        for (var i = 0; i < commands.length; i++) {
            var command = commands[i];

            if (command.triggers.indexOf(commandName) >= 0) {
                if (command.minimumRole && chatEvent.userRole.level < command.minimumRole.level) {
                    // user doesn't have sufficient permissions; notify the command module if possible
                    if (command.insufficientPermissionsHandler) {
                        command.insufficientPermissionsHandler.call(command.context, chatEvent, globalObject);
                    }

                    continue;
                }

                command.handler.call(command.context, chatEvent, globalObject);
            }
        }
    };
}
function _createCommandHandler ( commands ) { return function ( chatEvent , globalObject ) { if ( ! chatEvent . command ) { return ; } var commandName = chatEvent . command ; if ( ! globalObject . config . DubBotBase . areCommandsCaseSensitive ) { commandName = commandName . toLowerCase ( ) ; } for ( var i = 0 ; i < commands . length ; i ++ ) { var command = commands [ i ] ; if ( command . triggers . indexOf ( commandName ) >= 0 ) { if ( command . minimumRole && chatEvent . userRole . level < command . minimumRole . level ) { // user doesn't have sufficient permissions; notify the command module if possible if ( command . insufficientPermissionsHandler ) { command . insufficientPermissionsHandler . call ( command . context , chatEvent , globalObject ) ; } continue ; } command . handler . call ( command . context , chatEvent , globalObject ) ; } } } ; }
Creates a handler for the CHAT_COMMAND event which will distribute
chat commands to the appropriate registered handlers.

@param {array} commands - All of the registered command handlers
@returns {function} An event handler
Creates a handler for the CHAT_COMMAND event which will distribute chat commands to the appropriate registered handlers .