Move the code after the /whois into the raw 311 event.

The reason it doesn't work is that /whois doesn't pause scripts until it gets the server's reply. When the /whois reply does come your alias has already finished.