Code:
on @*:rawmode:#channel:{ mode # -mGU }


/mode doesn't throw out an error message if the mode is already set / not set, so just unset the modes whenever the modes in the channel change.

No need for any complex checks or parsing of the modes.