Kardafol's suggestion would work if $chans returned the channels separated by commas, you just need an extra replace:

Code:
on *:join:$($replace($chans,$chr(32),$chr(44))):{ 


or replace them in the actual alias. would look tidier


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde