I got out of my suicidal state through finding Christ, which I know a lot of people don’t believe in, so my first suggestion would to put your faith in Jesus.
Other ways that can help deal with feeling lonely that I’ve found is :
Having a journal)
Writing in a journal allows you to write about any problems you have like you were talking to someone, but you don’t have to hold back any details or feelings because you’re worried about being judged or miss understood, and I mean it when I say that’s a good thing to be able to not hold back.
Therapy)
I didn’t have therapy for long, maybe 2-3 months and I can’t even remember if I mentioned my difficulties with girls. But I do know that even that little amount of time helped me when it came to my mental health, having someone be able to listen to your problems is important, and not just someone on discord like me, a real person dedicated to wanting to help you. Having that real life connection is important. And can help lighten that overbearing feeling of being alone.