module Calamity.Interactions.Utils (
respond,
respondEphemeral,
followUp,
followUpEphemeral,
edit,
defer,
deferEphemeral,
deferComponent,
pushModal,
userLocalState,
) where
import Calamity.HTTP
import Calamity.Interactions.Eff (InteractionEff, getApplicationID, getInteractionID, getInteractionToken, getInteractionUser)
import Calamity.Metrics.Eff (MetricEff)
import Calamity.Types.LogEff (LogEff)
import Calamity.Types.Model.Channel.Component (Component (ActionRow'))
import Calamity.Types.Model.User (User)
import Calamity.Types.Snowflake (Snowflake)
import Calamity.Types.Tellable
import Data.HashMap.Strict qualified as H
import Data.Text (Text)
import Optics
import Polysemy qualified as P
import Polysemy.State qualified as P
import System.Random (getStdRandom, uniform)
userLocalState ::
forall r s a.
P.Member InteractionEff r =>
s ->
P.Sem (P.State s ': r) a ->
P.Sem r a
userLocalState :: forall (r :: EffectRow) s a.
Member InteractionEff r =>
s -> Sem (State s : r) a -> Sem r a
userLocalState s
s =
HashMap (Snowflake User) s
-> Sem (State (HashMap (Snowflake User) s) : r) a -> Sem r a
forall s (r :: EffectRow) a. s -> Sem (State s : r) a -> Sem r a
P.evalState HashMap (Snowflake User) s
forall k v. HashMap k v
H.empty
(Sem (State (HashMap (Snowflake User) s) : r) a -> Sem r a)
-> (Sem (State s : r) a
-> Sem (State (HashMap (Snowflake User) s) : r) a)
-> Sem (State s : r) a
-> Sem r a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (e1 :: (* -> *) -> * -> *) (e2 :: (* -> *) -> * -> *)
(r :: EffectRow) a.
FirstOrder e1 "reinterpret" =>
(forall (rInitial :: EffectRow) x.
e1 (Sem rInitial) x -> Sem (e2 : r) x)
-> Sem (e1 : r) a -> Sem (e2 : r) a
P.reinterpret @(P.State s) @(P.State (H.HashMap (Snowflake User) s))
( \case
State s (Sem rInitial) x
P.Get -> do
Snowflake User
uid <- Sem (State (HashMap (Snowflake User) s) : r) (Snowflake User)
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r (Snowflake User)
getInteractionUser
(HashMap (Snowflake User) x -> x)
-> Sem (State (HashMap (Snowflake User) s) : r) x
forall s a (r :: EffectRow).
Member (State s) r =>
(s -> a) -> Sem r a
P.gets (x -> Snowflake User -> HashMap (Snowflake User) x -> x
forall k v. (Eq k, Hashable k) => v -> k -> HashMap k v -> v
H.lookupDefault s
x
s Snowflake User
uid)
P.Put s
s -> do
Snowflake User
uid <- Sem (State (HashMap (Snowflake User) s) : r) (Snowflake User)
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r (Snowflake User)
getInteractionUser
(HashMap (Snowflake User) s -> HashMap (Snowflake User) s)
-> Sem (State (HashMap (Snowflake User) s) : r) ()
forall s (r :: EffectRow).
Member (State s) r =>
(s -> s) -> Sem r ()
P.modify' (Snowflake User
-> s -> HashMap (Snowflake User) s -> HashMap (Snowflake User) s
forall k v.
(Eq k, Hashable k) =>
k -> v -> HashMap k v -> HashMap k v
H.insert Snowflake User
uid s
s)
)
respond ::
forall t r.
(P.Members '[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff, P.Embed IO] r, ToMessage t) =>
t ->
P.Sem r (Either RestError ())
respond :: forall t (r :: EffectRow).
(Members
'[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff,
Embed IO]
r,
ToMessage t) =>
t -> Sem r (Either RestError ())
respond (t -> CreateMessageOptions
forall a. ToMessage a => a -> CreateMessageOptions
runToMessage -> CreateMessageOptions
msg) =
let opts :: InteractionCallbackMessageOptions
opts =
InteractionCallbackMessageOptions
{ $sel:tts:InteractionCallbackMessageOptions :: Maybe Bool
tts = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe Bool)
-> Maybe Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe Bool)
#tts
, $sel:content:InteractionCallbackMessageOptions :: Maybe Text
content = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe Text)
#content
, $sel:embeds:InteractionCallbackMessageOptions :: Maybe [Embed]
embeds = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe [Embed])
-> Maybe [Embed]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe [Embed])
#embeds
, $sel:allowedMentions:InteractionCallbackMessageOptions :: Maybe AllowedMentions
allowedMentions = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe AllowedMentions)
-> Maybe AllowedMentions
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe AllowedMentions)
#allowedMentions
, $sel:ephemeral:InteractionCallbackMessageOptions :: Maybe Bool
ephemeral = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
False
, $sel:suppressEmbeds:InteractionCallbackMessageOptions :: Maybe Bool
suppressEmbeds = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
False
, $sel:components:InteractionCallbackMessageOptions :: Maybe [Component]
components = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe [Component])
-> Maybe [Component]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe [Component])
#components
, $sel:attachments:InteractionCallbackMessageOptions :: Maybe [CreateMessageAttachment]
attachments = CreateMessageOptions
msg CreateMessageOptions
-> Optic'
A_Lens NoIx CreateMessageOptions (Maybe [CreateMessageAttachment])
-> Maybe [CreateMessageAttachment]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens NoIx CreateMessageOptions (Maybe [CreateMessageAttachment])
#attachments
}
in do
Snowflake Interaction
interactionID <- Sem r (Snowflake Interaction)
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r (Snowflake Interaction)
getInteractionID
InteractionToken
interactionToken <- Sem r InteractionToken
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r InteractionToken
getInteractionToken
InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall (r :: EffectRow) a.
(Members '[RatelimitEff, TokenEff, LogEff, MetricEff, Embed IO] r,
Request a, ReadResponse (Result a)) =>
a -> Sem r (Either RestError (Result a))
invoke (InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ()))))
-> InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall a b. (a -> b) -> a -> b
$ Snowflake Interaction
-> InteractionToken
-> InteractionCallbackMessageOptions
-> InteractionRequest ()
forall i.
HasID Interaction i =>
i
-> InteractionToken
-> InteractionCallbackMessageOptions
-> InteractionRequest ()
CreateResponseMessage Snowflake Interaction
interactionID InteractionToken
interactionToken InteractionCallbackMessageOptions
opts
respondEphemeral ::
forall t r.
(P.Members '[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff, P.Embed IO] r, ToMessage t) =>
t ->
P.Sem r (Either RestError ())
respondEphemeral :: forall t (r :: EffectRow).
(Members
'[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff,
Embed IO]
r,
ToMessage t) =>
t -> Sem r (Either RestError ())
respondEphemeral (t -> CreateMessageOptions
forall a. ToMessage a => a -> CreateMessageOptions
runToMessage -> CreateMessageOptions
msg) =
let opts :: InteractionCallbackMessageOptions
opts =
InteractionCallbackMessageOptions
{ $sel:tts:InteractionCallbackMessageOptions :: Maybe Bool
tts = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe Bool)
-> Maybe Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe Bool)
#tts
, $sel:content:InteractionCallbackMessageOptions :: Maybe Text
content = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe Text)
#content
, $sel:embeds:InteractionCallbackMessageOptions :: Maybe [Embed]
embeds = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe [Embed])
-> Maybe [Embed]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe [Embed])
#embeds
, $sel:allowedMentions:InteractionCallbackMessageOptions :: Maybe AllowedMentions
allowedMentions = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe AllowedMentions)
-> Maybe AllowedMentions
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe AllowedMentions)
#allowedMentions
, $sel:ephemeral:InteractionCallbackMessageOptions :: Maybe Bool
ephemeral = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True
, $sel:suppressEmbeds:InteractionCallbackMessageOptions :: Maybe Bool
suppressEmbeds = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
False
, $sel:components:InteractionCallbackMessageOptions :: Maybe [Component]
components = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe [Component])
-> Maybe [Component]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe [Component])
#components
, $sel:attachments:InteractionCallbackMessageOptions :: Maybe [CreateMessageAttachment]
attachments = CreateMessageOptions
msg CreateMessageOptions
-> Optic'
A_Lens NoIx CreateMessageOptions (Maybe [CreateMessageAttachment])
-> Maybe [CreateMessageAttachment]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens NoIx CreateMessageOptions (Maybe [CreateMessageAttachment])
#attachments
}
in do
Snowflake Interaction
interactionID <- Sem r (Snowflake Interaction)
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r (Snowflake Interaction)
getInteractionID
InteractionToken
interactionToken <- Sem r InteractionToken
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r InteractionToken
getInteractionToken
InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall (r :: EffectRow) a.
(Members '[RatelimitEff, TokenEff, LogEff, MetricEff, Embed IO] r,
Request a, ReadResponse (Result a)) =>
a -> Sem r (Either RestError (Result a))
invoke (InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ()))))
-> InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall a b. (a -> b) -> a -> b
$ Snowflake Interaction
-> InteractionToken
-> InteractionCallbackMessageOptions
-> InteractionRequest ()
forall i.
HasID Interaction i =>
i
-> InteractionToken
-> InteractionCallbackMessageOptions
-> InteractionRequest ()
CreateResponseMessage Snowflake Interaction
interactionID InteractionToken
interactionToken InteractionCallbackMessageOptions
opts
edit ::
forall t r.
(P.Members '[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff, P.Embed IO] r, ToMessage t) =>
t ->
P.Sem r (Either RestError ())
edit :: forall t (r :: EffectRow).
(Members
'[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff,
Embed IO]
r,
ToMessage t) =>
t -> Sem r (Either RestError ())
edit (t -> CreateMessageOptions
forall a. ToMessage a => a -> CreateMessageOptions
runToMessage -> CreateMessageOptions
msg) =
let opts :: InteractionCallbackMessageOptions
opts =
InteractionCallbackMessageOptions
{ $sel:tts:InteractionCallbackMessageOptions :: Maybe Bool
tts = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe Bool)
-> Maybe Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe Bool)
#tts
, $sel:content:InteractionCallbackMessageOptions :: Maybe Text
content = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe Text)
#content
, $sel:embeds:InteractionCallbackMessageOptions :: Maybe [Embed]
embeds = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe [Embed])
-> Maybe [Embed]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe [Embed])
#embeds
, $sel:allowedMentions:InteractionCallbackMessageOptions :: Maybe AllowedMentions
allowedMentions = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe AllowedMentions)
-> Maybe AllowedMentions
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe AllowedMentions)
#allowedMentions
, $sel:ephemeral:InteractionCallbackMessageOptions :: Maybe Bool
ephemeral = Maybe Bool
forall a. Maybe a
Nothing
, $sel:suppressEmbeds:InteractionCallbackMessageOptions :: Maybe Bool
suppressEmbeds = Maybe Bool
forall a. Maybe a
Nothing
, $sel:components:InteractionCallbackMessageOptions :: Maybe [Component]
components = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe [Component])
-> Maybe [Component]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe [Component])
#components
, $sel:attachments:InteractionCallbackMessageOptions :: Maybe [CreateMessageAttachment]
attachments = CreateMessageOptions
msg CreateMessageOptions
-> Optic'
A_Lens NoIx CreateMessageOptions (Maybe [CreateMessageAttachment])
-> Maybe [CreateMessageAttachment]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens NoIx CreateMessageOptions (Maybe [CreateMessageAttachment])
#attachments
}
in do
Snowflake Interaction
interactionID <- Sem r (Snowflake Interaction)
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r (Snowflake Interaction)
getInteractionID
InteractionToken
interactionToken <- Sem r InteractionToken
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r InteractionToken
getInteractionToken
InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall (r :: EffectRow) a.
(Members '[RatelimitEff, TokenEff, LogEff, MetricEff, Embed IO] r,
Request a, ReadResponse (Result a)) =>
a -> Sem r (Either RestError (Result a))
invoke (InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ()))))
-> InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall a b. (a -> b) -> a -> b
$ Snowflake Interaction
-> InteractionToken
-> InteractionCallbackMessageOptions
-> InteractionRequest ()
forall i.
HasID Interaction i =>
i
-> InteractionToken
-> InteractionCallbackMessageOptions
-> InteractionRequest ()
CreateResponseUpdate Snowflake Interaction
interactionID InteractionToken
interactionToken InteractionCallbackMessageOptions
opts
followUp ::
forall t r.
(P.Members '[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff, P.Embed IO] r, ToMessage t) =>
t ->
P.Sem r (Either RestError ())
followUp :: forall t (r :: EffectRow).
(Members
'[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff,
Embed IO]
r,
ToMessage t) =>
t -> Sem r (Either RestError ())
followUp (t -> CreateMessageOptions
forall a. ToMessage a => a -> CreateMessageOptions
runToMessage -> CreateMessageOptions
msg) =
let opts :: InteractionCallbackMessageOptions
opts =
InteractionCallbackMessageOptions
{ $sel:tts:InteractionCallbackMessageOptions :: Maybe Bool
tts = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe Bool)
-> Maybe Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe Bool)
#tts
, $sel:content:InteractionCallbackMessageOptions :: Maybe Text
content = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe Text)
#content
, $sel:embeds:InteractionCallbackMessageOptions :: Maybe [Embed]
embeds = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe [Embed])
-> Maybe [Embed]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe [Embed])
#embeds
, $sel:allowedMentions:InteractionCallbackMessageOptions :: Maybe AllowedMentions
allowedMentions = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe AllowedMentions)
-> Maybe AllowedMentions
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe AllowedMentions)
#allowedMentions
, $sel:ephemeral:InteractionCallbackMessageOptions :: Maybe Bool
ephemeral = Maybe Bool
forall a. Maybe a
Nothing
, $sel:suppressEmbeds:InteractionCallbackMessageOptions :: Maybe Bool
suppressEmbeds = Maybe Bool
forall a. Maybe a
Nothing
, $sel:components:InteractionCallbackMessageOptions :: Maybe [Component]
components = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe [Component])
-> Maybe [Component]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe [Component])
#components
, $sel:attachments:InteractionCallbackMessageOptions :: Maybe [CreateMessageAttachment]
attachments = CreateMessageOptions
msg CreateMessageOptions
-> Optic'
A_Lens NoIx CreateMessageOptions (Maybe [CreateMessageAttachment])
-> Maybe [CreateMessageAttachment]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens NoIx CreateMessageOptions (Maybe [CreateMessageAttachment])
#attachments
}
in do
Snowflake Application
applicationID <- Sem r (Snowflake Application)
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r (Snowflake Application)
getApplicationID
InteractionToken
interactionToken <- Sem r InteractionToken
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r InteractionToken
getInteractionToken
InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall (r :: EffectRow) a.
(Members '[RatelimitEff, TokenEff, LogEff, MetricEff, Embed IO] r,
Request a, ReadResponse (Result a)) =>
a -> Sem r (Either RestError (Result a))
invoke (InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ()))))
-> InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall a b. (a -> b) -> a -> b
$ Snowflake Application
-> InteractionToken
-> InteractionCallbackMessageOptions
-> InteractionRequest ()
forall i.
HasID Application i =>
i
-> InteractionToken
-> InteractionCallbackMessageOptions
-> InteractionRequest ()
CreateFollowupMessage Snowflake Application
applicationID InteractionToken
interactionToken InteractionCallbackMessageOptions
opts
followUpEphemeral ::
forall t r.
(P.Members '[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff, P.Embed IO] r, ToMessage t) =>
t ->
P.Sem r (Either RestError ())
followUpEphemeral :: forall t (r :: EffectRow).
(Members
'[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff,
Embed IO]
r,
ToMessage t) =>
t -> Sem r (Either RestError ())
followUpEphemeral (t -> CreateMessageOptions
forall a. ToMessage a => a -> CreateMessageOptions
runToMessage -> CreateMessageOptions
msg) =
let opts :: InteractionCallbackMessageOptions
opts =
InteractionCallbackMessageOptions
{ $sel:tts:InteractionCallbackMessageOptions :: Maybe Bool
tts = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe Bool)
-> Maybe Bool
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe Bool)
#tts
, $sel:content:InteractionCallbackMessageOptions :: Maybe Text
content = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe Text)
#content
, $sel:embeds:InteractionCallbackMessageOptions :: Maybe [Embed]
embeds = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe [Embed])
-> Maybe [Embed]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe [Embed])
#embeds
, $sel:allowedMentions:InteractionCallbackMessageOptions :: Maybe AllowedMentions
allowedMentions = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe AllowedMentions)
-> Maybe AllowedMentions
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe AllowedMentions)
#allowedMentions
, $sel:ephemeral:InteractionCallbackMessageOptions :: Maybe Bool
ephemeral = Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True
, $sel:suppressEmbeds:InteractionCallbackMessageOptions :: Maybe Bool
suppressEmbeds = Maybe Bool
forall a. Maybe a
Nothing
, $sel:components:InteractionCallbackMessageOptions :: Maybe [Component]
components = CreateMessageOptions
msg CreateMessageOptions
-> Optic' A_Lens NoIx CreateMessageOptions (Maybe [Component])
-> Maybe [Component]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic' A_Lens NoIx CreateMessageOptions (Maybe [Component])
#components
, $sel:attachments:InteractionCallbackMessageOptions :: Maybe [CreateMessageAttachment]
attachments = CreateMessageOptions
msg CreateMessageOptions
-> Optic'
A_Lens NoIx CreateMessageOptions (Maybe [CreateMessageAttachment])
-> Maybe [CreateMessageAttachment]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic'
A_Lens NoIx CreateMessageOptions (Maybe [CreateMessageAttachment])
#attachments
}
in do
Snowflake Application
applicationID <- Sem r (Snowflake Application)
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r (Snowflake Application)
getApplicationID
InteractionToken
interactionToken <- Sem r InteractionToken
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r InteractionToken
getInteractionToken
InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall (r :: EffectRow) a.
(Members '[RatelimitEff, TokenEff, LogEff, MetricEff, Embed IO] r,
Request a, ReadResponse (Result a)) =>
a -> Sem r (Either RestError (Result a))
invoke (InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ()))))
-> InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall a b. (a -> b) -> a -> b
$ Snowflake Application
-> InteractionToken
-> InteractionCallbackMessageOptions
-> InteractionRequest ()
forall i.
HasID Application i =>
i
-> InteractionToken
-> InteractionCallbackMessageOptions
-> InteractionRequest ()
CreateFollowupMessage Snowflake Application
applicationID InteractionToken
interactionToken InteractionCallbackMessageOptions
opts
defer :: P.Members '[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff, P.Embed IO] r => P.Sem r (Either RestError ())
defer :: forall (r :: EffectRow).
Members
'[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff,
Embed IO]
r =>
Sem r (Either RestError ())
defer = do
Snowflake Interaction
interactionID <- Sem r (Snowflake Interaction)
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r (Snowflake Interaction)
getInteractionID
InteractionToken
interactionToken <- Sem r InteractionToken
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r InteractionToken
getInteractionToken
InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall (r :: EffectRow) a.
(Members '[RatelimitEff, TokenEff, LogEff, MetricEff, Embed IO] r,
Request a, ReadResponse (Result a)) =>
a -> Sem r (Either RestError (Result a))
invoke (InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ()))))
-> InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall a b. (a -> b) -> a -> b
$ Snowflake Interaction
-> InteractionToken -> Bool -> InteractionRequest ()
forall i.
HasID Interaction i =>
i -> InteractionToken -> Bool -> InteractionRequest ()
CreateResponseDefer Snowflake Interaction
interactionID InteractionToken
interactionToken Bool
False
deferEphemeral :: P.Members '[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff, P.Embed IO] r => P.Sem r (Either RestError ())
deferEphemeral :: forall (r :: EffectRow).
Members
'[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff,
Embed IO]
r =>
Sem r (Either RestError ())
deferEphemeral = do
Snowflake Interaction
interactionID <- Sem r (Snowflake Interaction)
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r (Snowflake Interaction)
getInteractionID
InteractionToken
interactionToken <- Sem r InteractionToken
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r InteractionToken
getInteractionToken
InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall (r :: EffectRow) a.
(Members '[RatelimitEff, TokenEff, LogEff, MetricEff, Embed IO] r,
Request a, ReadResponse (Result a)) =>
a -> Sem r (Either RestError (Result a))
invoke (InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ()))))
-> InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall a b. (a -> b) -> a -> b
$ Snowflake Interaction
-> InteractionToken -> Bool -> InteractionRequest ()
forall i.
HasID Interaction i =>
i -> InteractionToken -> Bool -> InteractionRequest ()
CreateResponseDefer Snowflake Interaction
interactionID InteractionToken
interactionToken Bool
True
deferComponent :: P.Members '[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff, P.Embed IO] r => P.Sem r (Either RestError ())
deferComponent :: forall (r :: EffectRow).
Members
'[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff,
Embed IO]
r =>
Sem r (Either RestError ())
deferComponent = do
Snowflake Interaction
interactionID <- Sem r (Snowflake Interaction)
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r (Snowflake Interaction)
getInteractionID
InteractionToken
interactionToken <- Sem r InteractionToken
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r InteractionToken
getInteractionToken
InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall (r :: EffectRow) a.
(Members '[RatelimitEff, TokenEff, LogEff, MetricEff, Embed IO] r,
Request a, ReadResponse (Result a)) =>
a -> Sem r (Either RestError (Result a))
invoke (InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ()))))
-> InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall a b. (a -> b) -> a -> b
$ Snowflake Interaction -> InteractionToken -> InteractionRequest ()
forall i.
HasID Interaction i =>
i -> InteractionToken -> InteractionRequest ()
CreateResponseDeferComponent Snowflake Interaction
interactionID InteractionToken
interactionToken
fixupActionRow :: Component -> Component
fixupActionRow :: Component -> Component
fixupActionRow r :: Component
r@(ActionRow' [Component]
_) = Component
r
fixupActionRow Component
x = [Component] -> Component
ActionRow' [Component
x]
pushModal :: P.Members '[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff, P.Embed IO] r => Text -> [Component] -> P.Sem r (Either RestError ())
pushModal :: forall (r :: EffectRow).
Members
'[InteractionEff, RatelimitEff, TokenEff, LogEff, MetricEff,
Embed IO]
r =>
Text -> [Component] -> Sem r (Either RestError ())
pushModal Text
title [Component]
c = do
CustomID
cid <- IO CustomID -> Sem r CustomID
forall (m :: * -> *) (r :: EffectRow) a.
Member (Embed m) r =>
m a -> Sem r a
P.embed (IO CustomID -> Sem r CustomID) -> IO CustomID -> Sem r CustomID
forall a b. (a -> b) -> a -> b
$ (StdGen -> (CustomID, StdGen)) -> IO CustomID
forall (m :: * -> *) a. MonadIO m => (StdGen -> (a, StdGen)) -> m a
getStdRandom StdGen -> (CustomID, StdGen)
forall g a. (RandomGen g, Uniform a) => g -> (a, g)
uniform
Snowflake Interaction
interactionID <- Sem r (Snowflake Interaction)
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r (Snowflake Interaction)
getInteractionID
InteractionToken
interactionToken <- Sem r InteractionToken
forall (r :: EffectRow).
Member InteractionEff r =>
Sem r InteractionToken
getInteractionToken
InteractionRequest () -> Sem r (Either RestError ())
InteractionRequest ()
-> Sem r (Either RestError (Result (InteractionRequest ())))
forall (r :: EffectRow) a.
(Members '[RatelimitEff, TokenEff, LogEff, MetricEff, Embed IO] r,
Request a, ReadResponse (Result a)) =>
a -> Sem r (Either RestError (Result a))
invoke (InteractionRequest () -> Sem r (Either RestError ()))
-> (InteractionCallbackModal -> InteractionRequest ())
-> InteractionCallbackModal
-> Sem r (Either RestError ())
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Snowflake Interaction
-> InteractionToken
-> InteractionCallbackModal
-> InteractionRequest ()
forall i.
HasID Interaction i =>
i
-> InteractionToken
-> InteractionCallbackModal
-> InteractionRequest ()
CreateResponseModal Snowflake Interaction
interactionID InteractionToken
interactionToken (InteractionCallbackModal -> Sem r (Either RestError ()))
-> InteractionCallbackModal -> Sem r (Either RestError ())
forall a b. (a -> b) -> a -> b
$ CustomID -> Text -> [Component] -> InteractionCallbackModal
InteractionCallbackModal CustomID
cid Text
title ((Component -> Component) -> [Component] -> [Component]
forall a b. (a -> b) -> [a] -> [b]
map Component -> Component
fixupActionRow [Component]
c)