I think Discord betrayed was due to him questioning if the mane 6 was his real friends or not. He could have betrayed them anytime after they lost the elements of harmony and they couldn't have done anything to stop them. Instead it wasn't till Tirek told him his pony friends were just using him and if he team up with him then he would be Discord real friend that Discord betrayed them. And it clear Discord didn't really need Tirek at all.