Oh boy every once in a while, this sort of code shows up:
on $*:text:/\b(msg|join|part)\s(\43\S+)\b/iS:?:{
if ($istok(join part,$regml(1),32)) {
$regml(1) $regml(2)
}
else { msg $regml(2) $strip($$3-) }
}
You gotta make sure the $2 entered starts with the chantype "#" or it can be anything else to result an error. This is best done with regex as shown per my example.