I don’t think that the Bible directly addresses such mental illnesses such as bipolar. It does speak to how to build a strong mind. Note these two studies on building a mature mind:
and in more depth:
Here is a solid resource on good books that pertain to mental illnesses:
It is possible that mental illness could result from unconfessed sin but not necessary so. There have been many great Christian leaders who suffered from depression among other mental issues and God has used them in a mighty way. Biblical characters such as David were depressed: “Why are you cast down oh my soul?” If a person has examined and confessed their known sin, they need to move on and not drag out the skeletons in the closet (Php 3:13, 14). Harking back to our guilt and not accepting God’s grace is a problem of lack of trust in God’s promises. It is important to claim the promise with gratitude and move on. It can be dangerous to constantly drag the skeletons out of the closet to reinforce our guilt. Guilt is a way we punish ourselves if used incorrectly (rather than accepting Christ’s suffering for our sin), especially subjective guilt as over against objective guilt. Subjective guilt can be very destructive; this kind of guilt punishes self often unconsciously. Objective guilt acknowledges the sin and accepts Christ’s payment for it and does not look back. The issue in 1 John 1:9 is that not only does God forgive us the sin we confess but the sin we forgot. We need to accept by faith both kinds of forgiveness.
It may simply be that a person has a chemical problem issue such as lack of serotonin and not a sin issue at all. See this article:
There is a real problem with people who claim that depression is sin or that a person cannot be truly saved if they have mental problems. They have a defective view of the Bible.