This line
Code:
mode $1 $replace($channel($1).mode,+,-)
appearantly tries to "invert " (remove) all channel modes. Replace it with:
Code:
mode $1 -mR