Know that if you seek friendship look for three qualities in a person:
1- Intellect
The first is intellect. There is no benefit in friendship with a foolish person. An intelligent enemy is sometimes better than a foolish friend.
2- Good Character
The second is good character. Do not befriend someone who cannot restrain their anger, or control their desire; nor someone who is a liar or who is greedy for this world.
3- Righteousness
The third is righteousness. Do not befriend someone who persists in major wrongdoings. For witnessing such actions on a regular basis makes wrongdoing seem insignificant. These qualities rarely exist together. Keep interactions with your friends proportionate to the level of these qualities within them.
Three Types of Friendship
Know that friends are of three types:
1- Like Food
The first are like food, one cannot exist without them. They are for the sake of the hereafter; from them seek support in religious practices.
2- Like Medicine
The second are like medicine, one needs them from time to time. They are for the sake of this world; from them seek good character.
3- Like Disease
The third are like a disease, it is never needed but sometimes we are afflicted by it. These friends can only benefit you if you seek God’s help to perceive their flaws so you may better yourself.
Know that you are responsible for fulfilling certain duties in friendship such as defending them, assisting them financially, and forgiving their faults.
In short, you are to behave with your friend just as you would like them to behave with you.