Holy shit, I’m sorry man. Take it from me, it’s easy to turn such a negative experience and just dive head first into more negative thoughts and behaviors, but these things can also work the opposite way - use the pain to improve yourself rather than as an excuse to sink deeper down.
It sounds to me like that’s exactly what you’re doing. You got this, man. Stay strong.