Modafinil is used to cure extreme sleepiness caused due to narcolepsy and other sleep related diseases such as breathing problem while sleeping (obstructive sleep apnea). It can also be consumed during work hours to avoid you from sleeping during odd work timings.
Modafinil should not be consumed to treat tiredness or the issue of oversleeping which is not because of any sleeping disorder. It also does not make your sleep go away. It works by affecting some substances in your brain that affects your sleeping cycle.