I think this is how it goes: Muchos dusttale routes have been played. Then, the human did pacifist. sans was aware of the dusttale routes though. so then, he kill everyone. sans asks you why you made him kill everyone. then the battle starts.
Credit to lolelujah, and wherever else it's required.