The 3 C's of CBT
The following exercise is a great way to practice identifying and changing your negative thought patterns, thus making it easier to manage your pain. It may be difficult in the beginning, but the more you practice, the easier it gets - so don't give up!
The exercise has 3 steps: catch, check, and change.

Step 1 - Catch
Identify a negative thought. This is not always easy because sometimes, the first thing we notice is a feeling like sadness or hoplessness. If this is the case, try to identify what has caused that emotion, for example the thought "I can't do anything because of the pain."
Step 2 - Check
Reflect on how accurate and useful that thought is. In the example above, it's not really accurate. Sure, there are certain things you can't do because of the pain, but there are also many things you can do. If it helps, write down everything you can think of that proves that your thought isn't accurate - in this case, a list of things you can do despite your pain.
After that, think about how useful your thought is. Does it help you in any way? No, it only makes you feel worse. It leads to feelings of sadness, worthlessness and hopelessness, which only increases the pain. It also leads to negative behaviors (like staying in bed in day and isolating yourself) which increase the pain and decrease your quality of life.
Step 3 - Change
Now that you've identified your negative thought and realized why it isn't accurate or helpful, the next step is to change it. This can be very difficult, even more so if you are depressed. Remember you will get better the more you practice. If it's too hard, ask a friend for help.
How can you change the thought "I can't do anything because of the pain?" Well, you already figured out that it isn't accurate and that there are a lot of things you can do despite your pain. So, a more accurate and helpful thought might be "Even though I have severe pain, there are still a lot of things I can do. I won't let the pain define who I am or make me feel bad about myself. I'm a strong person who does a lot of things even though I'm in pain, and I'm proud of myself for always doing my best."