I came to the Prophet ﷺ and said to him, "I pledge allegiance to you to listen and obey in what I like and in what I dislike."The Prophet ﷺ said, "Are you able to do that, Jareer? Can you bear that? Say, 'in what I am able to do.'"So he took my pledge of allegiance, including sincere counsel to every Muslim.
أخبرني محمد بن قدامة عن جرير عن مغيرة عن أبي وائل والشعبي قالا
أتيت النبي ﷺ فقلت له أبايعك على السمع والطاعة فيما أحببت وفيما كرهت قال النبي ﷺ أو تستطيع ذلك يا جرير أو تطيق ذلك قال قل فيما استطعت فبايعني والنصح لكل مسلم
Bukhari reported it in "The Book of Judgments", chapter "How the Imam Takes the Pledge from People," hadith 7204, and Muslim in "The Book of Faith", chapter clarifying that religion is sincere advice, hadith 99/56, from the hadith of Shaybi, through him. It is also in Kubra, hadith 7797. Jareer is Ibn Abdullah Bajali.