Looks like you added the raw event inside the join event codeblock, that makes mIRC send "366:$(* %spam.chan *):{" as a raw command.