type /debug @whatever

then use the script if it returns a raw EVENT halt it.

Well i found out for you that maybe its 401 returning the error

if you want to prevent this from showing type in remotes

raw 401:*:halt

and for the double channel thing I might suggest to use a if statement that if ($newnick ison $active) { do stuff }

$active being the current active window sure if the nick changes on a non active channel then it wont work which generally is a bad idea but oh well... you have the raw event.