If the way you speak to yourself is negatively or harsh, and that's the way your friend speaks to you, this could be a vicious cycle.
It is said that you teach others how to treat you by what you will put up with from them. You must first decide to treat yourself with respect by not speaking to yourself negatively or harshly, then you should tell your friend not to speak with you that way. If the friend persists in treating you with disrespect, you should distance yourself from him or her until they stop doing that. When the friend realizes you are not talking to them because you don't like the way they behave, the friend will either change his or her ways, or you may grow apart.
Teaching yourself to focus on being friends with people who are good to you is a great habit to develop.