Sorry, I misread your original question. I thought you meant if someone typed !test in an already opened DCC Chat window, you'd msg them something back in DCC Chat.
on *:CHAT:!test*: msg =$nick This is a test
That line would accomplish that. However, it wasn't what you asked for. You wanted it such that if someone said !test in any window, it would open a DCC Chat window to them and then tell them the result string in that DCC Chat window.
on *:TEXT:!test*:*:{
set -u300 %!test $nick
DCC Chat $nick
}
on *:OPEN:=:{
if ($nick == %!test) {
unset %!test
msg =$nick This is a test.
}
}