Once I had a great anxiety and I said, "Oh, my Lord cure me and I swear to avoid some sins (because I thought that these sins are the source of my anxiety), if I do these sins You can punish me by a great anxiety". But after that, I was still anxious and I did them. I made Tawbah for breaking my oath and I give the Kaffarah. But I fear that Allah will punish me by this great anxiety. Will He do that? Did what I said have no value like a scholar of Madinah told me?
All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Sins have bad effects and result in awful consequences on their doer. Allah Says (what means): {And whatever strikes you of disaster - it is for what your hands have earned; but He pardons much.} [Quran 42:30]
Know that obedience is a fortress and everyone who gets into it is saved by Allah's Will. So, hasten to repent sincerely. Do not consider your falling in sin a second time a barrier between you and repentance. Indeed, it is only the disbelievers who despair from the Mercy of Allah. So, dear questioner, you should know that avoiding sins is initially an obligatory matter.
And when the person takes an oath to avoid them, this becomes greater and more emphatic and the sin becomes worse if committed after the oath. The expiation (Kaffaarah) you did was a right thing to do. Now, we advise you to befriend only righteous people as that will help you greatly to stay away from sins and occupy yourself in the obedience of your Lord.
Allah knows best.
You can search for fatwa through many choices