The Messenger of Allah ﷺ said, "Do not ask for a position of authority, for if you are given it without asking, you will be helped in carrying it out, but if you are given it because you asked, you will be left to handle it on your own. And if you swear an oath, then see that something else is better than it, do what is better and offer expiation for your oath."In another narration, "Then offer expiation for your oath and do what is better."
قال رسول الله ﷺ: لا تسأل الإمارة، فإنك إن أعطيتها من غير مسألة أعنت عليها، وإن أغطيتها عن مسألة وكلت إليها. وإذا حلفت على يمين، فرأيت غيرها خيرا منها، فأت الذي هو خير، وكفر عن يمينك وفي رواية: فكفر عن يمينك، وائت الذي هو خير
Bukhari narrated it in the Book of Expiations of Oaths (6722), and Muslim in the Book of Oaths and Vows (19:1652), both of them via Hasan, who said, Abdul-Rahman bin Samura narrated to us, and he related it. The wording given is Bukhari's, and the second version is Muslim's.Abu Dawud (3278) said after recording this hadith, "The hadiths of Abu Musa Ashari, Adi bin Hatim, and Abu Hurairah on this matter have been narrated from each of them, in some versions the breaking of the oath comes before the expiation, and in other versions the expiation comes before the breaking of the oath."