           controller.battle.playerNames[1],
           currentTime - controller.battle.createdAt
         ] for controller in server.getOngoingBattles())
-      callback(battleMetadata)
+      callback?(battleMetadata)
 
     spark.on 'findBattle', (format, team, altName=null) ->
       # Note: If altName == null, then isAltOwnedBy will return true

      attributes['contents'] = JSON.stringify(team.pokemon)
      new database.Team(attributes)
        .save().then (team) ->
          callback(team.id)

    spark.on 'requestTeams', ->
      q = new database.Teams()

        return

      battle.makeSwitch(user.name, toSlot, fromSlot, forTurn)
      callback?()

    spark.on 'sendCancelAction', (battleId, forTurn) ->
      battle = server.findBattle(battleId)
