And that was how you learned about Queen Chrysalis's plot to attack Ponyville at sunrise. The fact that she is doing so while Twilight and friends are out of town is sheer coincidence, meaning that the responsibility of protecting the town falls to you. And you don't have much time to prepare. You needed a plan, and fast.