You can get out of it.
Small steps is what worked for me. Just one win every day, or a working piece of code, or an admin task I'd been putting off before. It rebuilds your confidence that you can achieve things, and each little thing lifts your mood.
Also, the obvious things baked into our culture work. Being outdoors, especially in the sunshine, added to a healthy amount of exercise every day, even just a walk, helped me significantly. A healthier diet and taking supplements especialy B group vitamins had a big effect for me.
Also I cut out weed and smoking. For me, it sapped my motivation not just when I was high, but for days afterwards.
Good luck friend!