discord-hs-0.2.2: An API wrapper for Discord in Haskell

Safe HaskellNone
LanguageHaskell2010

Network.Discord.Types

Description

Provides types and encoding/decoding code. Types should be identical to those provided in the Discord API documentation.

Synopsis

Documentation

data StateEnum Source #

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

Constructors

Client a => DiscordState 

Fields

newtype DiscordM a Source #

Convenience type alias for the monad most used throughout most Discord.hs operations

Constructors

DiscordM (StateT DiscordState IO a) 

Instances

Monad DiscordM Source # 

Methods

(>>=) :: DiscordM a -> (a -> DiscordM b) -> DiscordM b #

(>>) :: DiscordM a -> DiscordM b -> DiscordM b #

return :: a -> DiscordM a #

fail :: String -> DiscordM a #

Functor DiscordM Source # 

Methods

fmap :: (a -> b) -> DiscordM a -> DiscordM b #

(<$) :: a -> DiscordM b -> DiscordM a #

Applicative DiscordM Source # 

Methods

pure :: a -> DiscordM a #

(<*>) :: DiscordM (a -> b) -> DiscordM a -> DiscordM b #

(*>) :: DiscordM a -> DiscordM b -> DiscordM b #

(<*) :: DiscordM a -> DiscordM b -> DiscordM a #

MonadIO DiscordM Source # 

Methods

liftIO :: IO a -> DiscordM a #

MonadHttp DiscordM Source #

Allow HTTP requests to be made from the DiscordM monad

MonadState DiscordState DiscordM Source # 

evalDiscordM :: DiscordM a -> DiscordState -> IO a Source #

Unwrap and eval a DiscordM

class Client c where Source #

The Client typeclass holds the majority of the user-customizable state, including merging states resulting from async operations.

Minimal complete definition

getAuth

Methods

getAuth :: c -> Auth Source #

Provides authorization token associated with the client

merge :: c -> c -> c Source #

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

data Auth Source #

Authorization token for the Discord API

Instances

Show Auth Source #

Formats the token for use with the REST API

Methods

showsPrec :: Int -> Auth -> ShowS #

show :: Auth -> String #

showList :: [Auth] -> ShowS #

authToken :: Auth -> String Source #

Get the raw token formatted for use with the websocket gateway

newtype Snowflake Source #

A unique integer identifier. Can be used to calculate the creation date of an entity.

Constructors

Snowflake Word64 

Instances

Enum Snowflake Source # 
Eq Snowflake Source # 
Integral Snowflake Source # 
Num Snowflake Source # 
Ord Snowflake Source # 
Real Snowflake Source # 
Show Snowflake Source # 
Hashable Snowflake Source # 
ToJSON Snowflake Source # 
FromJSON Snowflake Source # 
Bits Snowflake Source # 

creationDate :: Snowflake -> UTCTime Source #

Gets a creation date from a snowflake.

epochTime :: UTCTime Source #

Default timestamp

delete :: Eq a => a -> [(a, b)] -> [(a, b)] Source #

Delete a (key, value) pair if the key exists

insert :: Eq a => a -> b -> [(a, b)] -> [(a, b)] Source #

Insert or modify a (key, value) pair

justRight :: Show a => Either a b -> b Source #

Return only the Right vaule from an either

reparse :: (ToJSON a, FromJSON b) => a -> Either String b Source #

Convert ToJSON values to FromJSON values