You have to make sure the $2 is banned in the channel, otherwise people can enter garbage to mess with it:
on @*:text:!ub *:#:{ if ($2 isban #) { mode # -b $2 } }