diff --git a/app/Main.hs b/app/Main.hs index e09b9a0..dea427c 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -38,6 +38,7 @@ import Commands.EDT (getEdt) import qualified Control.Concurrent import qualified Control.Event as E import UnliftIO.Directory (doesFileExist, removeFile) +import Data.Time (getCurrentTime) main :: IO () main = do @@ -75,9 +76,11 @@ onDiscordStart conf eventSystem = do remindfile <- liftIO $ readFile "reminds.data" let reminddata :: [Remind] reminddata = map read $ lines remindfile + now <- liftIO getCurrentTime mapM_ (\r -> do withRunInIO $ \runInIO -> - E.addEvent eventSystem (rmdWhen r) + if now > rmdWhen r then + void $ E.addEvent eventSystem (rmdWhen r) ( do runInIO ( restCall $ R.CreateMessage (rmdWhere r) @@ -88,7 +91,9 @@ onDiscordStart conf eventSystem = do ) return () ) - ) reminddata + else + pure () + ) reminddata liftIO $ removeFile "reminds.data"