Alternatively, to be a bit more future-proof, you can do this:
sudo pmset -a autopoweroffdelay 86400
Instead of disabling autopoweroff, this will change it from 4 hours (the default 14400 minutes) to 24 hours, so it will only hibernate after 24 hours.
As far as I can tell, the plan seems to be to auto-hibernate after being asleep for some time, to prevent battery drain. (I actually applaud this, because it ***** when my MacBook's battery is completely drained after sitting around for 3 or 4 days.)
However, they seem to have introduced a bug where it hibernates when plugged in, and doesn't hibernate when on battery, which is pretty much the exact opposite of what you want. Almost certainly their code just has a sign flip somewhere.
I'm pretty sure this was introduced with a system update at some point, so presumably Apple will fix it eventually. When they do, they might not reset any pmset fiddling you may have done.
This is why I recommend lengthening the autopoweroffdelay from 4 to 24 hours instead of turning it off altogether. That way, when they do eventually fix it, you'll still get the benefit of auto-hibernation after a more reasonable 24 hour span, and have a working laptop even if you don't touch it for a few days.