Al-Bukhaari (6502) narrated that Abu Hurayrah (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Allah says: ‘Whoever takes a close friend of Mine as an enemy, I declare war on him. My slave does not draw closer to Me by anything more beloved to Me than that which I have made obligatory upon him, and My slave continues to draw closer to Me by doing naafil (supererogatory) deeds until I love him, and if I love him I will be his hearing with which he hears, his vision with which he sees, his hand with which he strikes and his foot with which he walks. If he were to ask of Me, I would surely give to him; if he were to seek refuge with Me, I would surely grant him refuge. I do not hesitate about anything that I want to do as I hesitate to take the soul of a believer, for he hates death and I hate to hurt him.”
This hadith clearly and concisely highlights the way to become a close friend of Allah, may He be exalted, for the one who wants to be one of His close friends. All the believer has to do is reflect deeply upon this hadith and understand it properly, then follow that by acting upon what it says.
Explaining the content of this hadith, al-Haafiz Ibn Rajab (may Allah have mercy on him) said elsewhere in his book Jaami‘ al-‘Uloom wa’l-Hikam: His close friends who are near to Him may be divided into two categories, the first of which is those who draw near to Him by doing that which is enjoined, which includes doing obligatory duties and avoiding things which are prohibited, because all of that comes under the heading of what Allah has enjoined upon His slaves. The second category is those who draw nearer to Him, after doing obligatory duties, by doing naafil (supererogatory) deeds.
May Allah help us and you to do that which He loves and is pleased with.