The Messenger of Allah ﷺ said, "O Allah, I am only a human being, so any Muslim man whom I have insulted, cursed, or flogged, make it for him a means of purification and mercy."
قال رسول الله ﷺ: اللهم إنما أنا بشر، فأيما رجل من المسلمين سببته، أو لعنته أو جلدته فاجعلها له زكاة ورحمة.
Muslim narrated it in the Book of Righteousness and Maintaining Ties (2601) from Muhammad bin Abdullah bin Numayr, who said, my father narrated to us, Amash narrated to us, from Abu Salih, from Abu Hurairah, and he mentioned it.Bukhari (6361) and Muslim both narrated it from the hadith of Ibn Wahb, who said, Yunus informed me, from Ibn Shihab, who said, Saeed bin Musayab informed me, from Abu Hurairah, that he heard the Prophet ﷺ say, "O Allah, whichever believer I have cursed, make that a means of bringing him closer to You on the Day of Resurrection."