I think its important to know too that when it comes to mental health its such a personal experience therefore one solution that works for someone does not work another person. Ive struggled with my mental health a lot over the years, and as a result have turned to drugs which made things ultimately worse. I tried therapy and medication but neither worked. I thought I was doomed. I thought about taking my own life, I even planned it.
Looking back now it seems quite crazy where I was to where I am now. Two years of absolute hell, now I am the best I have ever been. I started going to the gym which I enjoyed, it was a hobby to keep me busy and entertained. I also started setting myself small achievable goals, like cook dinner for my family, go to the shop, code X today, learn X today, learn how to do this exercise today, up the weights today. I also spoke to my family and friends, about my worries and how I felt. Then gradually it started getting better. It wasn't instant, but it wasn't slow either. That is my story, and how I got out of the pit I was in. Your story will be different, but I can promise you there is always a solution. Just don't give up, keep trying to find it, keep trying new things and stay strong.