well if you still want to use a while loop then make it abit better
to show the channels the bot is in
on $*:TEXT:/^!chanlist$/iS:#: {
var %a = $chan(0)
while (%a) {
var %m $addtok(%m,$chan(%a),32)
dec %a
}
msg # I'm in: %m
}
and $comchan so it would show the channels which both you and the bot are on.
on $*:TEXT:/^!chanlist$/iS:#: {
var %a = $comchan($nick,0)
while (%a) {
var %m $addtok(%m,$comchan($nick,%a),32)
dec %a
}
msg # Me and $nick are in these same channels: %m
}
but i would still go the $regsubex way as i stated before