As I can see error message is telling you -
unexpected end-of-input, expecting }
ItemHandlers::UseOnPokemon.add(:RARECANDY,proc { |item,pkmn,scene|
levelCap=15
levelCap=25 if $game_switches[4] #1 badge
levelCap=35 if $game_switches[6] #2 badge
levelCap=40 if $Trainer.numbadges>=2 #3 badge...