If someone doesn't get food or water and is deprived of sleep for a few days they will develop the symptoms of depression.
Humans need food, water, sleep, and social connections to thrive. When one of those is temporarily thwarted, mental and physical pain is a signal to take action. It's not always pleasant, but it will keep you alive and your genes in the game. This is unavoidable and often useful pain.
Recreational opiate use on the other hand is an extremely dangerous short circuit of the brains pleasure centers that very often results in physical dependance, legal problems, and death.
Part of maturing is understanding that you don't always have to mask pain and chase pleasure. It's ok and even healthy to feel like shit sometimes.