TW/self-harm

I've been feeling extremely lonely lately and my boyfriend, one of my only friends at the moment, has been becoming more and more close with a group of people that I don't really respect. He went to a party with them while I was home and I got jealous and lonely. I wound up self harming for the first time in years. I mostly did it because I felt overwhelmed by my emotions so that part was authentic but I was also mad at him for leaving me alone to be with those people and I wanted him back home. I called him and told him what I had done and he rushed back to take care of me. I got what I wanted but I just felt like absolute shit. I had read about people who did this kind of thing and was always disgusted by their behavior but that night I was just like them. And now that I've opened the door in afraid that I'll keep doing things like that for attention.  I never want to be manipulative like that or in any other way again. Has anyone else struggled with manipulative impulses? How do you work through it?