Safe Haskell | None |
---|---|
Language | Haskell2010 |
The client
Synopsis
- react :: forall (s :: EventType) r. (BotC r, InsertEventHandler s (Sem r)) => EHType s (Sem r) -> Sem r ()
- runBotIO :: (Members '[Embed IO, Final IO, Fail, CacheEff, MetricEff] r, Typeable r) => Token -> SetupEff r -> Sem r ()
- stopBot :: BotC r => Sem r ()
- sendPresence :: BotC r => StatusUpdateData -> Sem r ()
- events :: BotC r => Sem r (OutChan CalamityEvent)
- fire :: BotC r => CalamityEvent -> Sem r ()
- data CalamityEvent
- customEvt :: forall s a. (Typeable s, Typeable a) => a -> CalamityEvent
Documentation
react :: forall (s :: EventType) r. (BotC r, InsertEventHandler s (Sem r)) => EHType s (Sem r) -> Sem r () Source #
Register an event handler.
Refer to EventType
for what events you can register, and EHType
for the
parameters the event handlers they receive.
You'll probably want TypeApplications
and need DataKinds
enabled to
specify the type of s
.
Examples
Reacting to every message:
react
@'MessageCreateEvt
$
msg ->$
"Got message: "<>
show
msg
Reacting to a custom event:
react
('
CustomEvt
"my-event" (Text
,Message
)) $ (s, m) ->void
$tell
Text
m ("Somebody told me to tell you about: "<>
s)
Notes
This function is pretty bad for giving nasty type errors,
since if something doesn't match then EHType
might not get substituted,
which will result in errors about parameter counts mismatching.
runBotIO :: (Members '[Embed IO, Final IO, Fail, CacheEff, MetricEff] r, Typeable r) => Token -> SetupEff r -> Sem r () Source #
Create a bot, run your setup action, and then loop until the bot closes.
This method has a Fail
effect to handle fatal errors that happen during
setup (bad token, etc).
sendPresence :: BotC r => StatusUpdateData -> Sem r () Source #
Set the bot's presence on all shards.
events :: BotC r => Sem r (OutChan CalamityEvent) Source #
Get a copy of the event stream.
fire :: BotC r => CalamityEvent -> Sem r () Source #
data CalamityEvent Source #