{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module Commands where import Discord import Discord.Types import Discord.Interactions import qualified Discord.Requests as R import qualified Data.Text as T import qualified Data.Map.Strict as Map import Commands.EDT pingCommand :: CreateApplicationCommand pingCommand = CreateApplicationCommand "ping" "pong" (Just []) Nothing Nothing pingResponse :: InteractionResponse pingResponse = interactionResponseBasic "Pong" edtCommand :: CreateApplicationCommand edtCommand = CreateApplicationCommand "edt" "Gets the planning for a group" (Just $ toInternal <$> [ ApplicationCommandOptionValueString "group" "Group to get the planning for" (Just True) Nothing Nothing , ApplicationCommandOptionValueString "day" "The day you want the planning for as DD/MM(/YYYY)" Nothing Nothing Nothing ]) Nothing Nothing edtResponse :: Maybe InteractionDataApplicationCommandOptions -> InteractionResponse edtResponse (Just (InteractionDataApplicationCommandOptionsValues opts)) = interactionResponseBasic $ "You gave:\n```hs\n" `T.append` T.pack (show parsedOpts) `T.append` "\n```" where parsedOpts :: Map.Map T.Text T.Text parsedOpts = Map.fromList $ map parseOpt opts parseOpt :: InteractionDataApplicationCommandOptionValue -> (T.Text, T.Text) parseOpt (InteractionDataApplicationCommandOptionValue { interactionDataApplicationCommandOptionValueName = name , interactionDataApplicationCommandOptionValueValue = ApplicationCommandInteractionDataValueString val , ..} ) = (name, val) parseOpt _ = ("INVALID FORMAT", "INVALID FORMAT") edtResponse _ = interactionResponseBasic "The edt command should have params yet you managed not to give any: wow"