Generally speaking, for me the motivation to pursue pleasure is "positive" whereas the motivation to remove pain is "negative". Focusing on the positive leads to a far more pleasant life and greater agency than focusing on the negative, and I find that over time that which I focus on tends to gain even more of my focus. The example of "don't think about an elephant" is pertinent, as this makes you think about an elephant.
If we start with the uncomfortable feelings of mental pain and then ask how to remove them, then we might arrive at a list of possible ways to remove the pain...one option of which is to seek the pleasure of friendship.
Once we have determined that this is the best option to remove the pain of loneliness, then we must switch to a "pleasure optimising" goal...which would answer the question: "How can I best find the pleasure of friends?"
This seeking of pleasure will then lead to more and better options for ending the mental pain of loneliness.
This quote is a good illustration of how the process works: it's important to be aware of our pain so that we can address it. Both pleasure and pain are guides. This works for loneliness, stress, sickness, hunger, overeating, overstimulation, anger, sleepiness &c. I've been faced at times (as I imagine many of us have) with lengthy periods of overwhelming stress, chronic illness and the like. Trying to remove the pain always causes me to focus even more on the pain, whereas acknowledging the pain and pursuing pleasure has led me to much better outcomes. Often it might be just taking "baby steps" of agency, little nibbles of pleasure leading toward a larger meal.
As I age it becomes evident that the pains in life will increase. Bodily aches and pains, losing friends and family, loved ones suffering, changes in the world.... With this in mind it's interesting to ponder that some studies have documented people's happiness increasing as they age. For me, the more that I live through, the more understanding I have that pursuing pleasure and being grateful for this random existence is really the only way to live.
The short answer: No, the motivation to pursue pleasure is not the same as the motivation to remove pain.