Dolly Parton's new book details the time she almost committed suicide

Dolly Parton is seen as a ray of sunshine, but she's also had her dark days.

In her new book, "Dolly on Dolly, Interviews and Encounters with Dolly Parton," the country legend opened up about the time she almost committed suicide. Her dog, a Boston terrier named Popeye, saved her from pulling the trigger.

Back in the 1980s, Parton was having a hard time in both her personal and profession life.

She received death threats after pulling out of a tour due to medical issues while also struggling to get over the nightmare of working with Burt Reynolds on the film, "The Best Little Whorehouse in Texas." Meanwhile, she was brokenhearted over an unnamed lover outside of her open, long marriage to Carl Dean. All the stress coming from different areas of her life caused her to gain 50 pounds from binge eating.

The whole ordeal nearly pushed Parton off the edge.

"I was sitting upstairs in my bedroom one afternoon when I noticed in the nightstand drawer my gun that I keep for burglars. I looked at it a long time ... Then, just as I picked it up, just to hold it and look at it for a moment, our little dog, Popeye, came running up the stairs," the singer confessed in an interview for her book.

She continued: "The tap-tap-tap of his paws jolted me back to reality and I suddenly froze. I put the gun down. Then I prayed. I kinda believe Popeye was a spiritual messenger from God."

It was then that Dolly realized how grief could really push you over the edge.

"I don't think I'd have done it, killed myself, but I can't say for sure. Now that I've gone through that terrible moment, I can certainly understand the possibilities even for someone solid like me if the pain gets bad enough," she revealed.

Dolly and Carl tied the knot in 1966, but are in an open relationship. However, Parton revealed an "affair of the heart" with one man -- who is rumored to be former band leader Gregg Perry -- "shattered" her.

The couple have no children of their own, but she is the godmother of former Disney channel star Miley Cyrus.

The Oscar, Tony and Emmy-nominated star also dropped other bombshells in the new book (which you can order on Amazon here), like intimate details of her sex life and the truth behind her appearance.

She has remained relatively out of the spotlight in recent years, but she made a comeback of sorts in 2016 with a tour in support of her new album "Pure & Simple." She also appeared at the 2017 SAG Awards to present longtime friend Lily Tomlin with the Life Achievement Award.