In my experience, it's difficult to avoid leakage in a deep r.e.m. sleep b/c every muscle in your body is completely relaxed, including sphincter. The better you can sleep a little hungry; the better of you'll be. Make your last meal before sleep time your lightest and listen to your body. When you learn what foods/ drinks affect you in a way that produces more or less output you'll know what to consume before sleep. When your awake, the tightness of your sphincter will control leakage unless as mentioned you have pouch or cuffitis. I had pouchitis often and a combo of cipro/flagyll would stop it in 3 days or less, usually same day. Early on it was hard to tell the difference between diarrhea/ loose stool or pouchitis. With me, it didn't matter what I ate or drank when pouchitis was happening. I had running or very loose stool regardless and I would keep the anti-biotics on hand at all times.
Dx UC 2001
Totel Colectomy with end ileostomy (emergency-toxic megacolon) 2003
J-pouch surgery 2004, 2 step
2005, temp ileostomy-due to j-pouch complications.
2011, j-pouch reconnection.
2018, j-pouch Removal and end ileostomy.