 
     robot.respond /ttv search (.+)/i, (msg) ->
         query = msg.match[1]
-        twitch_request msg, "/search/streams", { q: query, limit: maxResults }, (object) ->
+        twitchRequest msg, "/search/streams", { q: query, limit: maxResults }, (object) ->
             if object._total is 0
                 msg.reply "No live streams were found using search query: \"#{query}\". Try a different query or try again later."
                 return

        createURL = (game) ->
            "http://www.twitch.tv/directory/game/#{encodeURIComponent(game)}"

        twitch_request msg, "/games/top", limit: maxResults, (object) ->
            for gameObj, i in object.top
                msg.send "#{i + 1}. #{gameObj.game.name} | Viewers: #{gameObj.viewers} | Channels: #{gameObj.channels} | #{createURL(gameObj.game.name)}"

twitch_request = (msg, api, params = {}, handler) ->
    msg.http("https://api.twitch.tv/kraken#{api}")
        .query(params)
        .get() (err, res, body) ->

        return

    robot.respond /ttv featured/i, (msg) ->
        twitchRequest msg, '/streams/featured', limit: maxResults, (object) ->
            for feature in object.featured
                channel = feature.stream.channel
                msg.send "#{feature.stream.game}: #{channel.display_name} (#{channel.status}) - #{channel.url} [Viewers: #{feature.stream.viewers}]"

    robot.respond /ttv game (.+)/i, (msg) ->
        category = msg.match[1]
        twitchRequest msg, '/streams', { game: category, limit: maxResults }, (object) ->
            if object._total is 0
                msg.reply "No live streams were found in \"#{category}\". Try a different category or try again later."
                return
