Then it must mean that the $chan identifier isn't filled, which means you're not calling it from a channel window.
$chan will be filled when issuing the command on a channel window, or in an event that fills $chan, or an alias that is called from an event where $chan is filled.
Or it could be that there are no ops on the channel where you are issuing that identifier.
/msg $opnick(#,1) $nick joins the room
By the way, if you are issuing this command from the editbox, then it will not work. That is because the $opnick(#,1) isn't evaluated. If you want identifiers and variables to evaluate from the command line, you must use double slash //
@NeoN: $opnick() works fine out of an event, it's simply a depreciated identifier, which still works.