1) In the ON NICK event, $nick contains the old nick and $newnick contains the new/current nick
2) You use $badnick but there's no way we can check for possible errors in that identifier without seeing the custom alias for it.
ie: alias badnick {
3) Invalid IF statement
It's impossible for a nick to be opped on a nick.. if you want to see if the nick is oppedk, use
if ($newnick !isop #channel) {