[07:50:17] * Your nick is now Colt45
[07:50:17] -NickServ- This nickname is registered and protected. If it is your
[07:50:17] -NickServ- nick, type /msg NickServ IDENTIFY password. Otherwise,
[07:50:17] -NickServ- please choose a different nick.
[07:50:17] -NickServ- Password accepted - you are now recognized.
[07:50:17] You need a registered nick to join that channel.
[07:50:18] * NickServ sets mode: +r

As you can see that it took 1 second for NickServ to set mode +r and my script went too fast.

So what and how do I fix that?

I've tried these 3 ON SNOTICE, ON NOTICE and ON ERROR but these 3 don't seem to pick up that "You need a registered nick to join that channel."

Also, tried to use ON USERMODE but can't find a way how to write code inside ON NOTICE as I didn't like to write code much, I'm still a newbie to coding.

Code
on *:notice:*:*:{
  if ($network == somenetwork) && ($nick == NickServ) {
    if (registered == $4) && (protected. == $6) { /ns identify password123 }
    if (Password == $1) && (accepted == $2) && (recognized. == $7) { /join #channel }
  }
}


The code above works for me, but it's just that I rarely get that "You need a registered nick to join that channel." - I think maybe because the server may be lagging a little?

By the way, I don't fancy the "timer" - but maybe a delayed script would work .. i.e. /delay 1 /join #channel .. this delay the command by 1 second? or something like that would be cool.

Thanks