Pilots have to disclose all medical provider visits at each medical re-certification. Many mental health conditions are disqualifying; many commonly taken medications are, in practice, disqualifying either by the medication itself or the underlying condition. Even ones which will eventually allow the resumption of flight crew duties via a special issuance process will still put you out of work for some period of time while your regular medical certificate is revoked pending the review for special issuance.
The system overall discourages seeking help for certain conditions. Even seeking help for excessive snoring/sleep apnea could put your medical (and ability to work) at risk.