You can't use $chan inside the raw event, since it will return $null
Since you can't show me the script that you're currently using for the silent whois, there's only one possibility that I'm aware of as a solution.
Put my code into it's own remote, and let it stand alone. This will allow the two scripts to run independent of each other.
The code that you have posted here WILL NOT WORK
Also, there was no need to start a new topic regarding this problem.