Modafinil isn't a substitute for getting enough sleep. It should not be used to cure exhaustion or to keep people from sleeping if they don't have a sleep issue. Modafinil's mechanism for keeping you awake is uncertain. It is considered to function by influencing brain chemicals that regulate the sleep/wake cycle.