When Pinkie told the others about Rainbow's cookie prank on the whole town, they all decided to fight fire with fire by having the entire town prank her.
It was simple in concept, everypony would act like there was something in the cookies that made them into cookie craving zombies, they'd corner Rainbow in a confined space, and then they'd reveal themselves after scaring her silly, teaching her not to prank so much.
In hindsight, they probably should have known better than to overstimulate the adventurous and action-packed imagination of their pegasus daredevil.
An alternate ending to 28 Pranks Later.