Agree with the others, active UC inflammation can cause pain when pooping, and spasms can cause pain. Your doctor can determine which it is.
Antispasmatics are common with IBS but we can have those pains too. Spasms aren't only when pooping, and can happen anytime during the day.
/www.verywell.com/antispasmodics-for-ibs-1945153