| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Calamity.Interactions
Contents
Description
Calamity Interaction views
Synopsis
- module Calamity.Interactions.View
- module Calamity.Interactions.Utils
- module Calamity.Interactions.Eff
Documentation
module Calamity.Interactions.View
module Calamity.Interactions.Utils
module Calamity.Interactions.Eff
Interactions and Views
This module contains functions and types related to handling discord interactions.
The data models for components can be found in Calamity.Types.Model.Channel.Component
Examples
Displaying a View
{-# LANGUAGE ApplicativeDo #-}
let view = row $ do
a <- button ButtonPrimary "defer"
b <- button ButtonPrimary "deferEph"
c <- button ButtonPrimary "deferComp"
d <- button ButtonPrimary "modal"
pure (a, b, c, d)
modalView = do
a <- textInput TextInputShort "a"
b <- textInput TextInputParagraph "b"
pure (a, b)
in runView view (tell ctx) $ \(a, b, c, d) -> do
when a $ do
void defer
embed $ threadDelay 1000000
void $ followUp @Text "lol"
when b $ do
void deferEphemeral
embed $ threadDelay 1000000
void $ followUpEphemeral @Text "lol"
when c $ do
void deferComponent
embed $ threadDelay 1000000
void $ followUp @Text "lol"
when d $ do
void . async $ do
runView modalView (void . pushModal "lol") $ (a, b) -> do
embed $ print (a, b)
void $ respond ("Thanks: " <> a <> " " <> b)
endView ()
pure ()