He reminded David that God was in control and that David could trust God. A real friend always takes us closer to God and God's truths. You hear things like people wanting to go to hell because their friends will all be there. What kind of friend would lead someone to hell. People who lead others to sin are not friends they are simply looking for someone to accompany them on their way to destruction.
Misery loves company.
A real friend will warn and do all they can to stop their friend from destroying themselves. That is not the real question. It is always up to us to reach out and make friends. You cannot have a friend without willing to be a friend. Be a friend to someone who needs a friend and you will find a friend.