def run_command(self, nick, user_level, command, args=None, timestamp=None, threaded=True):
    "\n        Handles running of custom commands from chat\n\n        :param nick: The calling user\n        :param user_level: The calling user's level\n        :param command: The command triggered\n        :param args: The words on the line after the command\n        :param timestamp: The unixtime for when the event happened\n        :return: Any return value from the custom Lua command, to be sent\n                 back to the channel\n        :raise CommandPermissionError: If user lacks permissions for command\n        "
    if (not self._can_run_command(user_level, command)):
        raise CommandPermissionError(u'User does not have permission to run this command')
    if (args is None):
        args = []
    elif ('quoted' in self.commands[command]['flags']):
        if (self.commands[command]['flags']['quoted'] == 1):
            text = ' '.join(args)
            args = shlex.split(text)
    if (timestamp is None):
        timestamp = time.time()
    if self._is_under_cooldown(command, timestamp):
        raise CommandCooldownError()
    self._set_last_executed_time(command, timestamp)

    def run():
        code = self.call_template.format(func_name=command)
        lua_func = self.lua.eval(code)
        if ('want_user' in self.commands[command]['flags']):
            if (self.commands[command]['flags']['want_user'] == 1):
                args.insert(0, nick)
        return lua_func(*args)
    if threaded:
        lua_thread = Thread(target=run)
        lua_thread.daemon = True
        lua_thread.start()
    else:
        return run()
Handles running of custom commands from chat

:param nick: The calling user
:param user_level: The calling user's level
:param command: The command triggered
:param args: The words on the line after the command
:param timestamp: The unixtime for when the event happened
:return: Any return value from the custom Lua command, to be sent
         back to the channel
:raise CommandPermissionError: If user lacks permissions for command
def run_command(self, nick, user_level, command, args=None, timestamp=None, threaded=True):
    "\n        Handles running of custom commands from chat\n\n        :param nick: The calling user\n        :param user_level: The calling user's level\n        :param command: The command triggered\n        :param args: The words on the line after the command\n        :param timestamp: The unixtime for when the event happened\n        :return: Any return value from the custom Lua command, to be sent\n                 back to the channel\n        :raise CommandPermissionError: If user lacks permissions for command\n        "
    if (not self._can_run_command(user_level, command)):
        raise CommandPermissionError(u'User does not have permission to run this command')
    if (args is None):
        args = []
    elif ('quoted' in self.commands[command]['flags']):
        if (self.commands[command]['flags']['quoted'] == 1):
            text = ' '.join(args)
            args = shlex.split(text)
    if (timestamp is None):
        timestamp = time.time()
    if self._is_under_cooldown(command, timestamp):
        raise CommandCooldownError()
    self._set_last_executed_time(command, timestamp)

    def run():
        code = self.call_template.format(func_name=command)
        lua_func = self.lua.eval(code)
        if ('want_user' in self.commands[command]['flags']):
            if (self.commands[command]['flags']['want_user'] == 1):
                args.insert(0, nick)
        return lua_func(*args)
    if threaded:
        lua_thread = Thread(target=run)
        lua_thread.daemon = True
        lua_thread.start()
    else:
        return run()