Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:16:126

And if you punish ˹an enemy, O believers˺, punish with an equivalent of that with which you were harmed. But if you are patient - it is better for those who are patient.  

After Hamza ˹b. ‘Abd al-Muttalib˺ had been killed and mutilated, and the Prophet (s) had seen him and said, ‘Verily I will mutilate 70 of them for you’, the following was revealed: And if you retaliate, retaliate with the like of what you have been made to suffer; and yet if you endure patiently, ˹refraining˺ from revenge, verily that, namely, ˹that˺ enduring, is better for the patient. Thus the Prophet (s) refrained ˹from taking revenge˺ and made atonement for his oath, as reported by al-Bazzār.
القرآن:١٦:١٢٦

وَإِنْ عَاقَبْتُمْ فَعَاقِبُوا بِمِثْلِ مَا عُوقِبْتُمْ بِهِ ۖ وَلَئِنْ صَبَرْتُمْ لَهُوَ خَيْرٌ لِلصَّابِرِينَ  

{وإن عاقبتم فعاقبوا بمثل ما عوقبتم به ولئن صبرتم} عن الانتقام {لهو} أي الصبر {خير للصابرين} فكف ﷺ وكفَّر عن يمينه رواه البزار.