To return joined channels use the suggestions mentioned above, but change $chan(0) to $comchan($me,0), for example:

Code:
alias totalchannels var %c = 0 | scon -at1 inc $(%c $comchan($me,0),) | return %c