{-# LANGUAGE TemplateHaskell #-}

-- | module containing all dispatch events
module Calamity.Gateway.DispatchEvents where

import Calamity.Internal.ConstructorName
import Calamity.Internal.UnixTimestamp
import Calamity.Internal.Utils
import Calamity.Types.Model.Channel
import Calamity.Types.Model.Channel.UpdatedMessage
import Calamity.Types.Model.Guild.Ban
import Calamity.Types.Model.Guild.Emoji
import Calamity.Types.Model.Guild.Guild
import Calamity.Types.Model.Guild.Member
import Calamity.Types.Model.Guild.Role
import Calamity.Types.Model.Guild.UnavailableGuild
import Calamity.Types.Model.Interaction
import Calamity.Types.Model.Presence.Presence
import Calamity.Types.Model.User
import Calamity.Types.Model.Voice
import Calamity.Types.Snowflake
import Data.Aeson ((.:), (.:?))
import Data.Aeson qualified as Aeson
import Data.Kind (Type)
import Data.Text (Text)
import Data.Time
import Data.Typeable (Typeable)
import GHC.Generics
import Optics.TH

data CalamityEvent
  = Dispatch
      Int
      -- ^ The shard that pushed this event
      DispatchData
      -- ^ The attached data
  | -- | The data sent to the custom event
    forall (a :: Type). Typeable a => Custom a
  | ShutDown

data DispatchData
  = Ready !ReadyData
  | Resumed
  | ChannelCreate !Channel
  | ChannelUpdate !Channel
  | ChannelDelete !Channel
  | ChannelPinsUpdate !ChannelPinsUpdateData
  | GuildCreate !Guild
  | GuildUpdate !UpdatedGuild
  | GuildDelete !UnavailableGuild
  | GuildBanAdd !BanData
  | GuildBanRemove !BanData
  | GuildEmojisUpdate !GuildEmojisUpdateData
  | GuildIntegrationsUpdate !GuildIntegrationsUpdateData
  | GuildMemberAdd !(Snowflake Guild) !Member
  | GuildMemberRemove !GuildMemberRemoveData
  | GuildMemberUpdate !GuildMemberUpdateData
  | GuildMembersChunk !GuildMembersChunkData
  | GuildRoleCreate !GuildRoleData
  | GuildRoleUpdate !GuildRoleData
  | GuildRoleDelete !GuildRoleDeleteData
  | InviteCreate !InviteCreateData
  | InviteDelete !InviteDeleteData
  | MessageCreate !Message !(Maybe User) !(Maybe Member)
  | MessageUpdate !UpdatedMessage !(Maybe User) !(Maybe Member)
  | MessageDelete !MessageDeleteData
  | MessageDeleteBulk !MessageDeleteBulkData
  | MessageReactionAdd !ReactionEvtData
  | MessageReactionRemove !ReactionEvtData
  | MessageReactionRemoveAll !MessageReactionRemoveAllData
  | PresenceUpdate !PresenceUpdateData
  | TypingStart !TypingStartData
  | UserUpdate !User
  | VoiceStateUpdate !VoiceState
  | VoiceServerUpdate !VoiceServerUpdateData
  | WebhooksUpdate !WebhooksUpdateData
  | InteractionCreate !Interaction
  | UNHANDLED Text
  deriving (Int -> DispatchData -> ShowS
[DispatchData] -> ShowS
DispatchData -> String
(Int -> DispatchData -> ShowS)
-> (DispatchData -> String)
-> ([DispatchData] -> ShowS)
-> Show DispatchData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DispatchData -> ShowS
showsPrec :: Int -> DispatchData -> ShowS
$cshow :: DispatchData -> String
show :: DispatchData -> String
$cshowList :: [DispatchData] -> ShowS
showList :: [DispatchData] -> ShowS
Show, (forall x. DispatchData -> Rep DispatchData x)
-> (forall x. Rep DispatchData x -> DispatchData)
-> Generic DispatchData
forall x. Rep DispatchData x -> DispatchData
forall x. DispatchData -> Rep DispatchData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. DispatchData -> Rep DispatchData x
from :: forall x. DispatchData -> Rep DispatchData x
$cto :: forall x. Rep DispatchData x -> DispatchData
to :: forall x. Rep DispatchData x -> DispatchData
Generic, DispatchData -> String
(DispatchData -> String) -> CtorName DispatchData
forall a. (a -> String) -> CtorName a
$cctorName :: DispatchData -> String
ctorName :: DispatchData -> String
CtorName)

data ReadyData = ReadyData
  { ReadyData -> Integer
v :: Integer
  , ReadyData -> User
user :: User
  , ReadyData -> [UnavailableGuild]
guilds :: [UnavailableGuild]
  , ReadyData -> Text
sessionID :: Text
  }
  deriving (Int -> ReadyData -> ShowS
[ReadyData] -> ShowS
ReadyData -> String
(Int -> ReadyData -> ShowS)
-> (ReadyData -> String)
-> ([ReadyData] -> ShowS)
-> Show ReadyData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReadyData -> ShowS
showsPrec :: Int -> ReadyData -> ShowS
$cshow :: ReadyData -> String
show :: ReadyData -> String
$cshowList :: [ReadyData] -> ShowS
showList :: [ReadyData] -> ShowS
Show)

instance Aeson.FromJSON ReadyData where
  parseJSON :: Value -> Parser ReadyData
parseJSON = String -> (Object -> Parser ReadyData) -> Value -> Parser ReadyData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"ReadyData" ((Object -> Parser ReadyData) -> Value -> Parser ReadyData)
-> (Object -> Parser ReadyData) -> Value -> Parser ReadyData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Integer -> User -> [UnavailableGuild] -> Text -> ReadyData
ReadyData
      (Integer -> User -> [UnavailableGuild] -> Text -> ReadyData)
-> Parser Integer
-> Parser (User -> [UnavailableGuild] -> Text -> ReadyData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser Integer
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"v"
      Parser (User -> [UnavailableGuild] -> Text -> ReadyData)
-> Parser User -> Parser ([UnavailableGuild] -> Text -> ReadyData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser User
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"user"
      Parser ([UnavailableGuild] -> Text -> ReadyData)
-> Parser [UnavailableGuild] -> Parser (Text -> ReadyData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser [UnavailableGuild]
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guilds"
      Parser (Text -> ReadyData) -> Parser Text -> Parser ReadyData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"session_id"

data ChannelPinsUpdateData = ChannelPinsUpdateData
  { ChannelPinsUpdateData -> Snowflake Channel
channelID :: Snowflake Channel
  , ChannelPinsUpdateData -> Maybe UTCTime
lastPinTimestamp :: Maybe UTCTime
  }
  deriving (Int -> ChannelPinsUpdateData -> ShowS
[ChannelPinsUpdateData] -> ShowS
ChannelPinsUpdateData -> String
(Int -> ChannelPinsUpdateData -> ShowS)
-> (ChannelPinsUpdateData -> String)
-> ([ChannelPinsUpdateData] -> ShowS)
-> Show ChannelPinsUpdateData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChannelPinsUpdateData -> ShowS
showsPrec :: Int -> ChannelPinsUpdateData -> ShowS
$cshow :: ChannelPinsUpdateData -> String
show :: ChannelPinsUpdateData -> String
$cshowList :: [ChannelPinsUpdateData] -> ShowS
showList :: [ChannelPinsUpdateData] -> ShowS
Show)

instance Aeson.FromJSON ChannelPinsUpdateData where
  parseJSON :: Value -> Parser ChannelPinsUpdateData
parseJSON = String
-> (Object -> Parser ChannelPinsUpdateData)
-> Value
-> Parser ChannelPinsUpdateData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"ChannelPinsUpdateData" ((Object -> Parser ChannelPinsUpdateData)
 -> Value -> Parser ChannelPinsUpdateData)
-> (Object -> Parser ChannelPinsUpdateData)
-> Value
-> Parser ChannelPinsUpdateData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Channel -> Maybe UTCTime -> ChannelPinsUpdateData
ChannelPinsUpdateData
      (Snowflake Channel -> Maybe UTCTime -> ChannelPinsUpdateData)
-> Parser (Snowflake Channel)
-> Parser (Maybe UTCTime -> ChannelPinsUpdateData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Channel)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"channel_id"
      Parser (Maybe UTCTime -> ChannelPinsUpdateData)
-> Parser (Maybe UTCTime) -> Parser ChannelPinsUpdateData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe UTCTime)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"last_pin_timestamp"

data GuildEmojisUpdateData = GuildEmojisUpdateData
  { GuildEmojisUpdateData -> Snowflake Guild
guildID :: Snowflake Guild
  , GuildEmojisUpdateData -> [Emoji]
emojis :: [Emoji]
  }
  deriving (Int -> GuildEmojisUpdateData -> ShowS
[GuildEmojisUpdateData] -> ShowS
GuildEmojisUpdateData -> String
(Int -> GuildEmojisUpdateData -> ShowS)
-> (GuildEmojisUpdateData -> String)
-> ([GuildEmojisUpdateData] -> ShowS)
-> Show GuildEmojisUpdateData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GuildEmojisUpdateData -> ShowS
showsPrec :: Int -> GuildEmojisUpdateData -> ShowS
$cshow :: GuildEmojisUpdateData -> String
show :: GuildEmojisUpdateData -> String
$cshowList :: [GuildEmojisUpdateData] -> ShowS
showList :: [GuildEmojisUpdateData] -> ShowS
Show)

instance Aeson.FromJSON GuildEmojisUpdateData where
  parseJSON :: Value -> Parser GuildEmojisUpdateData
parseJSON = String
-> (Object -> Parser GuildEmojisUpdateData)
-> Value
-> Parser GuildEmojisUpdateData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"GuildEmojisUpdateData" ((Object -> Parser GuildEmojisUpdateData)
 -> Value -> Parser GuildEmojisUpdateData)
-> (Object -> Parser GuildEmojisUpdateData)
-> Value
-> Parser GuildEmojisUpdateData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Guild -> [Emoji] -> GuildEmojisUpdateData
GuildEmojisUpdateData
      (Snowflake Guild -> [Emoji] -> GuildEmojisUpdateData)
-> Parser (Snowflake Guild)
-> Parser ([Emoji] -> GuildEmojisUpdateData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Guild)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id"
      Parser ([Emoji] -> GuildEmojisUpdateData)
-> Parser [Emoji] -> Parser GuildEmojisUpdateData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser [Emoji]
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"emojis"

newtype GuildIntegrationsUpdateData = GuildIntegrationsUpdateData
  { GuildIntegrationsUpdateData -> Snowflake Guild
guildID :: Snowflake Guild
  }
  deriving stock (Int -> GuildIntegrationsUpdateData -> ShowS
[GuildIntegrationsUpdateData] -> ShowS
GuildIntegrationsUpdateData -> String
(Int -> GuildIntegrationsUpdateData -> ShowS)
-> (GuildIntegrationsUpdateData -> String)
-> ([GuildIntegrationsUpdateData] -> ShowS)
-> Show GuildIntegrationsUpdateData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GuildIntegrationsUpdateData -> ShowS
showsPrec :: Int -> GuildIntegrationsUpdateData -> ShowS
$cshow :: GuildIntegrationsUpdateData -> String
show :: GuildIntegrationsUpdateData -> String
$cshowList :: [GuildIntegrationsUpdateData] -> ShowS
showList :: [GuildIntegrationsUpdateData] -> ShowS
Show)

instance Aeson.FromJSON GuildIntegrationsUpdateData where
  parseJSON :: Value -> Parser GuildIntegrationsUpdateData
parseJSON = String
-> (Object -> Parser GuildIntegrationsUpdateData)
-> Value
-> Parser GuildIntegrationsUpdateData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"GuildIntegrationsUpdateData" ((Object -> Parser GuildIntegrationsUpdateData)
 -> Value -> Parser GuildIntegrationsUpdateData)
-> (Object -> Parser GuildIntegrationsUpdateData)
-> Value
-> Parser GuildIntegrationsUpdateData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Guild -> GuildIntegrationsUpdateData
GuildIntegrationsUpdateData
      (Snowflake Guild -> GuildIntegrationsUpdateData)
-> Parser (Snowflake Guild) -> Parser GuildIntegrationsUpdateData
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Guild)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id"

data GuildMemberRemoveData = GuildMemberRemoveData
  { GuildMemberRemoveData -> Snowflake Guild
guildID :: Snowflake Guild
  , GuildMemberRemoveData -> User
user :: User
  }
  deriving (Int -> GuildMemberRemoveData -> ShowS
[GuildMemberRemoveData] -> ShowS
GuildMemberRemoveData -> String
(Int -> GuildMemberRemoveData -> ShowS)
-> (GuildMemberRemoveData -> String)
-> ([GuildMemberRemoveData] -> ShowS)
-> Show GuildMemberRemoveData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GuildMemberRemoveData -> ShowS
showsPrec :: Int -> GuildMemberRemoveData -> ShowS
$cshow :: GuildMemberRemoveData -> String
show :: GuildMemberRemoveData -> String
$cshowList :: [GuildMemberRemoveData] -> ShowS
showList :: [GuildMemberRemoveData] -> ShowS
Show)

instance Aeson.FromJSON GuildMemberRemoveData where
  parseJSON :: Value -> Parser GuildMemberRemoveData
parseJSON = String
-> (Object -> Parser GuildMemberRemoveData)
-> Value
-> Parser GuildMemberRemoveData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"GuildMemberRemoveData" ((Object -> Parser GuildMemberRemoveData)
 -> Value -> Parser GuildMemberRemoveData)
-> (Object -> Parser GuildMemberRemoveData)
-> Value
-> Parser GuildMemberRemoveData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Guild -> User -> GuildMemberRemoveData
GuildMemberRemoveData
      (Snowflake Guild -> User -> GuildMemberRemoveData)
-> Parser (Snowflake Guild)
-> Parser (User -> GuildMemberRemoveData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Guild)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id"
      Parser (User -> GuildMemberRemoveData)
-> Parser User -> Parser GuildMemberRemoveData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser User
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"user"

data GuildMemberUpdateData = GuildMemberUpdateData
  { GuildMemberUpdateData -> Snowflake Guild
guildID :: Snowflake Guild
  , GuildMemberUpdateData -> AesonVector (Snowflake Role)
roles :: AesonVector (Snowflake Role)
  , GuildMemberUpdateData -> User
user :: User
  , GuildMemberUpdateData -> Maybe Text
nick :: Maybe Text
  }
  deriving (Int -> GuildMemberUpdateData -> ShowS
[GuildMemberUpdateData] -> ShowS
GuildMemberUpdateData -> String
(Int -> GuildMemberUpdateData -> ShowS)
-> (GuildMemberUpdateData -> String)
-> ([GuildMemberUpdateData] -> ShowS)
-> Show GuildMemberUpdateData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GuildMemberUpdateData -> ShowS
showsPrec :: Int -> GuildMemberUpdateData -> ShowS
$cshow :: GuildMemberUpdateData -> String
show :: GuildMemberUpdateData -> String
$cshowList :: [GuildMemberUpdateData] -> ShowS
showList :: [GuildMemberUpdateData] -> ShowS
Show)

instance Aeson.FromJSON GuildMemberUpdateData where
  parseJSON :: Value -> Parser GuildMemberUpdateData
parseJSON = String
-> (Object -> Parser GuildMemberUpdateData)
-> Value
-> Parser GuildMemberUpdateData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"GuildMemberUpdateData" ((Object -> Parser GuildMemberUpdateData)
 -> Value -> Parser GuildMemberUpdateData)
-> (Object -> Parser GuildMemberUpdateData)
-> Value
-> Parser GuildMemberUpdateData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Guild
-> AesonVector (Snowflake Role)
-> User
-> Maybe Text
-> GuildMemberUpdateData
GuildMemberUpdateData
      (Snowflake Guild
 -> AesonVector (Snowflake Role)
 -> User
 -> Maybe Text
 -> GuildMemberUpdateData)
-> Parser (Snowflake Guild)
-> Parser
     (AesonVector (Snowflake Role)
      -> User -> Maybe Text -> GuildMemberUpdateData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Guild)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id"
      Parser
  (AesonVector (Snowflake Role)
   -> User -> Maybe Text -> GuildMemberUpdateData)
-> Parser (AesonVector (Snowflake Role))
-> Parser (User -> Maybe Text -> GuildMemberUpdateData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (AesonVector (Snowflake Role))
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"roles"
      Parser (User -> Maybe Text -> GuildMemberUpdateData)
-> Parser User -> Parser (Maybe Text -> GuildMemberUpdateData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser User
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"user"
      Parser (Maybe Text -> GuildMemberUpdateData)
-> Parser (Maybe Text) -> Parser GuildMemberUpdateData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"nick"

data GuildMembersChunkData = GuildMembersChunkData
  { GuildMembersChunkData -> Snowflake Guild
guildID :: Snowflake Guild
  , GuildMembersChunkData -> [Member]
members :: [Member]
  }
  deriving (Int -> GuildMembersChunkData -> ShowS
[GuildMembersChunkData] -> ShowS
GuildMembersChunkData -> String
(Int -> GuildMembersChunkData -> ShowS)
-> (GuildMembersChunkData -> String)
-> ([GuildMembersChunkData] -> ShowS)
-> Show GuildMembersChunkData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GuildMembersChunkData -> ShowS
showsPrec :: Int -> GuildMembersChunkData -> ShowS
$cshow :: GuildMembersChunkData -> String
show :: GuildMembersChunkData -> String
$cshowList :: [GuildMembersChunkData] -> ShowS
showList :: [GuildMembersChunkData] -> ShowS
Show)

instance Aeson.FromJSON GuildMembersChunkData where
  parseJSON :: Value -> Parser GuildMembersChunkData
parseJSON = String
-> (Object -> Parser GuildMembersChunkData)
-> Value
-> Parser GuildMembersChunkData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"GuildMembersChunkData" ((Object -> Parser GuildMembersChunkData)
 -> Value -> Parser GuildMembersChunkData)
-> (Object -> Parser GuildMembersChunkData)
-> Value
-> Parser GuildMembersChunkData
forall a b. (a -> b) -> a -> b
$ \Object
v -> do
    Snowflake Guild
guildID <- Object
v Object -> Key -> Parser (Snowflake Guild)
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"guild_id"

    [Member]
members' <- do
      [Object]
members' <- Object
v Object -> Key -> Parser [Object]
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"members"
      (Object -> Parser Member) -> [Object] -> Parser [Member]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (Value -> Parser Member
forall a. FromJSON a => Value -> Parser a
Aeson.parseJSON (Value -> Parser Member)
-> (Object -> Value) -> Object -> Parser Member
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Object -> Value
Aeson.Object) [Object]
members'

    GuildMembersChunkData -> Parser GuildMembersChunkData
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GuildMembersChunkData -> Parser GuildMembersChunkData)
-> GuildMembersChunkData -> Parser GuildMembersChunkData
forall a b. (a -> b) -> a -> b
$ Snowflake Guild -> [Member] -> GuildMembersChunkData
GuildMembersChunkData Snowflake Guild
guildID [Member]
members'

data GuildRoleData = GuildRoleData
  { GuildRoleData -> Snowflake Guild
guildID :: Snowflake Guild
  , GuildRoleData -> Role
role :: Role
  }
  deriving (Int -> GuildRoleData -> ShowS
[GuildRoleData] -> ShowS
GuildRoleData -> String
(Int -> GuildRoleData -> ShowS)
-> (GuildRoleData -> String)
-> ([GuildRoleData] -> ShowS)
-> Show GuildRoleData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GuildRoleData -> ShowS
showsPrec :: Int -> GuildRoleData -> ShowS
$cshow :: GuildRoleData -> String
show :: GuildRoleData -> String
$cshowList :: [GuildRoleData] -> ShowS
showList :: [GuildRoleData] -> ShowS
Show)

instance Aeson.FromJSON GuildRoleData where
  parseJSON :: Value -> Parser GuildRoleData
parseJSON = String
-> (Object -> Parser GuildRoleData)
-> Value
-> Parser GuildRoleData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"GuildRoleData" ((Object -> Parser GuildRoleData) -> Value -> Parser GuildRoleData)
-> (Object -> Parser GuildRoleData)
-> Value
-> Parser GuildRoleData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Guild -> Role -> GuildRoleData
GuildRoleData
      (Snowflake Guild -> Role -> GuildRoleData)
-> Parser (Snowflake Guild) -> Parser (Role -> GuildRoleData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Guild)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id"
      Parser (Role -> GuildRoleData)
-> Parser Role -> Parser GuildRoleData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Role
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"role"

data GuildRoleDeleteData = GuildRoleDeleteData
  { GuildRoleDeleteData -> Snowflake Guild
guildID :: Snowflake Guild
  , GuildRoleDeleteData -> Snowflake Role
roleID :: Snowflake Role
  }
  deriving (Int -> GuildRoleDeleteData -> ShowS
[GuildRoleDeleteData] -> ShowS
GuildRoleDeleteData -> String
(Int -> GuildRoleDeleteData -> ShowS)
-> (GuildRoleDeleteData -> String)
-> ([GuildRoleDeleteData] -> ShowS)
-> Show GuildRoleDeleteData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GuildRoleDeleteData -> ShowS
showsPrec :: Int -> GuildRoleDeleteData -> ShowS
$cshow :: GuildRoleDeleteData -> String
show :: GuildRoleDeleteData -> String
$cshowList :: [GuildRoleDeleteData] -> ShowS
showList :: [GuildRoleDeleteData] -> ShowS
Show)
instance Aeson.FromJSON GuildRoleDeleteData where
  parseJSON :: Value -> Parser GuildRoleDeleteData
parseJSON = String
-> (Object -> Parser GuildRoleDeleteData)
-> Value
-> Parser GuildRoleDeleteData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"GuildRoleDeleteData" ((Object -> Parser GuildRoleDeleteData)
 -> Value -> Parser GuildRoleDeleteData)
-> (Object -> Parser GuildRoleDeleteData)
-> Value
-> Parser GuildRoleDeleteData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Guild -> Snowflake Role -> GuildRoleDeleteData
GuildRoleDeleteData
      (Snowflake Guild -> Snowflake Role -> GuildRoleDeleteData)
-> Parser (Snowflake Guild)
-> Parser (Snowflake Role -> GuildRoleDeleteData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Guild)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id"
      Parser (Snowflake Role -> GuildRoleDeleteData)
-> Parser (Snowflake Role) -> Parser GuildRoleDeleteData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Snowflake Role)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"role_id"

data InviteCreateData = InviteCreateData
  { InviteCreateData -> Snowflake Channel
channelID :: Snowflake Channel
  , InviteCreateData -> Text
code :: Text
  , InviteCreateData -> UTCTime
createdAt :: UTCTime
  , InviteCreateData -> Maybe (Snowflake Guild)
guildID :: Maybe (Snowflake Guild)
  , InviteCreateData -> Maybe (Snowflake User)
inviter :: Maybe (Snowflake User)
  , InviteCreateData -> Int
maxAge :: Int
  , InviteCreateData -> Int
maxUses :: Int
  , InviteCreateData -> Maybe (Snowflake User)
targetUser :: Maybe (Snowflake User)
  , InviteCreateData -> Maybe Integer
targetUserType :: Maybe Integer
  , InviteCreateData -> Bool
temporary :: Bool
  , InviteCreateData -> Integer
uses :: Integer
  }
  deriving (Int -> InviteCreateData -> ShowS
[InviteCreateData] -> ShowS
InviteCreateData -> String
(Int -> InviteCreateData -> ShowS)
-> (InviteCreateData -> String)
-> ([InviteCreateData] -> ShowS)
-> Show InviteCreateData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InviteCreateData -> ShowS
showsPrec :: Int -> InviteCreateData -> ShowS
$cshow :: InviteCreateData -> String
show :: InviteCreateData -> String
$cshowList :: [InviteCreateData] -> ShowS
showList :: [InviteCreateData] -> ShowS
Show)

instance Aeson.FromJSON InviteCreateData where
  parseJSON :: Value -> Parser InviteCreateData
parseJSON = String
-> (Object -> Parser InviteCreateData)
-> Value
-> Parser InviteCreateData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"InviteCreateData" ((Object -> Parser InviteCreateData)
 -> Value -> Parser InviteCreateData)
-> (Object -> Parser InviteCreateData)
-> Value
-> Parser InviteCreateData
forall a b. (a -> b) -> a -> b
$ \Object
v -> do
    let inviter :: Parser (Maybe (Snowflake User))
inviter = (Object
v Object -> Key -> Parser (Maybe Object)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"inviter") Parser (Maybe Object)
-> (Maybe Object -> Parser (Maybe (Snowflake User)))
-> Parser (Maybe (Snowflake User))
forall a b. Parser a -> (a -> Parser b) -> Parser b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Object -> Parser (Snowflake User))
-> Maybe Object -> Parser (Maybe (Snowflake User))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse (Object -> Key -> Parser (Snowflake User)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id")
        targetUser :: Parser (Maybe (Snowflake User))
targetUser = (Object
v Object -> Key -> Parser (Maybe Object)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"target_user") Parser (Maybe Object)
-> (Maybe Object -> Parser (Maybe (Snowflake User)))
-> Parser (Maybe (Snowflake User))
forall a b. Parser a -> (a -> Parser b) -> Parser b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Object -> Parser (Snowflake User))
-> Maybe Object -> Parser (Maybe (Snowflake User))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse (Object -> Key -> Parser (Snowflake User)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id")

    Snowflake Channel
-> Text
-> UTCTime
-> Maybe (Snowflake Guild)
-> Maybe (Snowflake User)
-> Int
-> Int
-> Maybe (Snowflake User)
-> Maybe Integer
-> Bool
-> Integer
-> InviteCreateData
InviteCreateData
      (Snowflake Channel
 -> Text
 -> UTCTime
 -> Maybe (Snowflake Guild)
 -> Maybe (Snowflake User)
 -> Int
 -> Int
 -> Maybe (Snowflake User)
 -> Maybe Integer
 -> Bool
 -> Integer
 -> InviteCreateData)
-> Parser (Snowflake Channel)
-> Parser
     (Text
      -> UTCTime
      -> Maybe (Snowflake Guild)
      -> Maybe (Snowflake User)
      -> Int
      -> Int
      -> Maybe (Snowflake User)
      -> Maybe Integer
      -> Bool
      -> Integer
      -> InviteCreateData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Channel)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"channel_id"
      Parser
  (Text
   -> UTCTime
   -> Maybe (Snowflake Guild)
   -> Maybe (Snowflake User)
   -> Int
   -> Int
   -> Maybe (Snowflake User)
   -> Maybe Integer
   -> Bool
   -> Integer
   -> InviteCreateData)
-> Parser Text
-> Parser
     (UTCTime
      -> Maybe (Snowflake Guild)
      -> Maybe (Snowflake User)
      -> Int
      -> Int
      -> Maybe (Snowflake User)
      -> Maybe Integer
      -> Bool
      -> Integer
      -> InviteCreateData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"code"
      Parser
  (UTCTime
   -> Maybe (Snowflake Guild)
   -> Maybe (Snowflake User)
   -> Int
   -> Int
   -> Maybe (Snowflake User)
   -> Maybe Integer
   -> Bool
   -> Integer
   -> InviteCreateData)
-> Parser UTCTime
-> Parser
     (Maybe (Snowflake Guild)
      -> Maybe (Snowflake User)
      -> Int
      -> Int
      -> Maybe (Snowflake User)
      -> Maybe Integer
      -> Bool
      -> Integer
      -> InviteCreateData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser UTCTime
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"created_at"
      Parser
  (Maybe (Snowflake Guild)
   -> Maybe (Snowflake User)
   -> Int
   -> Int
   -> Maybe (Snowflake User)
   -> Maybe Integer
   -> Bool
   -> Integer
   -> InviteCreateData)
-> Parser (Maybe (Snowflake Guild))
-> Parser
     (Maybe (Snowflake User)
      -> Int
      -> Int
      -> Maybe (Snowflake User)
      -> Maybe Integer
      -> Bool
      -> Integer
      -> InviteCreateData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe (Snowflake Guild))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"guild_id"
      Parser
  (Maybe (Snowflake User)
   -> Int
   -> Int
   -> Maybe (Snowflake User)
   -> Maybe Integer
   -> Bool
   -> Integer
   -> InviteCreateData)
-> Parser (Maybe (Snowflake User))
-> Parser
     (Int
      -> Int
      -> Maybe (Snowflake User)
      -> Maybe Integer
      -> Bool
      -> Integer
      -> InviteCreateData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe (Snowflake User))
inviter
      Parser
  (Int
   -> Int
   -> Maybe (Snowflake User)
   -> Maybe Integer
   -> Bool
   -> Integer
   -> InviteCreateData)
-> Parser Int
-> Parser
     (Int
      -> Maybe (Snowflake User)
      -> Maybe Integer
      -> Bool
      -> Integer
      -> InviteCreateData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"max_age"
      Parser
  (Int
   -> Maybe (Snowflake User)
   -> Maybe Integer
   -> Bool
   -> Integer
   -> InviteCreateData)
-> Parser Int
-> Parser
     (Maybe (Snowflake User)
      -> Maybe Integer -> Bool -> Integer -> InviteCreateData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"max_uses"
      Parser
  (Maybe (Snowflake User)
   -> Maybe Integer -> Bool -> Integer -> InviteCreateData)
-> Parser (Maybe (Snowflake User))
-> Parser (Maybe Integer -> Bool -> Integer -> InviteCreateData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe (Snowflake User))
targetUser
      Parser (Maybe Integer -> Bool -> Integer -> InviteCreateData)
-> Parser (Maybe Integer)
-> Parser (Bool -> Integer -> InviteCreateData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"target_user_type"
      Parser (Bool -> Integer -> InviteCreateData)
-> Parser Bool -> Parser (Integer -> InviteCreateData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Bool
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"temporary"
      Parser (Integer -> InviteCreateData)
-> Parser Integer -> Parser InviteCreateData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Integer
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"uses"

data InviteDeleteData = InviteDeleteData
  { InviteDeleteData -> Snowflake Channel
channelID :: Snowflake Channel
  , InviteDeleteData -> Maybe (Snowflake Guild)
guildID :: Maybe (Snowflake Guild)
  , InviteDeleteData -> Text
code :: Text
  }
  deriving (Int -> InviteDeleteData -> ShowS
[InviteDeleteData] -> ShowS
InviteDeleteData -> String
(Int -> InviteDeleteData -> ShowS)
-> (InviteDeleteData -> String)
-> ([InviteDeleteData] -> ShowS)
-> Show InviteDeleteData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InviteDeleteData -> ShowS
showsPrec :: Int -> InviteDeleteData -> ShowS
$cshow :: InviteDeleteData -> String
show :: InviteDeleteData -> String
$cshowList :: [InviteDeleteData] -> ShowS
showList :: [InviteDeleteData] -> ShowS
Show)

instance Aeson.FromJSON InviteDeleteData where
  parseJSON :: Value -> Parser InviteDeleteData
parseJSON = String
-> (Object -> Parser InviteDeleteData)
-> Value
-> Parser InviteDeleteData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"InviteDeleteData" ((Object -> Parser InviteDeleteData)
 -> Value -> Parser InviteDeleteData)
-> (Object -> Parser InviteDeleteData)
-> Value
-> Parser InviteDeleteData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Channel
-> Maybe (Snowflake Guild) -> Text -> InviteDeleteData
InviteDeleteData
      (Snowflake Channel
 -> Maybe (Snowflake Guild) -> Text -> InviteDeleteData)
-> Parser (Snowflake Channel)
-> Parser (Maybe (Snowflake Guild) -> Text -> InviteDeleteData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Channel)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"channel_id"
      Parser (Maybe (Snowflake Guild) -> Text -> InviteDeleteData)
-> Parser (Maybe (Snowflake Guild))
-> Parser (Text -> InviteDeleteData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe (Snowflake Guild))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"guild_id"
      Parser (Text -> InviteDeleteData)
-> Parser Text -> Parser InviteDeleteData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"code"

data MessageDeleteData = MessageDeleteData
  { MessageDeleteData -> Snowflake Message
id :: Snowflake Message
  , MessageDeleteData -> Snowflake Channel
channelID :: Snowflake Channel
  , MessageDeleteData -> Snowflake Guild
guildID :: Snowflake Guild
  }
  deriving (Int -> MessageDeleteData -> ShowS
[MessageDeleteData] -> ShowS
MessageDeleteData -> String
(Int -> MessageDeleteData -> ShowS)
-> (MessageDeleteData -> String)
-> ([MessageDeleteData] -> ShowS)
-> Show MessageDeleteData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MessageDeleteData -> ShowS
showsPrec :: Int -> MessageDeleteData -> ShowS
$cshow :: MessageDeleteData -> String
show :: MessageDeleteData -> String
$cshowList :: [MessageDeleteData] -> ShowS
showList :: [MessageDeleteData] -> ShowS
Show)

instance Aeson.FromJSON MessageDeleteData where
  parseJSON :: Value -> Parser MessageDeleteData
parseJSON = String
-> (Object -> Parser MessageDeleteData)
-> Value
-> Parser MessageDeleteData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"MessageDeleteData" ((Object -> Parser MessageDeleteData)
 -> Value -> Parser MessageDeleteData)
-> (Object -> Parser MessageDeleteData)
-> Value
-> Parser MessageDeleteData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Message
-> Snowflake Channel -> Snowflake Guild -> MessageDeleteData
MessageDeleteData
      (Snowflake Message
 -> Snowflake Channel -> Snowflake Guild -> MessageDeleteData)
-> Parser (Snowflake Message)
-> Parser
     (Snowflake Channel -> Snowflake Guild -> MessageDeleteData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Message)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id"
      Parser (Snowflake Channel -> Snowflake Guild -> MessageDeleteData)
-> Parser (Snowflake Channel)
-> Parser (Snowflake Guild -> MessageDeleteData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Snowflake Channel)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"channel_id"
      Parser (Snowflake Guild -> MessageDeleteData)
-> Parser (Snowflake Guild) -> Parser MessageDeleteData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Snowflake Guild)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id"

data MessageDeleteBulkData = MessageDeleteBulkData
  { MessageDeleteBulkData -> Snowflake Guild
guildID :: Snowflake Guild
  , MessageDeleteBulkData -> Snowflake Channel
channelID :: Snowflake Channel
  , MessageDeleteBulkData -> [Snowflake Message]
ids :: [Snowflake Message]
  }
  deriving (Int -> MessageDeleteBulkData -> ShowS
[MessageDeleteBulkData] -> ShowS
MessageDeleteBulkData -> String
(Int -> MessageDeleteBulkData -> ShowS)
-> (MessageDeleteBulkData -> String)
-> ([MessageDeleteBulkData] -> ShowS)
-> Show MessageDeleteBulkData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MessageDeleteBulkData -> ShowS
showsPrec :: Int -> MessageDeleteBulkData -> ShowS
$cshow :: MessageDeleteBulkData -> String
show :: MessageDeleteBulkData -> String
$cshowList :: [MessageDeleteBulkData] -> ShowS
showList :: [MessageDeleteBulkData] -> ShowS
Show)

instance Aeson.FromJSON MessageDeleteBulkData where
  parseJSON :: Value -> Parser MessageDeleteBulkData
parseJSON = String
-> (Object -> Parser MessageDeleteBulkData)
-> Value
-> Parser MessageDeleteBulkData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"MessageDeleteBulkData" ((Object -> Parser MessageDeleteBulkData)
 -> Value -> Parser MessageDeleteBulkData)
-> (Object -> Parser MessageDeleteBulkData)
-> Value
-> Parser MessageDeleteBulkData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Guild
-> Snowflake Channel
-> [Snowflake Message]
-> MessageDeleteBulkData
MessageDeleteBulkData
      (Snowflake Guild
 -> Snowflake Channel
 -> [Snowflake Message]
 -> MessageDeleteBulkData)
-> Parser (Snowflake Guild)
-> Parser
     (Snowflake Channel -> [Snowflake Message] -> MessageDeleteBulkData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Guild)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id"
      Parser
  (Snowflake Channel -> [Snowflake Message] -> MessageDeleteBulkData)
-> Parser (Snowflake Channel)
-> Parser ([Snowflake Message] -> MessageDeleteBulkData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Snowflake Channel)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"channel_id"
      Parser ([Snowflake Message] -> MessageDeleteBulkData)
-> Parser [Snowflake Message] -> Parser MessageDeleteBulkData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser [Snowflake Message]
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"ids"

data MessageReactionRemoveAllData = MessageReactionRemoveAllData
  { MessageReactionRemoveAllData -> Snowflake Channel
channelID :: Snowflake Channel
  , MessageReactionRemoveAllData -> Snowflake Message
messageID :: Snowflake Message
  , MessageReactionRemoveAllData -> Maybe (Snowflake Guild)
guildID :: Maybe (Snowflake Guild)
  }
  deriving (Int -> MessageReactionRemoveAllData -> ShowS
[MessageReactionRemoveAllData] -> ShowS
MessageReactionRemoveAllData -> String
(Int -> MessageReactionRemoveAllData -> ShowS)
-> (MessageReactionRemoveAllData -> String)
-> ([MessageReactionRemoveAllData] -> ShowS)
-> Show MessageReactionRemoveAllData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MessageReactionRemoveAllData -> ShowS
showsPrec :: Int -> MessageReactionRemoveAllData -> ShowS
$cshow :: MessageReactionRemoveAllData -> String
show :: MessageReactionRemoveAllData -> String
$cshowList :: [MessageReactionRemoveAllData] -> ShowS
showList :: [MessageReactionRemoveAllData] -> ShowS
Show)

instance Aeson.FromJSON MessageReactionRemoveAllData where
  parseJSON :: Value -> Parser MessageReactionRemoveAllData
parseJSON = String
-> (Object -> Parser MessageReactionRemoveAllData)
-> Value
-> Parser MessageReactionRemoveAllData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"MessageReactionRemoveAllData" ((Object -> Parser MessageReactionRemoveAllData)
 -> Value -> Parser MessageReactionRemoveAllData)
-> (Object -> Parser MessageReactionRemoveAllData)
-> Value
-> Parser MessageReactionRemoveAllData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Channel
-> Snowflake Message
-> Maybe (Snowflake Guild)
-> MessageReactionRemoveAllData
MessageReactionRemoveAllData
      (Snowflake Channel
 -> Snowflake Message
 -> Maybe (Snowflake Guild)
 -> MessageReactionRemoveAllData)
-> Parser (Snowflake Channel)
-> Parser
     (Snowflake Message
      -> Maybe (Snowflake Guild) -> MessageReactionRemoveAllData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Channel)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"channel_id"
      Parser
  (Snowflake Message
   -> Maybe (Snowflake Guild) -> MessageReactionRemoveAllData)
-> Parser (Snowflake Message)
-> Parser (Maybe (Snowflake Guild) -> MessageReactionRemoveAllData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Snowflake Message)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"message_id"
      Parser (Maybe (Snowflake Guild) -> MessageReactionRemoveAllData)
-> Parser (Maybe (Snowflake Guild))
-> Parser MessageReactionRemoveAllData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe (Snowflake Guild))
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id"

data PresenceUpdateData = PresenceUpdateData
  { PresenceUpdateData -> Snowflake User
userID :: Snowflake User
  , PresenceUpdateData -> Presence
presence :: Presence
  }
  deriving (Int -> PresenceUpdateData -> ShowS
[PresenceUpdateData] -> ShowS
PresenceUpdateData -> String
(Int -> PresenceUpdateData -> ShowS)
-> (PresenceUpdateData -> String)
-> ([PresenceUpdateData] -> ShowS)
-> Show PresenceUpdateData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PresenceUpdateData -> ShowS
showsPrec :: Int -> PresenceUpdateData -> ShowS
$cshow :: PresenceUpdateData -> String
show :: PresenceUpdateData -> String
$cshowList :: [PresenceUpdateData] -> ShowS
showList :: [PresenceUpdateData] -> ShowS
Show)

instance Aeson.FromJSON PresenceUpdateData where
  parseJSON :: Value -> Parser PresenceUpdateData
parseJSON = String
-> (Object -> Parser PresenceUpdateData)
-> Value
-> Parser PresenceUpdateData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"PresenceUpdate" ((Object -> Parser PresenceUpdateData)
 -> Value -> Parser PresenceUpdateData)
-> (Object -> Parser PresenceUpdateData)
-> Value
-> Parser PresenceUpdateData
forall a b. (a -> b) -> a -> b
$ \Object
v -> do
    Snowflake User
user <- (Object
v Object -> Key -> Parser Object
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"user") Parser Object
-> (Object -> Parser (Snowflake User)) -> Parser (Snowflake User)
forall a b. Parser a -> (a -> Parser b) -> Parser b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (Object -> Key -> Parser (Snowflake User)
forall a. FromJSON a => Object -> Key -> Parser a
Aeson..: Key
"id")
    Presence
presence <- Value -> Parser Presence
forall a. FromJSON a => Value -> Parser a
Aeson.parseJSON (Value -> Parser Presence) -> Value -> Parser Presence
forall a b. (a -> b) -> a -> b
$ Object -> Value
Aeson.Object Object
v
    PresenceUpdateData -> Parser PresenceUpdateData
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PresenceUpdateData -> Parser PresenceUpdateData)
-> PresenceUpdateData -> Parser PresenceUpdateData
forall a b. (a -> b) -> a -> b
$ Snowflake User -> Presence -> PresenceUpdateData
PresenceUpdateData Snowflake User
user Presence
presence

data TypingStartData = TypingStartData
  { TypingStartData -> Snowflake Channel
channelID :: Snowflake Channel
  , TypingStartData -> Maybe (Snowflake Guild)
guildID :: Maybe (Snowflake Guild)
  , TypingStartData -> Snowflake User
userID :: Snowflake User
  , TypingStartData -> UnixTimestamp
timestamp :: UnixTimestamp
  }
  deriving (Int -> TypingStartData -> ShowS
[TypingStartData] -> ShowS
TypingStartData -> String
(Int -> TypingStartData -> ShowS)
-> (TypingStartData -> String)
-> ([TypingStartData] -> ShowS)
-> Show TypingStartData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TypingStartData -> ShowS
showsPrec :: Int -> TypingStartData -> ShowS
$cshow :: TypingStartData -> String
show :: TypingStartData -> String
$cshowList :: [TypingStartData] -> ShowS
showList :: [TypingStartData] -> ShowS
Show)

instance Aeson.FromJSON TypingStartData where
  parseJSON :: Value -> Parser TypingStartData
parseJSON = String
-> (Object -> Parser TypingStartData)
-> Value
-> Parser TypingStartData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"TypingStartData" ((Object -> Parser TypingStartData)
 -> Value -> Parser TypingStartData)
-> (Object -> Parser TypingStartData)
-> Value
-> Parser TypingStartData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake Channel
-> Maybe (Snowflake Guild)
-> Snowflake User
-> UnixTimestamp
-> TypingStartData
TypingStartData
      (Snowflake Channel
 -> Maybe (Snowflake Guild)
 -> Snowflake User
 -> UnixTimestamp
 -> TypingStartData)
-> Parser (Snowflake Channel)
-> Parser
     (Maybe (Snowflake Guild)
      -> Snowflake User -> UnixTimestamp -> TypingStartData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake Channel)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"channel_id"
      Parser
  (Maybe (Snowflake Guild)
   -> Snowflake User -> UnixTimestamp -> TypingStartData)
-> Parser (Maybe (Snowflake Guild))
-> Parser (Snowflake User -> UnixTimestamp -> TypingStartData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe (Snowflake Guild))
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id"
      Parser (Snowflake User -> UnixTimestamp -> TypingStartData)
-> Parser (Snowflake User)
-> Parser (UnixTimestamp -> TypingStartData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Snowflake User)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"user_id"
      Parser (UnixTimestamp -> TypingStartData)
-> Parser UnixTimestamp -> Parser TypingStartData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser UnixTimestamp
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"timestamp"

newtype VoiceServerUpdateData = VoiceServerUpdateData Aeson.Value
  deriving stock (Int -> VoiceServerUpdateData -> ShowS
[VoiceServerUpdateData] -> ShowS
VoiceServerUpdateData -> String
(Int -> VoiceServerUpdateData -> ShowS)
-> (VoiceServerUpdateData -> String)
-> ([VoiceServerUpdateData] -> ShowS)
-> Show VoiceServerUpdateData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VoiceServerUpdateData -> ShowS
showsPrec :: Int -> VoiceServerUpdateData -> ShowS
$cshow :: VoiceServerUpdateData -> String
show :: VoiceServerUpdateData -> String
$cshowList :: [VoiceServerUpdateData] -> ShowS
showList :: [VoiceServerUpdateData] -> ShowS
Show)
  deriving newtype ([VoiceServerUpdateData] -> Value
[VoiceServerUpdateData] -> Encoding
VoiceServerUpdateData -> Value
VoiceServerUpdateData -> Encoding
(VoiceServerUpdateData -> Value)
-> (VoiceServerUpdateData -> Encoding)
-> ([VoiceServerUpdateData] -> Value)
-> ([VoiceServerUpdateData] -> Encoding)
-> ToJSON VoiceServerUpdateData
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: VoiceServerUpdateData -> Value
toJSON :: VoiceServerUpdateData -> Value
$ctoEncoding :: VoiceServerUpdateData -> Encoding
toEncoding :: VoiceServerUpdateData -> Encoding
$ctoJSONList :: [VoiceServerUpdateData] -> Value
toJSONList :: [VoiceServerUpdateData] -> Value
$ctoEncodingList :: [VoiceServerUpdateData] -> Encoding
toEncodingList :: [VoiceServerUpdateData] -> Encoding
Aeson.ToJSON, Value -> Parser [VoiceServerUpdateData]
Value -> Parser VoiceServerUpdateData
(Value -> Parser VoiceServerUpdateData)
-> (Value -> Parser [VoiceServerUpdateData])
-> FromJSON VoiceServerUpdateData
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser VoiceServerUpdateData
parseJSON :: Value -> Parser VoiceServerUpdateData
$cparseJSONList :: Value -> Parser [VoiceServerUpdateData]
parseJSONList :: Value -> Parser [VoiceServerUpdateData]
Aeson.FromJSON)

newtype WebhooksUpdateData = WebhooksUpdateData Aeson.Value
  deriving stock (Int -> WebhooksUpdateData -> ShowS
[WebhooksUpdateData] -> ShowS
WebhooksUpdateData -> String
(Int -> WebhooksUpdateData -> ShowS)
-> (WebhooksUpdateData -> String)
-> ([WebhooksUpdateData] -> ShowS)
-> Show WebhooksUpdateData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> WebhooksUpdateData -> ShowS
showsPrec :: Int -> WebhooksUpdateData -> ShowS
$cshow :: WebhooksUpdateData -> String
show :: WebhooksUpdateData -> String
$cshowList :: [WebhooksUpdateData] -> ShowS
showList :: [WebhooksUpdateData] -> ShowS
Show)
  deriving newtype ([WebhooksUpdateData] -> Value
[WebhooksUpdateData] -> Encoding
WebhooksUpdateData -> Value
WebhooksUpdateData -> Encoding
(WebhooksUpdateData -> Value)
-> (WebhooksUpdateData -> Encoding)
-> ([WebhooksUpdateData] -> Value)
-> ([WebhooksUpdateData] -> Encoding)
-> ToJSON WebhooksUpdateData
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: WebhooksUpdateData -> Value
toJSON :: WebhooksUpdateData -> Value
$ctoEncoding :: WebhooksUpdateData -> Encoding
toEncoding :: WebhooksUpdateData -> Encoding
$ctoJSONList :: [WebhooksUpdateData] -> Value
toJSONList :: [WebhooksUpdateData] -> Value
$ctoEncodingList :: [WebhooksUpdateData] -> Encoding
toEncodingList :: [WebhooksUpdateData] -> Encoding
Aeson.ToJSON, Value -> Parser [WebhooksUpdateData]
Value -> Parser WebhooksUpdateData
(Value -> Parser WebhooksUpdateData)
-> (Value -> Parser [WebhooksUpdateData])
-> FromJSON WebhooksUpdateData
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
$cparseJSON :: Value -> Parser WebhooksUpdateData
parseJSON :: Value -> Parser WebhooksUpdateData
$cparseJSONList :: Value -> Parser [WebhooksUpdateData]
parseJSONList :: Value -> Parser [WebhooksUpdateData]
Aeson.FromJSON)

data ReactionEvtData = ReactionEvtData
  { ReactionEvtData -> Snowflake User
userID :: Snowflake User
  , ReactionEvtData -> Snowflake Channel
channelID :: Snowflake Channel
  , ReactionEvtData -> Snowflake Message
messageID :: Snowflake Message
  , ReactionEvtData -> Maybe (Snowflake Guild)
guildID :: Maybe (Snowflake Guild)
  , ReactionEvtData -> RawEmoji
emoji :: RawEmoji
  }
  deriving (ReactionEvtData -> ReactionEvtData -> Bool
(ReactionEvtData -> ReactionEvtData -> Bool)
-> (ReactionEvtData -> ReactionEvtData -> Bool)
-> Eq ReactionEvtData
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReactionEvtData -> ReactionEvtData -> Bool
== :: ReactionEvtData -> ReactionEvtData -> Bool
$c/= :: ReactionEvtData -> ReactionEvtData -> Bool
/= :: ReactionEvtData -> ReactionEvtData -> Bool
Eq, Int -> ReactionEvtData -> ShowS
[ReactionEvtData] -> ShowS
ReactionEvtData -> String
(Int -> ReactionEvtData -> ShowS)
-> (ReactionEvtData -> String)
-> ([ReactionEvtData] -> ShowS)
-> Show ReactionEvtData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReactionEvtData -> ShowS
showsPrec :: Int -> ReactionEvtData -> ShowS
$cshow :: ReactionEvtData -> String
show :: ReactionEvtData -> String
$cshowList :: [ReactionEvtData] -> ShowS
showList :: [ReactionEvtData] -> ShowS
Show)
  deriving (HasID User) via HasIDField "userID" ReactionEvtData
  deriving (HasID Channel) via HasIDField "channelID" ReactionEvtData
  deriving (HasID Message) via HasIDField "messageID" ReactionEvtData

instance Aeson.FromJSON ReactionEvtData where
  parseJSON :: Value -> Parser ReactionEvtData
parseJSON = String
-> (Object -> Parser ReactionEvtData)
-> Value
-> Parser ReactionEvtData
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"ReactionEvtData" ((Object -> Parser ReactionEvtData)
 -> Value -> Parser ReactionEvtData)
-> (Object -> Parser ReactionEvtData)
-> Value
-> Parser ReactionEvtData
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Snowflake User
-> Snowflake Channel
-> Snowflake Message
-> Maybe (Snowflake Guild)
-> RawEmoji
-> ReactionEvtData
ReactionEvtData
      (Snowflake User
 -> Snowflake Channel
 -> Snowflake Message
 -> Maybe (Snowflake Guild)
 -> RawEmoji
 -> ReactionEvtData)
-> Parser (Snowflake User)
-> Parser
     (Snowflake Channel
      -> Snowflake Message
      -> Maybe (Snowflake Guild)
      -> RawEmoji
      -> ReactionEvtData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake User)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"user_id"
      Parser
  (Snowflake Channel
   -> Snowflake Message
   -> Maybe (Snowflake Guild)
   -> RawEmoji
   -> ReactionEvtData)
-> Parser (Snowflake Channel)
-> Parser
     (Snowflake Message
      -> Maybe (Snowflake Guild) -> RawEmoji -> ReactionEvtData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Snowflake Channel)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"channel_id"
      Parser
  (Snowflake Message
   -> Maybe (Snowflake Guild) -> RawEmoji -> ReactionEvtData)
-> Parser (Snowflake Message)
-> Parser (Maybe (Snowflake Guild) -> RawEmoji -> ReactionEvtData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Snowflake Message)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"message_id"
      Parser (Maybe (Snowflake Guild) -> RawEmoji -> ReactionEvtData)
-> Parser (Maybe (Snowflake Guild))
-> Parser (RawEmoji -> ReactionEvtData)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe (Snowflake Guild))
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"guild_id"
      Parser (RawEmoji -> ReactionEvtData)
-> Parser RawEmoji -> Parser ReactionEvtData
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser RawEmoji
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"emoji"

$(makeFieldLabelsNoPrefix ''ReadyData)
$(makeFieldLabelsNoPrefix ''ReactionEvtData)