You are you using "else if" which is error prone, and you have no command after it.
Also, when someone joins a channel, they have no mode, they are not op, they are opped after they join the channel, isop on $nick always fail.
You probably tried to use a timer to get around this problem, which can be a solution, but with any kind of lag, it could fail.