Allah says: He is the Knower of the Unseen, and He does not disclose His Unseen to anyone. other than to a Messenger whom He chooses (for the bestowal of any part of the knowledge of the Unseen), thereafter He appoints guards who go before him and behind him. 72: 26-27
Also: Tell them (O Muhammad): “I have no power to benefit or harm myself except as Allah may please. And had I knowledge of the Unseen, I should have amassed all kinds of good, and no evil would have ever touched me. I am merely a warner and the herald of glad tidings to those who have faith.” 7:188