{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE RecordWildCards #-}
module Discord.Internal.Types.Gateway where
import System.Info
import qualified Data.Text as T
import Data.Time (UTCTime)
import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds)
import Data.Aeson
import Data.Aeson.Types
import Data.Default (Default, def)
import Data.Maybe (fromMaybe)
import Data.Functor
import Text.Read (readMaybe)
import Discord.Internal.Types.Prelude
import Discord.Internal.Types.Events
import Discord.Internal.Types.Guild (Activity (..))
data GatewayReceivable
= Dispatch EventInternalParse Integer
| HeartbeatRequest Integer
| Reconnect
| InvalidSession Bool
| Hello Integer
| HeartbeatAck
| ParseError T.Text
deriving (Int -> GatewayReceivable -> ShowS
[GatewayReceivable] -> ShowS
GatewayReceivable -> String
(Int -> GatewayReceivable -> ShowS)
-> (GatewayReceivable -> String)
-> ([GatewayReceivable] -> ShowS)
-> Show GatewayReceivable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GatewayReceivable -> ShowS
showsPrec :: Int -> GatewayReceivable -> ShowS
$cshow :: GatewayReceivable -> String
show :: GatewayReceivable -> String
$cshowList :: [GatewayReceivable] -> ShowS
showList :: [GatewayReceivable] -> ShowS
Show, GatewayReceivable -> GatewayReceivable -> Bool
(GatewayReceivable -> GatewayReceivable -> Bool)
-> (GatewayReceivable -> GatewayReceivable -> Bool)
-> Eq GatewayReceivable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GatewayReceivable -> GatewayReceivable -> Bool
== :: GatewayReceivable -> GatewayReceivable -> Bool
$c/= :: GatewayReceivable -> GatewayReceivable -> Bool
/= :: GatewayReceivable -> GatewayReceivable -> Bool
Eq, ReadPrec [GatewayReceivable]
ReadPrec GatewayReceivable
Int -> ReadS GatewayReceivable
ReadS [GatewayReceivable]
(Int -> ReadS GatewayReceivable)
-> ReadS [GatewayReceivable]
-> ReadPrec GatewayReceivable
-> ReadPrec [GatewayReceivable]
-> Read GatewayReceivable
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS GatewayReceivable
readsPrec :: Int -> ReadS GatewayReceivable
$creadList :: ReadS [GatewayReceivable]
readList :: ReadS [GatewayReceivable]
$creadPrec :: ReadPrec GatewayReceivable
readPrec :: ReadPrec GatewayReceivable
$creadListPrec :: ReadPrec [GatewayReceivable]
readListPrec :: ReadPrec [GatewayReceivable]
Read)
data GatewaySendableInternal
= Heartbeat Integer
| Identify Auth GatewayIntent (Int, Int)
| Resume Auth T.Text Integer
deriving (Int -> GatewaySendableInternal -> ShowS
[GatewaySendableInternal] -> ShowS
GatewaySendableInternal -> String
(Int -> GatewaySendableInternal -> ShowS)
-> (GatewaySendableInternal -> String)
-> ([GatewaySendableInternal] -> ShowS)
-> Show GatewaySendableInternal
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GatewaySendableInternal -> ShowS
showsPrec :: Int -> GatewaySendableInternal -> ShowS
$cshow :: GatewaySendableInternal -> String
show :: GatewaySendableInternal -> String
$cshowList :: [GatewaySendableInternal] -> ShowS
showList :: [GatewaySendableInternal] -> ShowS
Show, ReadPrec [GatewaySendableInternal]
ReadPrec GatewaySendableInternal
Int -> ReadS GatewaySendableInternal
ReadS [GatewaySendableInternal]
(Int -> ReadS GatewaySendableInternal)
-> ReadS [GatewaySendableInternal]
-> ReadPrec GatewaySendableInternal
-> ReadPrec [GatewaySendableInternal]
-> Read GatewaySendableInternal
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS GatewaySendableInternal
readsPrec :: Int -> ReadS GatewaySendableInternal
$creadList :: ReadS [GatewaySendableInternal]
readList :: ReadS [GatewaySendableInternal]
$creadPrec :: ReadPrec GatewaySendableInternal
readPrec :: ReadPrec GatewaySendableInternal
$creadListPrec :: ReadPrec [GatewaySendableInternal]
readListPrec :: ReadPrec [GatewaySendableInternal]
Read, GatewaySendableInternal -> GatewaySendableInternal -> Bool
(GatewaySendableInternal -> GatewaySendableInternal -> Bool)
-> (GatewaySendableInternal -> GatewaySendableInternal -> Bool)
-> Eq GatewaySendableInternal
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
== :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
$c/= :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
/= :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
Eq, Eq GatewaySendableInternal
Eq GatewaySendableInternal =>
(GatewaySendableInternal -> GatewaySendableInternal -> Ordering)
-> (GatewaySendableInternal -> GatewaySendableInternal -> Bool)
-> (GatewaySendableInternal -> GatewaySendableInternal -> Bool)
-> (GatewaySendableInternal -> GatewaySendableInternal -> Bool)
-> (GatewaySendableInternal -> GatewaySendableInternal -> Bool)
-> (GatewaySendableInternal
-> GatewaySendableInternal -> GatewaySendableInternal)
-> (GatewaySendableInternal
-> GatewaySendableInternal -> GatewaySendableInternal)
-> Ord GatewaySendableInternal
GatewaySendableInternal -> GatewaySendableInternal -> Bool
GatewaySendableInternal -> GatewaySendableInternal -> Ordering
GatewaySendableInternal
-> GatewaySendableInternal -> GatewaySendableInternal
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: GatewaySendableInternal -> GatewaySendableInternal -> Ordering
compare :: GatewaySendableInternal -> GatewaySendableInternal -> Ordering
$c< :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
< :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
$c<= :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
<= :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
$c> :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
> :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
$c>= :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
>= :: GatewaySendableInternal -> GatewaySendableInternal -> Bool
$cmax :: GatewaySendableInternal
-> GatewaySendableInternal -> GatewaySendableInternal
max :: GatewaySendableInternal
-> GatewaySendableInternal -> GatewaySendableInternal
$cmin :: GatewaySendableInternal
-> GatewaySendableInternal -> GatewaySendableInternal
min :: GatewaySendableInternal
-> GatewaySendableInternal -> GatewaySendableInternal
Ord)
data GatewayIntent = GatewayIntent
{ GatewayIntent -> Bool
gatewayIntentGuilds :: Bool
, GatewayIntent -> Bool
gatewayIntentMembers :: Bool
, GatewayIntent -> Bool
gatewayIntentBans :: Bool
, GatewayIntent -> Bool
gatewayIntentEmojis :: Bool
, GatewayIntent -> Bool
gatewayIntentIntegrations :: Bool
, GatewayIntent -> Bool
gatewayIntentWebhooks :: Bool
, GatewayIntent -> Bool
gatewayIntentInvites :: Bool
, GatewayIntent -> Bool
gatewayIntentVoiceStates :: Bool
, GatewayIntent -> Bool
gatewayIntentPresences :: Bool
, GatewayIntent -> Bool
gatewayIntentMessageChanges :: Bool
, GatewayIntent -> Bool
gatewayIntentMessageReactions :: Bool
, GatewayIntent -> Bool
gatewayIntentMessageTyping :: Bool
, GatewayIntent -> Bool
gatewayIntentDirectMessageChanges :: Bool
, GatewayIntent -> Bool
gatewayIntentDirectMessageReactions :: Bool
, GatewayIntent -> Bool
gatewayIntentDirectMessageTyping :: Bool
, GatewayIntent -> Bool
gatewayIntentMessageContent :: Bool
} deriving (Int -> GatewayIntent -> ShowS
[GatewayIntent] -> ShowS
GatewayIntent -> String
(Int -> GatewayIntent -> ShowS)
-> (GatewayIntent -> String)
-> ([GatewayIntent] -> ShowS)
-> Show GatewayIntent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GatewayIntent -> ShowS
showsPrec :: Int -> GatewayIntent -> ShowS
$cshow :: GatewayIntent -> String
show :: GatewayIntent -> String
$cshowList :: [GatewayIntent] -> ShowS
showList :: [GatewayIntent] -> ShowS
Show, ReadPrec [GatewayIntent]
ReadPrec GatewayIntent
Int -> ReadS GatewayIntent
ReadS [GatewayIntent]
(Int -> ReadS GatewayIntent)
-> ReadS [GatewayIntent]
-> ReadPrec GatewayIntent
-> ReadPrec [GatewayIntent]
-> Read GatewayIntent
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS GatewayIntent
readsPrec :: Int -> ReadS GatewayIntent
$creadList :: ReadS [GatewayIntent]
readList :: ReadS [GatewayIntent]
$creadPrec :: ReadPrec GatewayIntent
readPrec :: ReadPrec GatewayIntent
$creadListPrec :: ReadPrec [GatewayIntent]
readListPrec :: ReadPrec [GatewayIntent]
Read, GatewayIntent -> GatewayIntent -> Bool
(GatewayIntent -> GatewayIntent -> Bool)
-> (GatewayIntent -> GatewayIntent -> Bool) -> Eq GatewayIntent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GatewayIntent -> GatewayIntent -> Bool
== :: GatewayIntent -> GatewayIntent -> Bool
$c/= :: GatewayIntent -> GatewayIntent -> Bool
/= :: GatewayIntent -> GatewayIntent -> Bool
Eq, Eq GatewayIntent
Eq GatewayIntent =>
(GatewayIntent -> GatewayIntent -> Ordering)
-> (GatewayIntent -> GatewayIntent -> Bool)
-> (GatewayIntent -> GatewayIntent -> Bool)
-> (GatewayIntent -> GatewayIntent -> Bool)
-> (GatewayIntent -> GatewayIntent -> Bool)
-> (GatewayIntent -> GatewayIntent -> GatewayIntent)
-> (GatewayIntent -> GatewayIntent -> GatewayIntent)
-> Ord GatewayIntent
GatewayIntent -> GatewayIntent -> Bool
GatewayIntent -> GatewayIntent -> Ordering
GatewayIntent -> GatewayIntent -> GatewayIntent
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: GatewayIntent -> GatewayIntent -> Ordering
compare :: GatewayIntent -> GatewayIntent -> Ordering
$c< :: GatewayIntent -> GatewayIntent -> Bool
< :: GatewayIntent -> GatewayIntent -> Bool
$c<= :: GatewayIntent -> GatewayIntent -> Bool
<= :: GatewayIntent -> GatewayIntent -> Bool
$c> :: GatewayIntent -> GatewayIntent -> Bool
> :: GatewayIntent -> GatewayIntent -> Bool
$c>= :: GatewayIntent -> GatewayIntent -> Bool
>= :: GatewayIntent -> GatewayIntent -> Bool
$cmax :: GatewayIntent -> GatewayIntent -> GatewayIntent
max :: GatewayIntent -> GatewayIntent -> GatewayIntent
$cmin :: GatewayIntent -> GatewayIntent -> GatewayIntent
min :: GatewayIntent -> GatewayIntent -> GatewayIntent
Ord)
instance Default GatewayIntent where
def :: GatewayIntent
def = GatewayIntent { gatewayIntentGuilds :: Bool
gatewayIntentGuilds = Bool
True
, gatewayIntentMembers :: Bool
gatewayIntentMembers = Bool
False
, gatewayIntentBans :: Bool
gatewayIntentBans = Bool
True
, gatewayIntentEmojis :: Bool
gatewayIntentEmojis = Bool
True
, gatewayIntentIntegrations :: Bool
gatewayIntentIntegrations = Bool
True
, gatewayIntentWebhooks :: Bool
gatewayIntentWebhooks = Bool
True
, gatewayIntentInvites :: Bool
gatewayIntentInvites = Bool
True
, gatewayIntentVoiceStates :: Bool
gatewayIntentVoiceStates = Bool
True
, gatewayIntentPresences :: Bool
gatewayIntentPresences = Bool
False
, gatewayIntentMessageChanges :: Bool
gatewayIntentMessageChanges = Bool
True
, gatewayIntentMessageReactions :: Bool
gatewayIntentMessageReactions = Bool
True
, gatewayIntentMessageTyping :: Bool
gatewayIntentMessageTyping = Bool
True
, gatewayIntentDirectMessageChanges :: Bool
gatewayIntentDirectMessageChanges = Bool
True
, gatewayIntentDirectMessageReactions :: Bool
gatewayIntentDirectMessageReactions = Bool
True
, gatewayIntentDirectMessageTyping :: Bool
gatewayIntentDirectMessageTyping = Bool
True
, gatewayIntentMessageContent :: Bool
gatewayIntentMessageContent = Bool
True
}
compileGatewayIntent :: GatewayIntent -> Int
compileGatewayIntent :: GatewayIntent -> Int
compileGatewayIntent GatewayIntent{Bool
gatewayIntentGuilds :: GatewayIntent -> Bool
gatewayIntentMembers :: GatewayIntent -> Bool
gatewayIntentBans :: GatewayIntent -> Bool
gatewayIntentEmojis :: GatewayIntent -> Bool
gatewayIntentIntegrations :: GatewayIntent -> Bool
gatewayIntentWebhooks :: GatewayIntent -> Bool
gatewayIntentInvites :: GatewayIntent -> Bool
gatewayIntentVoiceStates :: GatewayIntent -> Bool
gatewayIntentPresences :: GatewayIntent -> Bool
gatewayIntentMessageChanges :: GatewayIntent -> Bool
gatewayIntentMessageReactions :: GatewayIntent -> Bool
gatewayIntentMessageTyping :: GatewayIntent -> Bool
gatewayIntentDirectMessageChanges :: GatewayIntent -> Bool
gatewayIntentDirectMessageReactions :: GatewayIntent -> Bool
gatewayIntentDirectMessageTyping :: GatewayIntent -> Bool
gatewayIntentMessageContent :: GatewayIntent -> Bool
gatewayIntentGuilds :: Bool
gatewayIntentMembers :: Bool
gatewayIntentBans :: Bool
gatewayIntentEmojis :: Bool
gatewayIntentIntegrations :: Bool
gatewayIntentWebhooks :: Bool
gatewayIntentInvites :: Bool
gatewayIntentVoiceStates :: Bool
gatewayIntentPresences :: Bool
gatewayIntentMessageChanges :: Bool
gatewayIntentMessageReactions :: Bool
gatewayIntentMessageTyping :: Bool
gatewayIntentDirectMessageChanges :: Bool
gatewayIntentDirectMessageReactions :: Bool
gatewayIntentDirectMessageTyping :: Bool
gatewayIntentMessageContent :: Bool
..} =
[Int] -> Int
forall a. Num a => [a] -> a
forall (t :: * -> *) a. (Foldable t, Num a) => t a -> a
sum ([Int] -> Int) -> [Int] -> Int
forall a b. (a -> b) -> a -> b
$ [ if Bool
on then Int
flag else Int
0
| (Int
flag, Bool
on) <- [ ( Int
1, Bool
gatewayIntentGuilds)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
1, Bool
gatewayIntentMembers)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
2, Bool
gatewayIntentBans)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
3, Bool
gatewayIntentEmojis)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
4, Bool
gatewayIntentIntegrations)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
5, Bool
gatewayIntentWebhooks)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
6, Bool
gatewayIntentInvites)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
7, Bool
gatewayIntentVoiceStates)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
8, Bool
gatewayIntentPresences)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
9, Bool
gatewayIntentMessageChanges)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
10, Bool
gatewayIntentMessageReactions)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
11, Bool
gatewayIntentMessageTyping)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
12, Bool
gatewayIntentDirectMessageChanges)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
13, Bool
gatewayIntentDirectMessageReactions)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
14, Bool
gatewayIntentDirectMessageTyping)
, (Int
2 Int -> Integer -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Integer
15, Bool
gatewayIntentMessageContent)
]
]
data GatewaySendable
= RequestGuildMembers RequestGuildMembersOpts
| UpdateStatus UpdateStatusOpts
| UpdateStatusVoice UpdateStatusVoiceOpts
deriving (Int -> GatewaySendable -> ShowS
[GatewaySendable] -> ShowS
GatewaySendable -> String
(Int -> GatewaySendable -> ShowS)
-> (GatewaySendable -> String)
-> ([GatewaySendable] -> ShowS)
-> Show GatewaySendable
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GatewaySendable -> ShowS
showsPrec :: Int -> GatewaySendable -> ShowS
$cshow :: GatewaySendable -> String
show :: GatewaySendable -> String
$cshowList :: [GatewaySendable] -> ShowS
showList :: [GatewaySendable] -> ShowS
Show, ReadPrec [GatewaySendable]
ReadPrec GatewaySendable
Int -> ReadS GatewaySendable
ReadS [GatewaySendable]
(Int -> ReadS GatewaySendable)
-> ReadS [GatewaySendable]
-> ReadPrec GatewaySendable
-> ReadPrec [GatewaySendable]
-> Read GatewaySendable
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS GatewaySendable
readsPrec :: Int -> ReadS GatewaySendable
$creadList :: ReadS [GatewaySendable]
readList :: ReadS [GatewaySendable]
$creadPrec :: ReadPrec GatewaySendable
readPrec :: ReadPrec GatewaySendable
$creadListPrec :: ReadPrec [GatewaySendable]
readListPrec :: ReadPrec [GatewaySendable]
Read, GatewaySendable -> GatewaySendable -> Bool
(GatewaySendable -> GatewaySendable -> Bool)
-> (GatewaySendable -> GatewaySendable -> Bool)
-> Eq GatewaySendable
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GatewaySendable -> GatewaySendable -> Bool
== :: GatewaySendable -> GatewaySendable -> Bool
$c/= :: GatewaySendable -> GatewaySendable -> Bool
/= :: GatewaySendable -> GatewaySendable -> Bool
Eq, Eq GatewaySendable
Eq GatewaySendable =>
(GatewaySendable -> GatewaySendable -> Ordering)
-> (GatewaySendable -> GatewaySendable -> Bool)
-> (GatewaySendable -> GatewaySendable -> Bool)
-> (GatewaySendable -> GatewaySendable -> Bool)
-> (GatewaySendable -> GatewaySendable -> Bool)
-> (GatewaySendable -> GatewaySendable -> GatewaySendable)
-> (GatewaySendable -> GatewaySendable -> GatewaySendable)
-> Ord GatewaySendable
GatewaySendable -> GatewaySendable -> Bool
GatewaySendable -> GatewaySendable -> Ordering
GatewaySendable -> GatewaySendable -> GatewaySendable
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: GatewaySendable -> GatewaySendable -> Ordering
compare :: GatewaySendable -> GatewaySendable -> Ordering
$c< :: GatewaySendable -> GatewaySendable -> Bool
< :: GatewaySendable -> GatewaySendable -> Bool
$c<= :: GatewaySendable -> GatewaySendable -> Bool
<= :: GatewaySendable -> GatewaySendable -> Bool
$c> :: GatewaySendable -> GatewaySendable -> Bool
> :: GatewaySendable -> GatewaySendable -> Bool
$c>= :: GatewaySendable -> GatewaySendable -> Bool
>= :: GatewaySendable -> GatewaySendable -> Bool
$cmax :: GatewaySendable -> GatewaySendable -> GatewaySendable
max :: GatewaySendable -> GatewaySendable -> GatewaySendable
$cmin :: GatewaySendable -> GatewaySendable -> GatewaySendable
min :: GatewaySendable -> GatewaySendable -> GatewaySendable
Ord)
data RequestGuildMembersOpts = RequestGuildMembersOpts
{ RequestGuildMembersOpts -> GuildId
requestGuildMembersOptsGuildId :: GuildId
, RequestGuildMembersOpts -> Text
requestGuildMembersOptsNamesStartingWith :: T.Text
, RequestGuildMembersOpts -> Integer
requestGuildMembersOptsLimit :: Integer }
deriving (Int -> RequestGuildMembersOpts -> ShowS
[RequestGuildMembersOpts] -> ShowS
RequestGuildMembersOpts -> String
(Int -> RequestGuildMembersOpts -> ShowS)
-> (RequestGuildMembersOpts -> String)
-> ([RequestGuildMembersOpts] -> ShowS)
-> Show RequestGuildMembersOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RequestGuildMembersOpts -> ShowS
showsPrec :: Int -> RequestGuildMembersOpts -> ShowS
$cshow :: RequestGuildMembersOpts -> String
show :: RequestGuildMembersOpts -> String
$cshowList :: [RequestGuildMembersOpts] -> ShowS
showList :: [RequestGuildMembersOpts] -> ShowS
Show, ReadPrec [RequestGuildMembersOpts]
ReadPrec RequestGuildMembersOpts
Int -> ReadS RequestGuildMembersOpts
ReadS [RequestGuildMembersOpts]
(Int -> ReadS RequestGuildMembersOpts)
-> ReadS [RequestGuildMembersOpts]
-> ReadPrec RequestGuildMembersOpts
-> ReadPrec [RequestGuildMembersOpts]
-> Read RequestGuildMembersOpts
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS RequestGuildMembersOpts
readsPrec :: Int -> ReadS RequestGuildMembersOpts
$creadList :: ReadS [RequestGuildMembersOpts]
readList :: ReadS [RequestGuildMembersOpts]
$creadPrec :: ReadPrec RequestGuildMembersOpts
readPrec :: ReadPrec RequestGuildMembersOpts
$creadListPrec :: ReadPrec [RequestGuildMembersOpts]
readListPrec :: ReadPrec [RequestGuildMembersOpts]
Read, RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
(RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool)
-> (RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool)
-> Eq RequestGuildMembersOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
== :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
$c/= :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
/= :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
Eq, Eq RequestGuildMembersOpts
Eq RequestGuildMembersOpts =>
(RequestGuildMembersOpts -> RequestGuildMembersOpts -> Ordering)
-> (RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool)
-> (RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool)
-> (RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool)
-> (RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool)
-> (RequestGuildMembersOpts
-> RequestGuildMembersOpts -> RequestGuildMembersOpts)
-> (RequestGuildMembersOpts
-> RequestGuildMembersOpts -> RequestGuildMembersOpts)
-> Ord RequestGuildMembersOpts
RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
RequestGuildMembersOpts -> RequestGuildMembersOpts -> Ordering
RequestGuildMembersOpts
-> RequestGuildMembersOpts -> RequestGuildMembersOpts
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Ordering
compare :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Ordering
$c< :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
< :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
$c<= :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
<= :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
$c> :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
> :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
$c>= :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
>= :: RequestGuildMembersOpts -> RequestGuildMembersOpts -> Bool
$cmax :: RequestGuildMembersOpts
-> RequestGuildMembersOpts -> RequestGuildMembersOpts
max :: RequestGuildMembersOpts
-> RequestGuildMembersOpts -> RequestGuildMembersOpts
$cmin :: RequestGuildMembersOpts
-> RequestGuildMembersOpts -> RequestGuildMembersOpts
min :: RequestGuildMembersOpts
-> RequestGuildMembersOpts -> RequestGuildMembersOpts
Ord)
data UpdateStatusVoiceOpts = UpdateStatusVoiceOpts
{ UpdateStatusVoiceOpts -> GuildId
updateStatusVoiceOptsGuildId :: GuildId
, UpdateStatusVoiceOpts -> Maybe ChannelId
updateStatusVoiceOptsChannelId :: Maybe ChannelId
, UpdateStatusVoiceOpts -> Bool
updateStatusVoiceOptsIsMuted :: Bool
, UpdateStatusVoiceOpts -> Bool
updateStatusVoiceOptsIsDeaf :: Bool
}
deriving (Int -> UpdateStatusVoiceOpts -> ShowS
[UpdateStatusVoiceOpts] -> ShowS
UpdateStatusVoiceOpts -> String
(Int -> UpdateStatusVoiceOpts -> ShowS)
-> (UpdateStatusVoiceOpts -> String)
-> ([UpdateStatusVoiceOpts] -> ShowS)
-> Show UpdateStatusVoiceOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UpdateStatusVoiceOpts -> ShowS
showsPrec :: Int -> UpdateStatusVoiceOpts -> ShowS
$cshow :: UpdateStatusVoiceOpts -> String
show :: UpdateStatusVoiceOpts -> String
$cshowList :: [UpdateStatusVoiceOpts] -> ShowS
showList :: [UpdateStatusVoiceOpts] -> ShowS
Show, ReadPrec [UpdateStatusVoiceOpts]
ReadPrec UpdateStatusVoiceOpts
Int -> ReadS UpdateStatusVoiceOpts
ReadS [UpdateStatusVoiceOpts]
(Int -> ReadS UpdateStatusVoiceOpts)
-> ReadS [UpdateStatusVoiceOpts]
-> ReadPrec UpdateStatusVoiceOpts
-> ReadPrec [UpdateStatusVoiceOpts]
-> Read UpdateStatusVoiceOpts
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS UpdateStatusVoiceOpts
readsPrec :: Int -> ReadS UpdateStatusVoiceOpts
$creadList :: ReadS [UpdateStatusVoiceOpts]
readList :: ReadS [UpdateStatusVoiceOpts]
$creadPrec :: ReadPrec UpdateStatusVoiceOpts
readPrec :: ReadPrec UpdateStatusVoiceOpts
$creadListPrec :: ReadPrec [UpdateStatusVoiceOpts]
readListPrec :: ReadPrec [UpdateStatusVoiceOpts]
Read, UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
(UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool)
-> (UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool)
-> Eq UpdateStatusVoiceOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
== :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
$c/= :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
/= :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
Eq, Eq UpdateStatusVoiceOpts
Eq UpdateStatusVoiceOpts =>
(UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Ordering)
-> (UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool)
-> (UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool)
-> (UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool)
-> (UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool)
-> (UpdateStatusVoiceOpts
-> UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts)
-> (UpdateStatusVoiceOpts
-> UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts)
-> Ord UpdateStatusVoiceOpts
UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Ordering
UpdateStatusVoiceOpts
-> UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Ordering
compare :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Ordering
$c< :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
< :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
$c<= :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
<= :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
$c> :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
> :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
$c>= :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
>= :: UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts -> Bool
$cmax :: UpdateStatusVoiceOpts
-> UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts
max :: UpdateStatusVoiceOpts
-> UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts
$cmin :: UpdateStatusVoiceOpts
-> UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts
min :: UpdateStatusVoiceOpts
-> UpdateStatusVoiceOpts -> UpdateStatusVoiceOpts
Ord)
data UpdateStatusOpts = UpdateStatusOpts
{ UpdateStatusOpts -> Maybe UTCTime
updateStatusOptsSince :: Maybe UTCTime
, UpdateStatusOpts -> [Activity]
updateStatusOptsActivities :: [Activity]
, UpdateStatusOpts -> UpdateStatusType
updateStatusOptsNewStatus :: UpdateStatusType
, UpdateStatusOpts -> Bool
updateStatusOptsAFK :: Bool
}
deriving (Int -> UpdateStatusOpts -> ShowS
[UpdateStatusOpts] -> ShowS
UpdateStatusOpts -> String
(Int -> UpdateStatusOpts -> ShowS)
-> (UpdateStatusOpts -> String)
-> ([UpdateStatusOpts] -> ShowS)
-> Show UpdateStatusOpts
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UpdateStatusOpts -> ShowS
showsPrec :: Int -> UpdateStatusOpts -> ShowS
$cshow :: UpdateStatusOpts -> String
show :: UpdateStatusOpts -> String
$cshowList :: [UpdateStatusOpts] -> ShowS
showList :: [UpdateStatusOpts] -> ShowS
Show, ReadPrec [UpdateStatusOpts]
ReadPrec UpdateStatusOpts
Int -> ReadS UpdateStatusOpts
ReadS [UpdateStatusOpts]
(Int -> ReadS UpdateStatusOpts)
-> ReadS [UpdateStatusOpts]
-> ReadPrec UpdateStatusOpts
-> ReadPrec [UpdateStatusOpts]
-> Read UpdateStatusOpts
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS UpdateStatusOpts
readsPrec :: Int -> ReadS UpdateStatusOpts
$creadList :: ReadS [UpdateStatusOpts]
readList :: ReadS [UpdateStatusOpts]
$creadPrec :: ReadPrec UpdateStatusOpts
readPrec :: ReadPrec UpdateStatusOpts
$creadListPrec :: ReadPrec [UpdateStatusOpts]
readListPrec :: ReadPrec [UpdateStatusOpts]
Read, UpdateStatusOpts -> UpdateStatusOpts -> Bool
(UpdateStatusOpts -> UpdateStatusOpts -> Bool)
-> (UpdateStatusOpts -> UpdateStatusOpts -> Bool)
-> Eq UpdateStatusOpts
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
== :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
$c/= :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
/= :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
Eq, Eq UpdateStatusOpts
Eq UpdateStatusOpts =>
(UpdateStatusOpts -> UpdateStatusOpts -> Ordering)
-> (UpdateStatusOpts -> UpdateStatusOpts -> Bool)
-> (UpdateStatusOpts -> UpdateStatusOpts -> Bool)
-> (UpdateStatusOpts -> UpdateStatusOpts -> Bool)
-> (UpdateStatusOpts -> UpdateStatusOpts -> Bool)
-> (UpdateStatusOpts -> UpdateStatusOpts -> UpdateStatusOpts)
-> (UpdateStatusOpts -> UpdateStatusOpts -> UpdateStatusOpts)
-> Ord UpdateStatusOpts
UpdateStatusOpts -> UpdateStatusOpts -> Bool
UpdateStatusOpts -> UpdateStatusOpts -> Ordering
UpdateStatusOpts -> UpdateStatusOpts -> UpdateStatusOpts
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: UpdateStatusOpts -> UpdateStatusOpts -> Ordering
compare :: UpdateStatusOpts -> UpdateStatusOpts -> Ordering
$c< :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
< :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
$c<= :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
<= :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
$c> :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
> :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
$c>= :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
>= :: UpdateStatusOpts -> UpdateStatusOpts -> Bool
$cmax :: UpdateStatusOpts -> UpdateStatusOpts -> UpdateStatusOpts
max :: UpdateStatusOpts -> UpdateStatusOpts -> UpdateStatusOpts
$cmin :: UpdateStatusOpts -> UpdateStatusOpts -> UpdateStatusOpts
min :: UpdateStatusOpts -> UpdateStatusOpts -> UpdateStatusOpts
Ord)
data UpdateStatusType = UpdateStatusOnline
| UpdateStatusDoNotDisturb
| UpdateStatusAwayFromKeyboard
| UpdateStatusInvisibleOffline
| UpdateStatusOffline
deriving (Int -> UpdateStatusType -> ShowS
[UpdateStatusType] -> ShowS
UpdateStatusType -> String
(Int -> UpdateStatusType -> ShowS)
-> (UpdateStatusType -> String)
-> ([UpdateStatusType] -> ShowS)
-> Show UpdateStatusType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UpdateStatusType -> ShowS
showsPrec :: Int -> UpdateStatusType -> ShowS
$cshow :: UpdateStatusType -> String
show :: UpdateStatusType -> String
$cshowList :: [UpdateStatusType] -> ShowS
showList :: [UpdateStatusType] -> ShowS
Show, ReadPrec [UpdateStatusType]
ReadPrec UpdateStatusType
Int -> ReadS UpdateStatusType
ReadS [UpdateStatusType]
(Int -> ReadS UpdateStatusType)
-> ReadS [UpdateStatusType]
-> ReadPrec UpdateStatusType
-> ReadPrec [UpdateStatusType]
-> Read UpdateStatusType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS UpdateStatusType
readsPrec :: Int -> ReadS UpdateStatusType
$creadList :: ReadS [UpdateStatusType]
readList :: ReadS [UpdateStatusType]
$creadPrec :: ReadPrec UpdateStatusType
readPrec :: ReadPrec UpdateStatusType
$creadListPrec :: ReadPrec [UpdateStatusType]
readListPrec :: ReadPrec [UpdateStatusType]
Read, UpdateStatusType -> UpdateStatusType -> Bool
(UpdateStatusType -> UpdateStatusType -> Bool)
-> (UpdateStatusType -> UpdateStatusType -> Bool)
-> Eq UpdateStatusType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UpdateStatusType -> UpdateStatusType -> Bool
== :: UpdateStatusType -> UpdateStatusType -> Bool
$c/= :: UpdateStatusType -> UpdateStatusType -> Bool
/= :: UpdateStatusType -> UpdateStatusType -> Bool
Eq, Eq UpdateStatusType
Eq UpdateStatusType =>
(UpdateStatusType -> UpdateStatusType -> Ordering)
-> (UpdateStatusType -> UpdateStatusType -> Bool)
-> (UpdateStatusType -> UpdateStatusType -> Bool)
-> (UpdateStatusType -> UpdateStatusType -> Bool)
-> (UpdateStatusType -> UpdateStatusType -> Bool)
-> (UpdateStatusType -> UpdateStatusType -> UpdateStatusType)
-> (UpdateStatusType -> UpdateStatusType -> UpdateStatusType)
-> Ord UpdateStatusType
UpdateStatusType -> UpdateStatusType -> Bool
UpdateStatusType -> UpdateStatusType -> Ordering
UpdateStatusType -> UpdateStatusType -> UpdateStatusType
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: UpdateStatusType -> UpdateStatusType -> Ordering
compare :: UpdateStatusType -> UpdateStatusType -> Ordering
$c< :: UpdateStatusType -> UpdateStatusType -> Bool
< :: UpdateStatusType -> UpdateStatusType -> Bool
$c<= :: UpdateStatusType -> UpdateStatusType -> Bool
<= :: UpdateStatusType -> UpdateStatusType -> Bool
$c> :: UpdateStatusType -> UpdateStatusType -> Bool
> :: UpdateStatusType -> UpdateStatusType -> Bool
$c>= :: UpdateStatusType -> UpdateStatusType -> Bool
>= :: UpdateStatusType -> UpdateStatusType -> Bool
$cmax :: UpdateStatusType -> UpdateStatusType -> UpdateStatusType
max :: UpdateStatusType -> UpdateStatusType -> UpdateStatusType
$cmin :: UpdateStatusType -> UpdateStatusType -> UpdateStatusType
min :: UpdateStatusType -> UpdateStatusType -> UpdateStatusType
Ord, Int -> UpdateStatusType
UpdateStatusType -> Int
UpdateStatusType -> [UpdateStatusType]
UpdateStatusType -> UpdateStatusType
UpdateStatusType -> UpdateStatusType -> [UpdateStatusType]
UpdateStatusType
-> UpdateStatusType -> UpdateStatusType -> [UpdateStatusType]
(UpdateStatusType -> UpdateStatusType)
-> (UpdateStatusType -> UpdateStatusType)
-> (Int -> UpdateStatusType)
-> (UpdateStatusType -> Int)
-> (UpdateStatusType -> [UpdateStatusType])
-> (UpdateStatusType -> UpdateStatusType -> [UpdateStatusType])
-> (UpdateStatusType -> UpdateStatusType -> [UpdateStatusType])
-> (UpdateStatusType
-> UpdateStatusType -> UpdateStatusType -> [UpdateStatusType])
-> Enum UpdateStatusType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: UpdateStatusType -> UpdateStatusType
succ :: UpdateStatusType -> UpdateStatusType
$cpred :: UpdateStatusType -> UpdateStatusType
pred :: UpdateStatusType -> UpdateStatusType
$ctoEnum :: Int -> UpdateStatusType
toEnum :: Int -> UpdateStatusType
$cfromEnum :: UpdateStatusType -> Int
fromEnum :: UpdateStatusType -> Int
$cenumFrom :: UpdateStatusType -> [UpdateStatusType]
enumFrom :: UpdateStatusType -> [UpdateStatusType]
$cenumFromThen :: UpdateStatusType -> UpdateStatusType -> [UpdateStatusType]
enumFromThen :: UpdateStatusType -> UpdateStatusType -> [UpdateStatusType]
$cenumFromTo :: UpdateStatusType -> UpdateStatusType -> [UpdateStatusType]
enumFromTo :: UpdateStatusType -> UpdateStatusType -> [UpdateStatusType]
$cenumFromThenTo :: UpdateStatusType
-> UpdateStatusType -> UpdateStatusType -> [UpdateStatusType]
enumFromThenTo :: UpdateStatusType
-> UpdateStatusType -> UpdateStatusType -> [UpdateStatusType]
Enum)
statusString :: UpdateStatusType -> T.Text
statusString :: UpdateStatusType -> Text
statusString UpdateStatusType
s = case UpdateStatusType
s of
UpdateStatusType
UpdateStatusOnline -> Text
"online"
UpdateStatusType
UpdateStatusDoNotDisturb -> Text
"dnd"
UpdateStatusType
UpdateStatusAwayFromKeyboard -> Text
"idle"
UpdateStatusType
UpdateStatusInvisibleOffline -> Text
"invisible"
UpdateStatusType
UpdateStatusOffline -> Text
"offline"
instance FromJSON GatewayReceivable where
parseJSON :: Value -> Parser GatewayReceivable
parseJSON = String
-> (Object -> Parser GatewayReceivable)
-> Value
-> Parser GatewayReceivable
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"payload" ((Object -> Parser GatewayReceivable)
-> Value -> Parser GatewayReceivable)
-> (Object -> Parser GatewayReceivable)
-> Value
-> Parser GatewayReceivable
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Int
op <- Object
o Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"op" :: Parser Int
case Int
op of
Int
0 -> do Text
etype <- Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"t"
Value
ejson <- Object
o Object -> Key -> Parser Value
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"d"
case Value
ejson of
Object Object
hm -> EventInternalParse -> Integer -> GatewayReceivable
Dispatch (EventInternalParse -> Integer -> GatewayReceivable)
-> Parser EventInternalParse
-> Parser (Integer -> GatewayReceivable)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Text -> Object -> Parser EventInternalParse
eventParse Text
etype Object
hm Parser (Integer -> GatewayReceivable)
-> Parser Integer -> Parser GatewayReceivable
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Integer
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"s"
Value
_other -> EventInternalParse -> Integer -> GatewayReceivable
Dispatch (Text -> Object -> EventInternalParse
InternalUnknownEvent Text
"Dispatch payload wasn't an object" Object
o)
(Integer -> GatewayReceivable)
-> Parser Integer -> Parser GatewayReceivable
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser Integer
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"s"
Int
1 -> Integer -> GatewayReceivable
HeartbeatRequest (Integer -> GatewayReceivable)
-> (String -> Integer) -> String -> GatewayReceivable
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Maybe Integer -> Integer
forall a. a -> Maybe a -> a
fromMaybe Integer
0 (Maybe Integer -> Integer)
-> (String -> Maybe Integer) -> String -> Integer
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Maybe Integer
forall a. Read a => String -> Maybe a
readMaybe (String -> GatewayReceivable)
-> Parser String -> Parser GatewayReceivable
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"d"
Int
7 -> GatewayReceivable -> Parser GatewayReceivable
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure GatewayReceivable
Reconnect
Int
9 -> Bool -> GatewayReceivable
InvalidSession (Bool -> GatewayReceivable)
-> Parser Bool -> Parser GatewayReceivable
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser Bool
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"d"
Int
10 -> do Object
od <- Object
o Object -> Key -> Parser Object
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"d"
Integer
int <- Object
od Object -> Key -> Parser Integer
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"heartbeat_interval"
GatewayReceivable -> Parser GatewayReceivable
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Integer -> GatewayReceivable
Hello Integer
int)
Int
11 -> GatewayReceivable -> Parser GatewayReceivable
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure GatewayReceivable
HeartbeatAck
Int
_ -> String -> Parser GatewayReceivable
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String
"Unknown Receivable payload ID:" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
op)
instance ToJSON GatewaySendableInternal where
toJSON :: GatewaySendableInternal -> Value
toJSON (Heartbeat Integer
i) = [Pair] -> Value
object [ Key
"op" Key -> Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Int
1 :: Int), Key
"d" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= if Integer
i Integer -> Integer -> Bool
forall a. Ord a => a -> a -> Bool
<= Integer
0 then String
"null" else Integer -> String
forall a. Show a => a -> String
show Integer
i ]
toJSON (Identify Auth
token GatewayIntent
intent (Int, Int)
shard) = [Pair] -> Value
object [
Key
"op" Key -> Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Int
2 :: Int)
, Key
"d" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [
Key
"token" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Auth -> Text
authToken Auth
token
, Key
"intents" Key -> Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= GatewayIntent -> Int
compileGatewayIntent GatewayIntent
intent
, Key
"properties" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [
Key
"$os" Key -> String -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= String
os
, Key
"$browser" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
"discord-haskell" :: T.Text)
, Key
"$device" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
"discord-haskell" :: T.Text)
, Key
"$referrer" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
"" :: T.Text)
, Key
"$referring_domain" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
"" :: T.Text)
]
, Key
"compress" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
False
, Key
"large_threshold" Key -> Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Int
50 :: Int)
, Key
"shard" Key -> (Int, Int) -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Int, Int)
shard
]
]
toJSON (Resume Auth
token Text
session Integer
seqId) = [Pair] -> Value
object [
Key
"op" Key -> Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Int
6 :: Int)
, Key
"d" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [
Key
"token" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Auth -> Text
authToken Auth
token
, Key
"session_id" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
session
, Key
"seq" Key -> Integer -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Integer
seqId
]
]
instance ToJSON GatewaySendable where
toJSON :: GatewaySendable -> Value
toJSON (UpdateStatus (UpdateStatusOpts Maybe UTCTime
since [Activity]
activities UpdateStatusType
status Bool
afk)) = [Pair] -> Value
object [
Key
"op" Key -> Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Int
3 :: Int)
, Key
"d" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [
Key
"since" Key -> Maybe POSIXTime -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Maybe UTCTime
since Maybe UTCTime -> (UTCTime -> POSIXTime) -> Maybe POSIXTime
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
<&> \UTCTime
s -> POSIXTime
1000 POSIXTime -> POSIXTime -> POSIXTime
forall a. Num a => a -> a -> a
* UTCTime -> POSIXTime
utcTimeToPOSIXSeconds UTCTime
s)
, Key
"afk" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
afk
, Key
"status" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= UpdateStatusType -> Text
statusString UpdateStatusType
status
, Key
"activities" Key -> [Activity] -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Activity]
activities
]
]
toJSON (UpdateStatusVoice (UpdateStatusVoiceOpts GuildId
guild Maybe ChannelId
channel Bool
mute Bool
deaf)) =
[Pair] -> Value
object [
Key
"op" Key -> Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Int
4 :: Int)
, Key
"d" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [
Key
"guild_id" Key -> GuildId -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= GuildId
guild
, Key
"channel_id" Key -> Maybe ChannelId -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Maybe ChannelId
channel
, Key
"self_mute" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
mute
, Key
"self_deaf" Key -> Bool -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Bool
deaf
]
]
toJSON (RequestGuildMembers (RequestGuildMembersOpts GuildId
guild Text
query Integer
limit)) =
[Pair] -> Value
object [
Key
"op" Key -> Int -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Int
8 :: Int)
, Key
"d" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object [
Key
"guild_id" Key -> GuildId -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= GuildId
guild
, Key
"query" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
query
, Key
"limit" Key -> Integer -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Integer
limit
]
]