I'm unsure what you think you did to deserve to hurt yourself, but I am promising you, you do not deserve to hurt yourself. You do not deserve pain, you do not deserve to hurt yourself, you do not deserve any of it. Nobody deserves to be in pain no matter what has happened, what they did, or who they are.
I recommend trying different things to distract yourself from feeling this way: read a book, play a game, play with a fidget toy (fidget spinner, slime, etc.), color in a coloring book, anything to distract yourself. It is MOST important that you remind yourself: no matter what you've done, who you are, and how you feel; YOU DO NOT DESERVE TO HURT YOURSELF.
If these feelings continue or have been going on for a while, please reach out to a trusted adult. Reach out to an adult who can get you the help that you need emotionally and mentally. I know it can be an intimidating thing to reach out for help, but you will feel so much better after you reach out for help. Talk to your parents, guardians, a school counselor, a teacher, whoever you are most comfortable reaching out to.
I am sending you so many positive vibes and well wishes.