             incidents: foundIncidents.map (incident) ->
               {
                 'id':     incident.id,
-                'status': status
+                'status': updatedStatus
               }
           }
+
           pagerDutyPut msg, "/incidents", data , (json) ->
-            if json.incidents
+            if json?.incidents
               buffer = "Incident"
               buffer += "s" if json.incidents.length > 1
               buffer += " "
-              buffer += (incident.incident_number for incident in incidents).join(", ")
-              buffer += " #{incident.status}"
+              buffer += (incident.incident_number for incident in json.incidents).join(", ")
+              buffer += " #{updatedStatus}"
               msg.reply buffer
             else
               msg.reply "Problem updating incidents #{incidentNumbers.join(',')}"


    "#{inc.incident_number}: #{inc.created_on} #{summary} #{assigned_to}\n"

  updateIncidents = (msg, incidentNumbers, status) ->
    withPagerDutyUsers msg, (users) ->
      requesterId = pagerDutyUserId(msg, users)
      return unless requesterId

      pagerDutyIncidents msg, "triggered,acknowledged", (incidents) ->
        foundIncidents = []
        for incident in incidents
          if incidentNumbers.indexOf("#{incident.incident_number}")
            foundIncidents.push(incident)

        if foundIncidents.length == 0
          msg.reply "Couldn't find incident #{incident_number}"
        else
          # loljson
          data = {

  robot.respond /who('s|s| is)? (on call|oncall)/i, (msg) ->
    withCurrentOncall msg, (username) ->
      msg.reply "#{username} is on call"

  parseIncidentNumbers = (match) ->
    match.split(/[ ,]+/).map (incidentNumber) ->
      parseInt(incidentNumber)

  missingEnvironmentForApi = (msg) ->
    missingAnything = false
