None of that $qt stuff is necessary. Only commands need to use quotes strings, not identifiers.

Also, instead of using an $iif you could just turn off the timer when you leave your channel.

Code:
alias rndline { return $read($findfile($scriptdir $+ texts\,*.txt,$rand(1,$findfile($scriptdir $+ texts\,*.txt,0))),n) }

on *:connect:{ .timerrndline 0 60 msg #mychannel $!rndline }
on *:part:#mychannel:{ .timerrndline off }