It is narrated from Sayyiduna Anas (may Allah be pleased with him) that he said: "A Bedouin came to the door of the Messenger of Allah (peace and blessings be upon him) and put his eye to a crack in the door, and the Messenger of Allah (peace and blessings be upon him) caught sight of him. He took an arrow or a sharpened stick and aimed at the Bedouin's eye to put it out, and the Bedouin quickly drew back. At that, the Messenger of Allah (peace and blessings be upon him) said to him: 'Beware! Had you stayed where you were, I would certainly have put out your eye.'"
Imam Muslim (may Allah have mercy on him) narrated something with a similar meaning through the narration of Ubaydullah bin Abi Bakr (may Allah have mercy on him), which he reported from Sayyiduna Anas bin Malik (may Allah be pleased with him).
In this narration the saying of the Prophet (peace and blessings be upon him) is mentioned, whereas it is not present in that one (Muslim's narration); and Allah knows best.