I had many of these attacks years ago & found diet helped considerably.
After I was scanned & discovered to have 6 small gallstones, I treated myself for about 9 years using diet. When I would have bad pain, I used to drink a hot lemon drink (50% pure freshly squeezed lemon juice & 50% boiling water - no sugar or any other sweetener). It worked well. I also used to massage the gallbladder reflexology point under my foot with the point of my finger. This also worked well for easing pain. Apart from checking the position on a reflexology chart, you can tell you've got exactly the right reflexology point because pressing the correct spot under your the arch of your foot means you feel a faint sensation under your ribcage where your gallbladder & pain is.
After 9 years, the stones grew to the point where I couldn't eat or drink & the pain was excruciating and I had to have my gallbladder removed. My gallbladder was about to burst & I could have died if this happened. I still have the 13 marble sized gallstones to this day.
Usually, it's the gallstones that are the size of sand grains that give the most pain as they can move around & block a duct causing obstruction to the flow of bile (& pain). Many people have gallstones & don't realise they have them as they don't cause symptoms.
Despite different diets & lifestyles, our whole family has/had gallstones, so there must have been a genetic predisposition to them.
If you suspect you have gallstones, you really should go to a doctor who can order a scan & diagnose you acurately. And of course, there are other reasons for pain in this area hence the need for an accurate diagnosis before treating yourself. I certainly didn't treat myself until I had been scanned & diagnosed.
I urge you to go to a doctor if you suspect gallstones are causing your pain.