A4IX64FMBOLH5PQPR6VY6XAC4V7SGKXIBGTTTA65L57LVJKHHVPAC
packages: . vendor/discord-haskell
slashDiffCommand :: Maybe CreateApplicationCommand
slashDiffCommand = options <$> createChatInput "diff" "Check the diff of two decklists"
where
options command =
command
{ createOptions =
Just $
OptionsValues
[ OptionValueAttachment "old" Nothing "Old decklist" Nothing True
, OptionValueAttachment "new" Nothing "New decklist" Nothing True
]
}
onReady :: ApplicationId -> DiscordHandler ()
onReady appId = case slashDiffCommand of
Nothing -> pure ()
Just command -> do
res <- restCall $ Request.CreateGlobalApplicationCommand appId command
case res of
Left e -> liftIO $ print e
Right validCmds -> do
liftIO $ putStrLn "Command successfully registered"
registered <- restCall $ Request.GetGlobalApplicationCommands appId
case registered of
Left _ -> liftIO $ putStrLn "error occured"
Right cmds -> do
let validId = applicationCommandId validCmds
outdatedIds = filter (/= validId) . map applicationCommandId $ cmds
in forM_ outdatedIds $
restCall . Request.DeleteGlobalApplicationCommand appId