You may use the && operator to save yourself an if statement:
on @*:text:!ub *:#:{ if ($nick == ur nick) && ($2 isban #) { mode # -b $2 } }