Safe Haskell | None |
---|---|
Language | Haskell2010 |
Provides types and encoding/decoding code. Types should be identical to those provided in the Discord API documentation.
- data StateEnum
- data DiscordState = Client a => DiscordState {
- getState :: StateEnum
- getClient :: a
- getWebSocket :: Connection
- getSequenceNum :: TMVar Integer
- getRateLimits :: TVar [(Int, Int)]
- type DiscordM = StateT DiscordState IO
- class Client c where
- data Auth
- authToken :: Auth -> String
- newtype Snowflake = Snowflake Word64
- creationDate :: Snowflake -> UTCTime
- epochTime :: UTCTime
- delete :: Eq a => a -> [(a, b)] -> [(a, b)]
- insert :: Eq a => a -> b -> [(a, b)] -> [(a, b)]
- justRight :: Show a => Either a b -> b
- reparse :: (ToJSON a, FromJSON b) => a -> Either String b
- module Network.Discord.Types.Channel
- module Network.Discord.Types.Events
- module Network.Discord.Types.Gateway
- module Network.Discord.Types.Guild
Documentation
Provides a list of possible states for the client gateway to be in.
data DiscordState Source #
Stores details needed to manage the gateway and bot
Client a => DiscordState | |
|
type DiscordM = StateT DiscordState IO Source #
Convenience type alias for the monad most used throughout most Discord.hs operations
The Client typeclass holds the majority of the user-customizable state, including merging states resulting from async operations.
Provides authorization token associated with the client
Function for resolving state differences due to async operations. Developers are responsible for preventing race conditions. Remember as `merge newState oldState`
getTMClient :: TVar c Source #
Control access to state. In cases where state locks aren't needed, this is most likely the best solution. This implementation most likely needs an accompanying {-# NOINLINE getTMClient #-} pragma to ensure that a single state is shared between events
getSTMClient :: Proxy c -> STM c Source #
In some cases, state locks are needed to prevent race conditions or TVars are an unwanted solution. In these cases, both getClient and modifyClient should be implemented.
modifyClient :: (c -> c) -> STM () Source #
modifyClient is used by mergeClient to merge application states before and after an event handler is run
mergeClient :: c -> STM () Source #
Merges application states before and after an event handler
Authorization token for the Discord API
A unique integer identifier. Can be used to calculate the creation date of an entity.
creationDate :: Snowflake -> UTCTime Source #
Gets a creation date from a snowflake.
reparse :: (ToJSON a, FromJSON b) => a -> Either String b Source #
Convert ToJSON values to FromJSON values
module Network.Discord.Types.Events
module Network.Discord.Types.Guild