We have the Law of No Harm. The Prophet (s) said: لا ضرر ولا ضرار في الاسلام
“There is no harm and harming in Islam.”
Hence it’s prohibited to harm oneself and others. Doing so is a sin. If one causes harm and sincerely repents, Allah forgives. If one does not repent and gets away with it in this life, Allah will hold him accountable in the Hereafter.