These are separate issues and should be consixered separately.
Go get professional medical help for the self harming. You realise it is not a good mental state, you would benefit for expert help.
As for your friendships/relationships, you need to decide what is most important to you. That said sexual attraction may not last but an established friendship will have already proved valuable. I'd suggest not muscling in on this guy whilst your friend still expresses interest/hope is the morally higher path. Willpower strengthens when exercised. You may consider that a benefit.