In an ON JOIN event, you are always a regular, thus the second part of your first if statement will always return true
The ON JOIN event is triggered before ChanServ gives operator status to the nick.