Oh Chickpea, I'm so very sorry for what you are dealing with. What our adult children can put us through is so unfair.
If your daughter is still using drugs and drinking she, as you already know, is in no condition to care for her child. I will never understand the mindset of our adult kids who think they are better prepared to care for their children even though they cannot care for themselves.
I agree with the others that you need to consult a lawyer and file for custody.
As for your daughters threats of harming you or herself, I feel all threats should be taken seriously. If at all possible and she threatens you again, can you record her?
Also, if she threatens to harm herself, you can always call the police. They can pick her up and put her in a hospital for an evaluation. The reason I'm suggesting this is because if she is using this as a manipulation tactic you will send a clear message to her how you will respond.
Again, I'm just so very sorry for what you are going through.
Stay strong. This is one of those times you can draw on the strength of all of us here.