From 58ea6945c6df7a227e36648fe2db98b0510683b2 Mon Sep 17 00:00:00 2001 From: Antoine COMBET Date: Thu, 3 Mar 2022 22:36:06 +0100 Subject: [PATCH] Fixed some bugs and added some stuff --- app/Commands.hs | 26 ++++++++++++++++++++++++-- app/Commands/EDT.hs | 6 ++++-- app/Main.hs | 38 ++++++++++++++++++++++++++++++++------ 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/app/Commands.hs b/app/Commands.hs index e2647d8..8eddee7 100644 --- a/app/Commands.hs +++ b/app/Commands.hs @@ -7,7 +7,7 @@ import Discord ( restCall, DiscordHandler ) import Discord.Types ( ChannelId , User(..) , GuildMember(..) - , GuildId + , GuildId, UTCTime, Snowflake ) import Discord.Interactions ( interactionResponseBasic , createApplicationCommandChatInput @@ -116,6 +116,13 @@ remindCommand = ] } +data Remind = Remind { rmdWhen :: UTCTime + , rmdWhat :: T.Text + , rmdWhere :: Snowflake + , rmdWho :: Snowflake + } + deriving (Read, Show, Eq) + remindResponse :: Maybe InteractionDataApplicationCommandOptions -> EventSystem -> ChannelId @@ -127,7 +134,7 @@ remindResponse (Just (InteractionDataApplicationCommandOptionsValues opts)) evts MemberOrUser (Right User{userId = uid}) -> uid _ -> error "Couldnt get user id" let d = delay' - now <- liftIO $ getCurrentTime + now <- liftIO getCurrentTime let remindDateTime = case T.last d of 's' -> addUTCTime ( fromInteger @@ -169,6 +176,7 @@ remindResponse (Just (InteractionDataApplicationCommandOptionsValues opts)) evts ) return () ) + liftIO $ appendFile "reminds.data" $ show (Remind remindDateTime message ch userid) ++ "\n" return $ interactionResponseBasic $ "Reminder registered sucessfully for " @@ -239,3 +247,17 @@ groupResponse c groupResponse _ _ _ _ = return $ interactionResponseBasic "the group command has mandatory params, yet you managed not to give any, WOW" + +helpCommand :: Maybe CreateApplicationCommand +helpCommand = + createApplicationCommandChatInput + "help" + "help" + +helpResponse :: IO InteractionResponse +helpResponse = return . interactionResponseBasic + $ "**__Help for Bot IUT__**\n\n" + `T.append` "`/help` shows this help message\n" + `T.append` "`/group ` join a group\n" + `T.append` "`/remind