Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data ViewEff ret inp sendResp m a where
- EndView :: ret -> ViewEff ret inp sendResp m ()
- ReplaceView :: View inp -> ([Component] -> m ()) -> ViewEff ret inp sendResp m ()
- GetSendResponse :: ViewEff ret inp sendResp m sendResp
- endView :: forall ret inp sendResp r. Member (ViewEff ret inp sendResp) r => ret -> Sem r ()
- replaceView :: forall ret inp sendResp r. Member (ViewEff ret inp sendResp) r => View inp -> ([Component] -> Sem r ()) -> Sem r ()
- getSendResponse :: forall ret inp sendResp r. Member (ViewEff ret inp sendResp) r => Sem r sendResp
- data View a
- row :: View a -> View a
- runView :: BotC r => View inp -> ([Component] -> Sem r sendResp) -> (inp -> Sem (InteractionEff ': (ViewEff a inp sendResp ': r)) ()) -> Sem r a
- runViewInstance :: BotC r => sendResp -> ViewInstance inp -> (inp -> Sem (InteractionEff ': (ViewEff a inp sendResp ': r)) ()) -> Sem r a
- button :: ButtonStyle -> Text -> View Bool
- button' :: (Button -> Button) -> View Bool
- select :: [Text] -> View (Maybe Text)
- select' :: [SelectOption] -> (Select -> Select) -> View (Maybe [Text])
- textInput :: TextInputStyle -> Text -> View Text
- textInput' :: TextInputStyle -> Text -> (TextInput -> TextInput) -> View (Maybe Text)
- deleteInitialMsg :: (BotC r, Member (ViewEff a inp (Either e Message)) r) => Sem r ()
- instantiateView :: RandomGen g => g -> View a -> (ViewInstance a, g)
Documentation
data ViewEff ret inp sendResp m a where Source #
EndView :: ret -> ViewEff ret inp sendResp m () | Mark the view as finished and set the return value. This doesn't trigger the immediate exit from the code it is used in, the view will exit before it would wait for the next event. |
ReplaceView :: View inp -> ([Component] -> m ()) -> ViewEff ret inp sendResp m () | Given a view and a way to display the rendered view to discord, show the view and start tracking the new view This works for both message components and modals |
GetSendResponse :: ViewEff ret inp sendResp m sendResp | Get the result of the action that sent a value |
endView :: forall ret inp sendResp r. Member (ViewEff ret inp sendResp) r => ret -> Sem r () Source #
Mark the view as finished and set the return value.
This doesn't trigger the immediate exit from the code it is used in, the view will exit before it would wait for the next event.
replaceView :: forall ret inp sendResp r. Member (ViewEff ret inp sendResp) r => View inp -> ([Component] -> Sem r ()) -> Sem r () Source #
Given a view and a way to display the rendered view to discord, show the view and start tracking the new view
This works for both message components and modals
getSendResponse :: forall ret inp sendResp r. Member (ViewEff ret inp sendResp) r => Sem r sendResp Source #
Get the result of the action that sent a value
A view containing one or more components
This has an applicative interface to allow for easy composition of components.
row :: View a -> View a Source #
Convert a View
such that it renders as a row.
Note: nested rows are not allowed by discord, along with further restrictions listed here: https://discord.com/developers/docs/interactions/message-components
:: BotC r | |
=> View inp | The initial view to render |
-> ([Component] -> Sem r sendResp) | A function to send the rendered view (i.e. as a message or a modal) |
-> (inp -> Sem (InteractionEff ': (ViewEff a inp sendResp ': r)) ()) | Your callback effect. local state semantics are preserved between calls here, you can keep state around |
-> Sem r a |
Run a View
, returning the value passed to endView
This function will not return until endView
is used inside the view.
If you want it to run in the background, consider using Polysemy.Async.
This is async exception safe, you can use libraries such as polysemy-conc to stop views after a timeout.
:: BotC r | |
=> sendResp | An initial value to act as the value of If you just sent a message, probably pass that |
-> ViewInstance inp | The initial view to run |
-> (inp -> Sem (InteractionEff ': (ViewEff a inp sendResp ': r)) ()) | Your callback effect. In here you get access to the local state semantics are preserved between calls here, you can keep state around |
-> Sem r a |
button' :: (Button -> Button) -> View Bool Source #
Construct a View
containing a Button
, then modify the component with
the passed mapping function
The Button
passed to the mapping function will have a style of
ButtonPrimary
, other fields will be Nothing
:: TextInputStyle | |
-> Text | Label |
-> View Text |