module Calamity.Gateway.Types
( ShardC
, ShardMsg(..)
, ReceivedDiscordMessage(..)
, SentDiscordMessage(..)
, DispatchType(..)
, IdentifyData(..)
, StatusUpdateData(..)
, ResumeData(..)
, RequestGuildMembersData(..)
, IdentifyProps(..)
, ControlMessage(..)
, ShardFlowControl(..)
, Shard(..)
, ShardState(..) ) where
import Calamity.Gateway.DispatchEvents
import Calamity.Gateway.Intents
import Calamity.Internal.AesonThings
import Calamity.Metrics.Eff
import Calamity.Types.LogEff
import Calamity.Types.Model.Guild.Guild
import Calamity.Types.Model.Voice
import Calamity.Types.Model.Presence.Activity
import Calamity.Types.Model.User (StatusType)
import Calamity.Types.Snowflake
import Control.Concurrent.Async
import Control.Concurrent.Chan.Unagi
import Data.Aeson
import qualified Data.Aeson.Types as AT
import Data.Generics.Labels ()
import Data.Maybe
import Data.Text ( Text )
import GHC.Generics
import Network.WebSockets.Connection ( Connection )
import qualified Polysemy as P
import qualified Polysemy.Async as P
import qualified Polysemy.AtomicState as P
import qualified TextShow.Generic as TSG
import TextShow (TextShow)
import Control.Lens.Operators ((^?))
import Data.Aeson.Types (parseMaybe)
import Control.Lens (Ixed(ix))
import Data.Aeson.Lens
type ShardC r = (P.Members '[LogEff, P.AtomicState ShardState, P.Embed IO, P.Final IO,
P.Async, MetricEff] r)
data ShardMsg
= Discord ReceivedDiscordMessage
| Control ControlMessage
deriving ( Int -> ShardMsg -> ShowS
[ShardMsg] -> ShowS
ShardMsg -> String
(Int -> ShardMsg -> ShowS)
-> (ShardMsg -> String) -> ([ShardMsg] -> ShowS) -> Show ShardMsg
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShardMsg] -> ShowS
$cshowList :: [ShardMsg] -> ShowS
show :: ShardMsg -> String
$cshow :: ShardMsg -> String
showsPrec :: Int -> ShardMsg -> ShowS
$cshowsPrec :: Int -> ShardMsg -> ShowS
Show, (forall x. ShardMsg -> Rep ShardMsg x)
-> (forall x. Rep ShardMsg x -> ShardMsg) -> Generic ShardMsg
forall x. Rep ShardMsg x -> ShardMsg
forall x. ShardMsg -> Rep ShardMsg x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ShardMsg x -> ShardMsg
$cfrom :: forall x. ShardMsg -> Rep ShardMsg x
Generic )
data ReceivedDiscordMessage
= EvtDispatch Int !DispatchData
| HeartBeatReq
| Reconnect
| InvalidSession Bool
| Hello Int
| HeartBeatAck
deriving ( Int -> ReceivedDiscordMessage -> ShowS
[ReceivedDiscordMessage] -> ShowS
ReceivedDiscordMessage -> String
(Int -> ReceivedDiscordMessage -> ShowS)
-> (ReceivedDiscordMessage -> String)
-> ([ReceivedDiscordMessage] -> ShowS)
-> Show ReceivedDiscordMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReceivedDiscordMessage] -> ShowS
$cshowList :: [ReceivedDiscordMessage] -> ShowS
show :: ReceivedDiscordMessage -> String
$cshow :: ReceivedDiscordMessage -> String
showsPrec :: Int -> ReceivedDiscordMessage -> ShowS
$cshowsPrec :: Int -> ReceivedDiscordMessage -> ShowS
Show, (forall x. ReceivedDiscordMessage -> Rep ReceivedDiscordMessage x)
-> (forall x.
Rep ReceivedDiscordMessage x -> ReceivedDiscordMessage)
-> Generic ReceivedDiscordMessage
forall x. Rep ReceivedDiscordMessage x -> ReceivedDiscordMessage
forall x. ReceivedDiscordMessage -> Rep ReceivedDiscordMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReceivedDiscordMessage x -> ReceivedDiscordMessage
$cfrom :: forall x. ReceivedDiscordMessage -> Rep ReceivedDiscordMessage x
Generic )
instance FromJSON ReceivedDiscordMessage where
parseJSON :: Value -> Parser ReceivedDiscordMessage
parseJSON = String
-> (Object -> Parser ReceivedDiscordMessage)
-> Value
-> Parser ReceivedDiscordMessage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ReceivedDiscordMessage" ((Object -> Parser ReceivedDiscordMessage)
-> Value -> Parser ReceivedDiscordMessage)
-> (Object -> Parser ReceivedDiscordMessage)
-> Value
-> Parser ReceivedDiscordMessage
forall a b. (a -> b) -> a -> b
$ \Object
v -> do
Int
op :: Int <- Object
v Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"op"
case Int
op of
Int
0 -> do
Value
d <- Object
v Object -> Key -> Parser Value
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"d"
DispatchType
t <- Object
v Object -> Key -> Parser DispatchType
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"t"
Int
s <- Object
v Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"s"
Int -> DispatchData -> ReceivedDiscordMessage
EvtDispatch Int
s (DispatchData -> ReceivedDiscordMessage)
-> Parser DispatchData -> Parser ReceivedDiscordMessage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> DispatchType -> Value -> Parser DispatchData
parseDispatchData DispatchType
t Value
d
Int
1 -> ReceivedDiscordMessage -> Parser ReceivedDiscordMessage
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReceivedDiscordMessage
HeartBeatReq
Int
7 -> ReceivedDiscordMessage -> Parser ReceivedDiscordMessage
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReceivedDiscordMessage
Reconnect
Int
9 -> Bool -> ReceivedDiscordMessage
InvalidSession (Bool -> ReceivedDiscordMessage)
-> Parser Bool -> Parser ReceivedDiscordMessage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser Bool
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"d"
Int
10 -> Int -> ReceivedDiscordMessage
Hello (Int -> ReceivedDiscordMessage)
-> Parser Int -> Parser ReceivedDiscordMessage
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> do
Object
d <- Object
v Object -> Key -> Parser Object
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"d"
Object
d Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"heartbeat_interval"
Int
11 -> ReceivedDiscordMessage -> Parser ReceivedDiscordMessage
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReceivedDiscordMessage
HeartBeatAck
Int
_ -> String -> Parser ReceivedDiscordMessage
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ReceivedDiscordMessage)
-> String -> Parser ReceivedDiscordMessage
forall a b. (a -> b) -> a -> b
$ String
"invalid opcode: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
op
parseDispatchData :: DispatchType -> Value -> AT.Parser DispatchData
parseDispatchData :: DispatchType -> Value -> Parser DispatchData
parseDispatchData DispatchType
READY Value
data' = ReadyData -> DispatchData
Ready (ReadyData -> DispatchData)
-> Parser ReadyData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser ReadyData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
RESUMED Value
_ = DispatchData -> Parser DispatchData
forall (f :: * -> *) a. Applicative f => a -> f a
pure DispatchData
Resumed
parseDispatchData DispatchType
CHANNEL_CREATE Value
data' = Channel -> DispatchData
ChannelCreate (Channel -> DispatchData) -> Parser Channel -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Channel
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
CHANNEL_UPDATE Value
data' = Channel -> DispatchData
ChannelUpdate (Channel -> DispatchData) -> Parser Channel -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Channel
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
CHANNEL_DELETE Value
data' = Channel -> DispatchData
ChannelDelete (Channel -> DispatchData) -> Parser Channel -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Channel
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
CHANNEL_PINS_UPDATE Value
data' = ChannelPinsUpdateData -> DispatchData
ChannelPinsUpdate (ChannelPinsUpdateData -> DispatchData)
-> Parser ChannelPinsUpdateData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser ChannelPinsUpdateData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_CREATE Value
data' = Guild -> DispatchData
GuildCreate (Guild -> DispatchData) -> Parser Guild -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Guild
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_UPDATE Value
data' = UpdatedGuild -> DispatchData
GuildUpdate (UpdatedGuild -> DispatchData)
-> Parser UpdatedGuild -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser UpdatedGuild
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_DELETE Value
data' = UnavailableGuild -> DispatchData
GuildDelete (UnavailableGuild -> DispatchData)
-> Parser UnavailableGuild -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser UnavailableGuild
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_BAN_ADD Value
data' = BanData -> DispatchData
GuildBanAdd (BanData -> DispatchData) -> Parser BanData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser BanData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_BAN_REMOVE Value
data' = BanData -> DispatchData
GuildBanRemove (BanData -> DispatchData) -> Parser BanData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser BanData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_EMOJIS_UPDATE Value
data' = GuildEmojisUpdateData -> DispatchData
GuildEmojisUpdate (GuildEmojisUpdateData -> DispatchData)
-> Parser GuildEmojisUpdateData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser GuildEmojisUpdateData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_INTEGRATIONS_UPDATE Value
data' = GuildIntegrationsUpdateData -> DispatchData
GuildIntegrationsUpdate (GuildIntegrationsUpdateData -> DispatchData)
-> Parser GuildIntegrationsUpdateData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser GuildIntegrationsUpdateData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_MEMBER_ADD Value
data' = do
Snowflake Guild
guildID <- String
-> (Object -> Parser (Snowflake Guild))
-> Value
-> Parser (Snowflake Guild)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"GuildMemberAdd.guild_id" (Object -> Key -> Parser (Snowflake Guild)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id") Value
data'
Snowflake Guild -> Member -> DispatchData
GuildMemberAdd Snowflake Guild
guildID (Member -> DispatchData) -> Parser Member -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Member
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_MEMBER_REMOVE Value
data' = GuildMemberRemoveData -> DispatchData
GuildMemberRemove (GuildMemberRemoveData -> DispatchData)
-> Parser GuildMemberRemoveData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser GuildMemberRemoveData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_MEMBER_UPDATE Value
data' = GuildMemberUpdateData -> DispatchData
GuildMemberUpdate (GuildMemberUpdateData -> DispatchData)
-> Parser GuildMemberUpdateData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser GuildMemberUpdateData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_MEMBERS_CHUNK Value
data' = GuildMembersChunkData -> DispatchData
GuildMembersChunk (GuildMembersChunkData -> DispatchData)
-> Parser GuildMembersChunkData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser GuildMembersChunkData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_ROLE_CREATE Value
data' = GuildRoleData -> DispatchData
GuildRoleCreate (GuildRoleData -> DispatchData)
-> Parser GuildRoleData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser GuildRoleData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_ROLE_UPDATE Value
data' = GuildRoleData -> DispatchData
GuildRoleUpdate (GuildRoleData -> DispatchData)
-> Parser GuildRoleData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser GuildRoleData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
GUILD_ROLE_DELETE Value
data' = GuildRoleDeleteData -> DispatchData
GuildRoleDelete (GuildRoleDeleteData -> DispatchData)
-> Parser GuildRoleDeleteData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser GuildRoleDeleteData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
INVITE_CREATE Value
data' = InviteCreateData -> DispatchData
InviteCreate (InviteCreateData -> DispatchData)
-> Parser InviteCreateData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser InviteCreateData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
INVITE_DELETE Value
data' = InviteDeleteData -> DispatchData
InviteDelete (InviteDeleteData -> DispatchData)
-> Parser InviteDeleteData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser InviteDeleteData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
MESSAGE_CREATE Value
data' = do
Message
message <- Value -> Parser Message
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
let member :: Maybe Member
member = (Value -> Parser Member) -> Value -> Maybe Member
forall a b. (a -> Parser b) -> a -> Maybe b
parseMaybe (String -> (Object -> Parser Member) -> Value -> Parser Member
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"MessageCreate.member" ((Object -> Parser Member) -> Value -> Parser Member)
-> (Object -> Parser Member) -> Value -> Parser Member
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Object
userObject :: Object <- Object
o Object -> Key -> Parser Object
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"author"
Object
memberObject :: Object <- Object
o Object -> Key -> Parser Object
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"member"
Value -> Parser Member
forall a. FromJSON a => Value -> Parser a
parseJSON (Value -> Parser Member) -> Value -> Parser Member
forall a b. (a -> b) -> a -> b
$ Object -> Value
Object (Object
memberObject Object -> Object -> Object
forall a. Semigroup a => a -> a -> a
<> Key
"user" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Object
userObject)) Value
data'
let user :: Maybe User
user = (Value -> Parser User) -> Value -> Maybe User
forall a b. (a -> Parser b) -> a -> Maybe b
parseMaybe Value -> Parser User
forall a. FromJSON a => Value -> Parser a
parseJSON (Value -> Maybe User) -> Maybe Value -> Maybe User
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Value
data' Value -> Getting (First Value) Value Value -> Maybe Value
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Object -> Const (First Value) Object)
-> Value -> Const (First Value) Value
forall t. AsValue t => Prism' t Object
_Object ((Object -> Const (First Value) Object)
-> Value -> Const (First Value) Value)
-> ((Value -> Const (First Value) Value)
-> Object -> Const (First Value) Object)
-> Getting (First Value) Value Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index Object -> Traversal' Object (IxValue Object)
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index Object
"author"
DispatchData -> Parser DispatchData
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DispatchData -> Parser DispatchData)
-> DispatchData -> Parser DispatchData
forall a b. (a -> b) -> a -> b
$ Message -> Maybe User -> Maybe Member -> DispatchData
MessageCreate Message
message Maybe User
user Maybe Member
member
parseDispatchData DispatchType
MESSAGE_UPDATE Value
data' = do
UpdatedMessage
message <- Value -> Parser UpdatedMessage
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
let member :: Maybe Member
member = (Value -> Parser Member) -> Value -> Maybe Member
forall a b. (a -> Parser b) -> a -> Maybe b
parseMaybe (String -> (Object -> Parser Member) -> Value -> Parser Member
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"MessageCreate.member" ((Object -> Parser Member) -> Value -> Parser Member)
-> (Object -> Parser Member) -> Value -> Parser Member
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Object
userObject :: Object <- Object
o Object -> Key -> Parser Object
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"author"
Object
memberObject :: Object <- Object
o Object -> Key -> Parser Object
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"member"
Value -> Parser Member
forall a. FromJSON a => Value -> Parser a
parseJSON (Value -> Parser Member) -> Value -> Parser Member
forall a b. (a -> b) -> a -> b
$ Object -> Value
Object (Object
memberObject Object -> Object -> Object
forall a. Semigroup a => a -> a -> a
<> Key
"user" Key -> Object -> Object
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Object
userObject)) Value
data'
let user :: Maybe User
user = (Value -> Parser User) -> Value -> Maybe User
forall a b. (a -> Parser b) -> a -> Maybe b
parseMaybe Value -> Parser User
forall a. FromJSON a => Value -> Parser a
parseJSON (Value -> Maybe User) -> Maybe Value -> Maybe User
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Value
data' Value -> Getting (First Value) Value Value -> Maybe Value
forall s a. s -> Getting (First a) s a -> Maybe a
^? (Object -> Const (First Value) Object)
-> Value -> Const (First Value) Value
forall t. AsValue t => Prism' t Object
_Object ((Object -> Const (First Value) Object)
-> Value -> Const (First Value) Value)
-> ((Value -> Const (First Value) Value)
-> Object -> Const (First Value) Object)
-> Getting (First Value) Value Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Index Object -> Traversal' Object (IxValue Object)
forall m. Ixed m => Index m -> Traversal' m (IxValue m)
ix Index Object
"author"
DispatchData -> Parser DispatchData
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DispatchData -> Parser DispatchData)
-> DispatchData -> Parser DispatchData
forall a b. (a -> b) -> a -> b
$ UpdatedMessage -> Maybe User -> Maybe Member -> DispatchData
MessageUpdate UpdatedMessage
message Maybe User
user Maybe Member
member
parseDispatchData DispatchType
MESSAGE_DELETE Value
data' = MessageDeleteData -> DispatchData
MessageDelete (MessageDeleteData -> DispatchData)
-> Parser MessageDeleteData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser MessageDeleteData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
MESSAGE_DELETE_BULK Value
data' = MessageDeleteBulkData -> DispatchData
MessageDeleteBulk (MessageDeleteBulkData -> DispatchData)
-> Parser MessageDeleteBulkData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser MessageDeleteBulkData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
MESSAGE_REACTION_ADD Value
data' = ReactionEvtData -> DispatchData
MessageReactionAdd (ReactionEvtData -> DispatchData)
-> Parser ReactionEvtData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser ReactionEvtData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
MESSAGE_REACTION_REMOVE Value
data' = ReactionEvtData -> DispatchData
MessageReactionRemove (ReactionEvtData -> DispatchData)
-> Parser ReactionEvtData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser ReactionEvtData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
MESSAGE_REACTION_REMOVE_ALL Value
data' = MessageReactionRemoveAllData -> DispatchData
MessageReactionRemoveAll (MessageReactionRemoveAllData -> DispatchData)
-> Parser MessageReactionRemoveAllData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser MessageReactionRemoveAllData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
PRESENCE_UPDATE Value
data' = PresenceUpdateData -> DispatchData
PresenceUpdate (PresenceUpdateData -> DispatchData)
-> Parser PresenceUpdateData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser PresenceUpdateData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
TYPING_START Value
data' = TypingStartData -> DispatchData
TypingStart (TypingStartData -> DispatchData)
-> Parser TypingStartData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser TypingStartData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
USER_UPDATE Value
data' = User -> DispatchData
UserUpdate (User -> DispatchData) -> Parser User -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser User
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
VOICE_STATE_UPDATE Value
data' = VoiceState -> DispatchData
VoiceStateUpdate (VoiceState -> DispatchData)
-> Parser VoiceState -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser VoiceState
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
VOICE_SERVER_UPDATE Value
data' = VoiceServerUpdateData -> DispatchData
VoiceServerUpdate (VoiceServerUpdateData -> DispatchData)
-> Parser VoiceServerUpdateData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser VoiceServerUpdateData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
WEBHOOKS_UPDATE Value
data' = WebhooksUpdateData -> DispatchData
WebhooksUpdate (WebhooksUpdateData -> DispatchData)
-> Parser WebhooksUpdateData -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser WebhooksUpdateData
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
parseDispatchData DispatchType
INTERACTION_CREATE Value
data' = Interaction -> DispatchData
InteractionCreate (Interaction -> DispatchData)
-> Parser Interaction -> Parser DispatchData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Interaction
forall a. FromJSON a => Value -> Parser a
parseJSON Value
data'
data SentDiscordMessage
= StatusUpdate StatusUpdateData
| Identify IdentifyData
| HeartBeat (Maybe Int)
| VoiceStatusUpdate VoiceState
| Resume ResumeData
| RequestGuildMembers RequestGuildMembersData
deriving ( Int -> SentDiscordMessage -> ShowS
[SentDiscordMessage] -> ShowS
SentDiscordMessage -> String
(Int -> SentDiscordMessage -> ShowS)
-> (SentDiscordMessage -> String)
-> ([SentDiscordMessage] -> ShowS)
-> Show SentDiscordMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SentDiscordMessage] -> ShowS
$cshowList :: [SentDiscordMessage] -> ShowS
show :: SentDiscordMessage -> String
$cshow :: SentDiscordMessage -> String
showsPrec :: Int -> SentDiscordMessage -> ShowS
$cshowsPrec :: Int -> SentDiscordMessage -> ShowS
Show, (forall x. SentDiscordMessage -> Rep SentDiscordMessage x)
-> (forall x. Rep SentDiscordMessage x -> SentDiscordMessage)
-> Generic SentDiscordMessage
forall x. Rep SentDiscordMessage x -> SentDiscordMessage
forall x. SentDiscordMessage -> Rep SentDiscordMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SentDiscordMessage x -> SentDiscordMessage
$cfrom :: forall x. SentDiscordMessage -> Rep SentDiscordMessage x
Generic )
instance ToJSON SentDiscordMessage where
toJSON :: SentDiscordMessage -> Value
toJSON (HeartBeat Maybe Int
data') = [Pair] -> Value
object [Key
"op" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
1 :: Int), Key
"d" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
data']
toJSON (Identify IdentifyData
data') = [Pair] -> Value
object [Key
"op" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
2 :: Int), Key
"d" Key -> IdentifyData -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= IdentifyData
data']
toJSON (StatusUpdate StatusUpdateData
data') = [Pair] -> Value
object [Key
"op" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
3 :: Int), Key
"d" Key -> StatusUpdateData -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= StatusUpdateData
data']
toJSON (VoiceStatusUpdate VoiceState
data') = [Pair] -> Value
object [Key
"op" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
4 :: Int), Key
"d" Key -> VoiceState -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VoiceState
data']
toJSON (Resume ResumeData
data') = [Pair] -> Value
object [Key
"op" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
6 :: Int), Key
"d" Key -> ResumeData -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ResumeData
data']
toJSON (RequestGuildMembers RequestGuildMembersData
data') = [Pair] -> Value
object [Key
"op" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
8 :: Int), Key
"d" Key -> RequestGuildMembersData -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RequestGuildMembersData
data']
toEncoding :: SentDiscordMessage -> Encoding
toEncoding (HeartBeat Maybe Int
data') = Series -> Encoding
pairs (Key
"op" Key -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
1 :: Int) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
<> Key
"d" Key -> Maybe Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Int
data')
toEncoding (Identify IdentifyData
data') = Series -> Encoding
pairs (Key
"op" Key -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
2 :: Int) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
<> Key
"d" Key -> IdentifyData -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= IdentifyData
data')
toEncoding (StatusUpdate StatusUpdateData
data') = Series -> Encoding
pairs (Key
"op" Key -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
3 :: Int) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
<> Key
"d" Key -> StatusUpdateData -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= StatusUpdateData
data')
toEncoding (VoiceStatusUpdate VoiceState
data') = Series -> Encoding
pairs (Key
"op" Key -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
4 :: Int) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
<> Key
"d" Key -> VoiceState -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= VoiceState
data')
toEncoding (Resume ResumeData
data') = Series -> Encoding
pairs (Key
"op" Key -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
6 :: Int) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
<> Key
"d" Key -> ResumeData -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= ResumeData
data')
toEncoding (RequestGuildMembers RequestGuildMembersData
data') = Series -> Encoding
pairs (Key
"op" Key -> Int -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= (Int
8 :: Int) Series -> Series -> Series
forall a. Semigroup a => a -> a -> a
<> Key
"d" Key -> RequestGuildMembersData -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= RequestGuildMembersData
data')
data DispatchType
= READY
| RESUMED
| CHANNEL_CREATE
| CHANNEL_UPDATE
| CHANNEL_DELETE
| CHANNEL_PINS_UPDATE
| GUILD_CREATE
| GUILD_UPDATE
| GUILD_DELETE
| GUILD_BAN_ADD
| GUILD_BAN_REMOVE
| GUILD_EMOJIS_UPDATE
| GUILD_INTEGRATIONS_UPDATE
| GUILD_MEMBER_ADD
| GUILD_MEMBER_REMOVE
| GUILD_MEMBER_UPDATE
| GUILD_MEMBERS_CHUNK
| GUILD_ROLE_CREATE
| GUILD_ROLE_UPDATE
| GUILD_ROLE_DELETE
| INVITE_CREATE
| INVITE_DELETE
| MESSAGE_CREATE
| MESSAGE_UPDATE
| MESSAGE_DELETE
| MESSAGE_DELETE_BULK
| MESSAGE_REACTION_ADD
| MESSAGE_REACTION_REMOVE
| MESSAGE_REACTION_REMOVE_ALL
| PRESENCE_UPDATE
| TYPING_START
| USER_UPDATE
| VOICE_STATE_UPDATE
| VOICE_SERVER_UPDATE
| WEBHOOKS_UPDATE
| INTERACTION_CREATE
deriving ( Int -> DispatchType -> ShowS
[DispatchType] -> ShowS
DispatchType -> String
(Int -> DispatchType -> ShowS)
-> (DispatchType -> String)
-> ([DispatchType] -> ShowS)
-> Show DispatchType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DispatchType] -> ShowS
$cshowList :: [DispatchType] -> ShowS
show :: DispatchType -> String
$cshow :: DispatchType -> String
showsPrec :: Int -> DispatchType -> ShowS
$cshowsPrec :: Int -> DispatchType -> ShowS
Show, DispatchType -> DispatchType -> Bool
(DispatchType -> DispatchType -> Bool)
-> (DispatchType -> DispatchType -> Bool) -> Eq DispatchType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DispatchType -> DispatchType -> Bool
$c/= :: DispatchType -> DispatchType -> Bool
== :: DispatchType -> DispatchType -> Bool
$c== :: DispatchType -> DispatchType -> Bool
Eq, Int -> DispatchType
DispatchType -> Int
DispatchType -> [DispatchType]
DispatchType -> DispatchType
DispatchType -> DispatchType -> [DispatchType]
DispatchType -> DispatchType -> DispatchType -> [DispatchType]
(DispatchType -> DispatchType)
-> (DispatchType -> DispatchType)
-> (Int -> DispatchType)
-> (DispatchType -> Int)
-> (DispatchType -> [DispatchType])
-> (DispatchType -> DispatchType -> [DispatchType])
-> (DispatchType -> DispatchType -> [DispatchType])
-> (DispatchType -> DispatchType -> DispatchType -> [DispatchType])
-> Enum DispatchType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: DispatchType -> DispatchType -> DispatchType -> [DispatchType]
$cenumFromThenTo :: DispatchType -> DispatchType -> DispatchType -> [DispatchType]
enumFromTo :: DispatchType -> DispatchType -> [DispatchType]
$cenumFromTo :: DispatchType -> DispatchType -> [DispatchType]
enumFromThen :: DispatchType -> DispatchType -> [DispatchType]
$cenumFromThen :: DispatchType -> DispatchType -> [DispatchType]
enumFrom :: DispatchType -> [DispatchType]
$cenumFrom :: DispatchType -> [DispatchType]
fromEnum :: DispatchType -> Int
$cfromEnum :: DispatchType -> Int
toEnum :: Int -> DispatchType
$ctoEnum :: Int -> DispatchType
pred :: DispatchType -> DispatchType
$cpred :: DispatchType -> DispatchType
succ :: DispatchType -> DispatchType
$csucc :: DispatchType -> DispatchType
Enum, (forall x. DispatchType -> Rep DispatchType x)
-> (forall x. Rep DispatchType x -> DispatchType)
-> Generic DispatchType
forall x. Rep DispatchType x -> DispatchType
forall x. DispatchType -> Rep DispatchType x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DispatchType x -> DispatchType
$cfrom :: forall x. DispatchType -> Rep DispatchType x
Generic )
deriving anyclass ( [DispatchType] -> Encoding
[DispatchType] -> Value
DispatchType -> Encoding
DispatchType -> Value
(DispatchType -> Value)
-> (DispatchType -> Encoding)
-> ([DispatchType] -> Value)
-> ([DispatchType] -> Encoding)
-> ToJSON DispatchType
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [DispatchType] -> Encoding
$ctoEncodingList :: [DispatchType] -> Encoding
toJSONList :: [DispatchType] -> Value
$ctoJSONList :: [DispatchType] -> Value
toEncoding :: DispatchType -> Encoding
$ctoEncoding :: DispatchType -> Encoding
toJSON :: DispatchType -> Value
$ctoJSON :: DispatchType -> Value
ToJSON, Value -> Parser [DispatchType]
Value -> Parser DispatchType
(Value -> Parser DispatchType)
-> (Value -> Parser [DispatchType]) -> FromJSON DispatchType
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [DispatchType]
$cparseJSONList :: Value -> Parser [DispatchType]
parseJSON :: Value -> Parser DispatchType
$cparseJSON :: Value -> Parser DispatchType
FromJSON )
data IdentifyData = IdentifyData
{ IdentifyData -> Text
token :: Text
, IdentifyData -> IdentifyProps
properties :: IdentifyProps
, IdentifyData -> Bool
compress :: Bool
, IdentifyData -> Int
largeThreshold :: Int
, IdentifyData -> (Int, Int)
shard :: (Int, Int)
, IdentifyData -> Maybe StatusUpdateData
presence :: Maybe StatusUpdateData
, IdentifyData -> Intents
intents :: Intents
}
deriving ( Int -> IdentifyData -> ShowS
[IdentifyData] -> ShowS
IdentifyData -> String
(Int -> IdentifyData -> ShowS)
-> (IdentifyData -> String)
-> ([IdentifyData] -> ShowS)
-> Show IdentifyData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IdentifyData] -> ShowS
$cshowList :: [IdentifyData] -> ShowS
show :: IdentifyData -> String
$cshow :: IdentifyData -> String
showsPrec :: Int -> IdentifyData -> ShowS
$cshowsPrec :: Int -> IdentifyData -> ShowS
Show, (forall x. IdentifyData -> Rep IdentifyData x)
-> (forall x. Rep IdentifyData x -> IdentifyData)
-> Generic IdentifyData
forall x. Rep IdentifyData x -> IdentifyData
forall x. IdentifyData -> Rep IdentifyData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IdentifyData x -> IdentifyData
$cfrom :: forall x. IdentifyData -> Rep IdentifyData x
Generic )
deriving [IdentifyData] -> Encoding
[IdentifyData] -> Value
IdentifyData -> Encoding
IdentifyData -> Value
(IdentifyData -> Value)
-> (IdentifyData -> Encoding)
-> ([IdentifyData] -> Value)
-> ([IdentifyData] -> Encoding)
-> ToJSON IdentifyData
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [IdentifyData] -> Encoding
$ctoEncodingList :: [IdentifyData] -> Encoding
toJSONList :: [IdentifyData] -> Value
$ctoJSONList :: [IdentifyData] -> Value
toEncoding :: IdentifyData -> Encoding
$ctoEncoding :: IdentifyData -> Encoding
toJSON :: IdentifyData -> Value
$ctoJSON :: IdentifyData -> Value
ToJSON via CalamityJSON IdentifyData
data StatusUpdateData = StatusUpdateData
{ StatusUpdateData -> Maybe Integer
since :: Maybe Integer
, StatusUpdateData -> Maybe Activity
game :: Maybe Activity
, StatusUpdateData -> StatusType
status :: StatusType
, StatusUpdateData -> Bool
afk :: Bool
}
deriving ( Int -> StatusUpdateData -> ShowS
[StatusUpdateData] -> ShowS
StatusUpdateData -> String
(Int -> StatusUpdateData -> ShowS)
-> (StatusUpdateData -> String)
-> ([StatusUpdateData] -> ShowS)
-> Show StatusUpdateData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatusUpdateData] -> ShowS
$cshowList :: [StatusUpdateData] -> ShowS
show :: StatusUpdateData -> String
$cshow :: StatusUpdateData -> String
showsPrec :: Int -> StatusUpdateData -> ShowS
$cshowsPrec :: Int -> StatusUpdateData -> ShowS
Show, (forall x. StatusUpdateData -> Rep StatusUpdateData x)
-> (forall x. Rep StatusUpdateData x -> StatusUpdateData)
-> Generic StatusUpdateData
forall x. Rep StatusUpdateData x -> StatusUpdateData
forall x. StatusUpdateData -> Rep StatusUpdateData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatusUpdateData x -> StatusUpdateData
$cfrom :: forall x. StatusUpdateData -> Rep StatusUpdateData x
Generic )
deriving [StatusUpdateData] -> Encoding
[StatusUpdateData] -> Value
StatusUpdateData -> Encoding
StatusUpdateData -> Value
(StatusUpdateData -> Value)
-> (StatusUpdateData -> Encoding)
-> ([StatusUpdateData] -> Value)
-> ([StatusUpdateData] -> Encoding)
-> ToJSON StatusUpdateData
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [StatusUpdateData] -> Encoding
$ctoEncodingList :: [StatusUpdateData] -> Encoding
toJSONList :: [StatusUpdateData] -> Value
$ctoJSONList :: [StatusUpdateData] -> Value
toEncoding :: StatusUpdateData -> Encoding
$ctoEncoding :: StatusUpdateData -> Encoding
toJSON :: StatusUpdateData -> Value
$ctoJSON :: StatusUpdateData -> Value
ToJSON via CalamityJSONKeepNothing StatusUpdateData
data ResumeData = ResumeData
{ ResumeData -> Text
token :: Text
, ResumeData -> Text
sessionID :: Text
, ResumeData -> Int
seq :: Int
}
deriving ( Int -> ResumeData -> ShowS
[ResumeData] -> ShowS
ResumeData -> String
(Int -> ResumeData -> ShowS)
-> (ResumeData -> String)
-> ([ResumeData] -> ShowS)
-> Show ResumeData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResumeData] -> ShowS
$cshowList :: [ResumeData] -> ShowS
show :: ResumeData -> String
$cshow :: ResumeData -> String
showsPrec :: Int -> ResumeData -> ShowS
$cshowsPrec :: Int -> ResumeData -> ShowS
Show, (forall x. ResumeData -> Rep ResumeData x)
-> (forall x. Rep ResumeData x -> ResumeData) -> Generic ResumeData
forall x. Rep ResumeData x -> ResumeData
forall x. ResumeData -> Rep ResumeData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResumeData x -> ResumeData
$cfrom :: forall x. ResumeData -> Rep ResumeData x
Generic )
deriving ( [ResumeData] -> Encoding
[ResumeData] -> Value
ResumeData -> Encoding
ResumeData -> Value
(ResumeData -> Value)
-> (ResumeData -> Encoding)
-> ([ResumeData] -> Value)
-> ([ResumeData] -> Encoding)
-> ToJSON ResumeData
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ResumeData] -> Encoding
$ctoEncodingList :: [ResumeData] -> Encoding
toJSONList :: [ResumeData] -> Value
$ctoJSONList :: [ResumeData] -> Value
toEncoding :: ResumeData -> Encoding
$ctoEncoding :: ResumeData -> Encoding
toJSON :: ResumeData -> Value
$ctoJSON :: ResumeData -> Value
ToJSON, Value -> Parser [ResumeData]
Value -> Parser ResumeData
(Value -> Parser ResumeData)
-> (Value -> Parser [ResumeData]) -> FromJSON ResumeData
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ResumeData]
$cparseJSONList :: Value -> Parser [ResumeData]
parseJSON :: Value -> Parser ResumeData
$cparseJSON :: Value -> Parser ResumeData
FromJSON ) via CalamityJSON ResumeData
data RequestGuildMembersData = RequestGuildMembersData
{ RequestGuildMembersData -> Snowflake Guild
guildID :: Snowflake Guild
, RequestGuildMembersData -> Maybe Text
query :: Maybe Text
, RequestGuildMembersData -> Maybe Int
limit :: Maybe Int
}
deriving ( Int -> RequestGuildMembersData -> ShowS
[RequestGuildMembersData] -> ShowS
RequestGuildMembersData -> String
(Int -> RequestGuildMembersData -> ShowS)
-> (RequestGuildMembersData -> String)
-> ([RequestGuildMembersData] -> ShowS)
-> Show RequestGuildMembersData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RequestGuildMembersData] -> ShowS
$cshowList :: [RequestGuildMembersData] -> ShowS
show :: RequestGuildMembersData -> String
$cshow :: RequestGuildMembersData -> String
showsPrec :: Int -> RequestGuildMembersData -> ShowS
$cshowsPrec :: Int -> RequestGuildMembersData -> ShowS
Show, (forall x.
RequestGuildMembersData -> Rep RequestGuildMembersData x)
-> (forall x.
Rep RequestGuildMembersData x -> RequestGuildMembersData)
-> Generic RequestGuildMembersData
forall x. Rep RequestGuildMembersData x -> RequestGuildMembersData
forall x. RequestGuildMembersData -> Rep RequestGuildMembersData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RequestGuildMembersData x -> RequestGuildMembersData
$cfrom :: forall x. RequestGuildMembersData -> Rep RequestGuildMembersData x
Generic )
instance ToJSON RequestGuildMembersData where
toJSON :: RequestGuildMembersData -> Value
toJSON RequestGuildMembersData { Snowflake Guild
guildID :: Snowflake Guild
$sel:guildID:RequestGuildMembersData :: RequestGuildMembersData -> Snowflake Guild
guildID, Maybe Text
query :: Maybe Text
$sel:query:RequestGuildMembersData :: RequestGuildMembersData -> Maybe Text
query, Maybe Int
limit :: Maybe Int
$sel:limit:RequestGuildMembersData :: RequestGuildMembersData -> Maybe Int
limit } =
[Pair] -> Value
object [Key
"guild_id" Key -> Snowflake Guild -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Snowflake Guild
guildID, Key
"query" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text -> Maybe Text -> Text
forall a. a -> Maybe a -> a
fromMaybe Text
"" Maybe Text
query, Key
"limit" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int -> Maybe Int -> Int
forall a. a -> Maybe a -> a
fromMaybe Int
0 Maybe Int
limit]
data IdentifyProps = IdentifyProps
{ IdentifyProps -> Text
browser :: Text
, IdentifyProps -> Text
device :: Text
}
deriving ( Int -> IdentifyProps -> ShowS
[IdentifyProps] -> ShowS
IdentifyProps -> String
(Int -> IdentifyProps -> ShowS)
-> (IdentifyProps -> String)
-> ([IdentifyProps] -> ShowS)
-> Show IdentifyProps
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IdentifyProps] -> ShowS
$cshowList :: [IdentifyProps] -> ShowS
show :: IdentifyProps -> String
$cshow :: IdentifyProps -> String
showsPrec :: Int -> IdentifyProps -> ShowS
$cshowsPrec :: Int -> IdentifyProps -> ShowS
Show, (forall x. IdentifyProps -> Rep IdentifyProps x)
-> (forall x. Rep IdentifyProps x -> IdentifyProps)
-> Generic IdentifyProps
forall x. Rep IdentifyProps x -> IdentifyProps
forall x. IdentifyProps -> Rep IdentifyProps x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep IdentifyProps x -> IdentifyProps
$cfrom :: forall x. IdentifyProps -> Rep IdentifyProps x
Generic )
instance ToJSON IdentifyProps where
toJSON :: IdentifyProps -> Value
toJSON IdentifyProps { Text
browser :: Text
$sel:browser:IdentifyProps :: IdentifyProps -> Text
browser, Text
device :: Text
$sel:device:IdentifyProps :: IdentifyProps -> Text
device } = [Pair] -> Value
object [Key
"$browser" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
browser, Key
"$device" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
device]
data ControlMessage
= RestartShard
| ShutDownShard
| SendPresence StatusUpdateData
deriving ( Int -> ControlMessage -> ShowS
[ControlMessage] -> ShowS
ControlMessage -> String
(Int -> ControlMessage -> ShowS)
-> (ControlMessage -> String)
-> ([ControlMessage] -> ShowS)
-> Show ControlMessage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ControlMessage] -> ShowS
$cshowList :: [ControlMessage] -> ShowS
show :: ControlMessage -> String
$cshow :: ControlMessage -> String
showsPrec :: Int -> ControlMessage -> ShowS
$cshowsPrec :: Int -> ControlMessage -> ShowS
Show, (forall x. ControlMessage -> Rep ControlMessage x)
-> (forall x. Rep ControlMessage x -> ControlMessage)
-> Generic ControlMessage
forall x. Rep ControlMessage x -> ControlMessage
forall x. ControlMessage -> Rep ControlMessage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ControlMessage x -> ControlMessage
$cfrom :: forall x. ControlMessage -> Rep ControlMessage x
Generic )
data ShardFlowControl
= ShardFlowRestart
| ShardFlowShutDown
deriving ( Int -> ShardFlowControl -> ShowS
[ShardFlowControl] -> ShowS
ShardFlowControl -> String
(Int -> ShardFlowControl -> ShowS)
-> (ShardFlowControl -> String)
-> ([ShardFlowControl] -> ShowS)
-> Show ShardFlowControl
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ShardFlowControl] -> ShowS
$cshowList :: [ShardFlowControl] -> ShowS
show :: ShardFlowControl -> String
$cshow :: ShardFlowControl -> String
showsPrec :: Int -> ShardFlowControl -> ShowS
$cshowsPrec :: Int -> ShardFlowControl -> ShowS
Show, (forall x. ShardFlowControl -> Rep ShardFlowControl x)
-> (forall x. Rep ShardFlowControl x -> ShardFlowControl)
-> Generic ShardFlowControl
forall x. Rep ShardFlowControl x -> ShardFlowControl
forall x. ShardFlowControl -> Rep ShardFlowControl x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ShardFlowControl x -> ShardFlowControl
$cfrom :: forall x. ShardFlowControl -> Rep ShardFlowControl x
Generic )
deriving ( Int -> ShardFlowControl -> Builder
Int -> ShardFlowControl -> Text
Int -> ShardFlowControl -> Text
[ShardFlowControl] -> Builder
[ShardFlowControl] -> Text
[ShardFlowControl] -> Text
ShardFlowControl -> Builder
ShardFlowControl -> Text
ShardFlowControl -> Text
(Int -> ShardFlowControl -> Builder)
-> (ShardFlowControl -> Builder)
-> ([ShardFlowControl] -> Builder)
-> (Int -> ShardFlowControl -> Text)
-> (ShardFlowControl -> Text)
-> ([ShardFlowControl] -> Text)
-> (Int -> ShardFlowControl -> Text)
-> (ShardFlowControl -> Text)
-> ([ShardFlowControl] -> Text)
-> TextShow ShardFlowControl
forall a.
(Int -> a -> Builder)
-> (a -> Builder)
-> ([a] -> Builder)
-> (Int -> a -> Text)
-> (a -> Text)
-> ([a] -> Text)
-> (Int -> a -> Text)
-> (a -> Text)
-> ([a] -> Text)
-> TextShow a
showtlList :: [ShardFlowControl] -> Text
$cshowtlList :: [ShardFlowControl] -> Text
showtl :: ShardFlowControl -> Text
$cshowtl :: ShardFlowControl -> Text
showtlPrec :: Int -> ShardFlowControl -> Text
$cshowtlPrec :: Int -> ShardFlowControl -> Text
showtList :: [ShardFlowControl] -> Text
$cshowtList :: [ShardFlowControl] -> Text
showt :: ShardFlowControl -> Text
$cshowt :: ShardFlowControl -> Text
showtPrec :: Int -> ShardFlowControl -> Text
$cshowtPrec :: Int -> ShardFlowControl -> Text
showbList :: [ShardFlowControl] -> Builder
$cshowbList :: [ShardFlowControl] -> Builder
showb :: ShardFlowControl -> Builder
$cshowb :: ShardFlowControl -> Builder
showbPrec :: Int -> ShardFlowControl -> Builder
$cshowbPrec :: Int -> ShardFlowControl -> Builder
TextShow ) via TSG.FromGeneric ShardFlowControl
data Shard = Shard
{ Shard -> Int
shardID :: Int
, Shard -> Int
shardCount :: Int
, Shard -> Text
gateway :: Text
, Shard -> InChan CalamityEvent
evtIn :: InChan CalamityEvent
, Shard -> OutChan ControlMessage
cmdOut :: OutChan ControlMessage
, Shard -> Text
token :: Text
, Shard -> Maybe StatusUpdateData
initialStatus :: Maybe StatusUpdateData
, Shard -> Intents
intents :: Intents
}
deriving ( (forall x. Shard -> Rep Shard x)
-> (forall x. Rep Shard x -> Shard) -> Generic Shard
forall x. Rep Shard x -> Shard
forall x. Shard -> Rep Shard x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Shard x -> Shard
$cfrom :: forall x. Shard -> Rep Shard x
Generic )
data ShardState = ShardState
{ ShardState -> Shard
shardS :: Shard
, ShardState -> Maybe Int
seqNum :: Maybe Int
, ShardState -> Maybe (Async (Maybe ()))
hbThread :: Maybe (Async (Maybe ()))
, ShardState -> Bool
hbResponse :: Bool
, ShardState -> Maybe Text
wsHost :: Maybe Text
, ShardState -> Maybe Text
sessionID :: Maybe Text
, ShardState -> Maybe Connection
wsConn :: Maybe Connection
}
deriving ( (forall x. ShardState -> Rep ShardState x)
-> (forall x. Rep ShardState x -> ShardState) -> Generic ShardState
forall x. Rep ShardState x -> ShardState
forall x. ShardState -> Rep ShardState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ShardState x -> ShardState
$cfrom :: forall x. ShardState -> Rep ShardState x
Generic )