Making someone sleep or awake, or resting can be done using the position variable, whch you won't have known about.
nop %actor.pos(sleeping)%
nop %actor.pos(resting)%
nop %actor.pos(sitting)%
nop %actor.pos(standing)%
nop %actor.pos(stunned)%
nop %actor.pos(dead)%
dg_cast spells are prone to being blocked by the actors spell defenses if they are aggressive, and some spells have a low chance of success in any case, and the dg_cast mob (yes, an actual mob casts the spells), has a chance of failing the spells too.
dg_affect however always works, no chance of failing.
But I would hope you would test out what the affect is going to be.
Such as, the AFFECT sleep, causes people not to wake up.
The SPELL sleep puts them to sleep.