{-# 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 qualified Data.Aeson 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
  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
showList :: [DispatchData] -> ShowS
$cshowList :: [DispatchData] -> ShowS
show :: DispatchData -> String
$cshow :: DispatchData -> String
showsPrec :: Int -> DispatchData -> ShowS
$cshowsPrec :: Int -> 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
$cto :: forall x. Rep DispatchData x -> DispatchData
$cfrom :: forall x. DispatchData -> Rep DispatchData x
Generic, DispatchData -> String
(DispatchData -> String) -> CtorName DispatchData
forall a. (a -> String) -> CtorName a
ctorName :: DispatchData -> String
$cctorName :: 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
showList :: [ReadyData] -> ShowS
$cshowList :: [ReadyData] -> ShowS
show :: ReadyData -> String
$cshow :: ReadyData -> String
showsPrec :: Int -> ReadyData -> ShowS
$cshowsPrec :: Int -> 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 (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 (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 (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
showList :: [ChannelPinsUpdateData] -> ShowS
$cshowList :: [ChannelPinsUpdateData] -> ShowS
show :: ChannelPinsUpdateData -> String
$cshow :: ChannelPinsUpdateData -> String
showsPrec :: Int -> ChannelPinsUpdateData -> ShowS
$cshowsPrec :: Int -> 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 (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
showList :: [GuildEmojisUpdateData] -> ShowS
$cshowList :: [GuildEmojisUpdateData] -> ShowS
show :: GuildEmojisUpdateData -> String
$cshow :: GuildEmojisUpdateData -> String
showsPrec :: Int -> GuildEmojisUpdateData -> ShowS
$cshowsPrec :: Int -> 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 (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
showList :: [GuildIntegrationsUpdateData] -> ShowS
$cshowList :: [GuildIntegrationsUpdateData] -> ShowS
show :: GuildIntegrationsUpdateData -> String
$cshow :: GuildIntegrationsUpdateData -> String
showsPrec :: Int -> GuildIntegrationsUpdateData -> ShowS
$cshowsPrec :: Int -> 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
showList :: [GuildMemberRemoveData] -> ShowS
$cshowList :: [GuildMemberRemoveData] -> ShowS
show :: GuildMemberRemoveData -> String
$cshow :: GuildMemberRemoveData -> String
showsPrec :: Int -> GuildMemberRemoveData -> ShowS
$cshowsPrec :: Int -> 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 (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
showList :: [GuildMemberUpdateData] -> ShowS
$cshowList :: [GuildMemberUpdateData] -> ShowS
show :: GuildMemberUpdateData -> String
$cshow :: GuildMemberUpdateData -> String
showsPrec :: Int -> GuildMemberUpdateData -> ShowS
$cshowsPrec :: Int -> 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 (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 (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 (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
showList :: [GuildMembersChunkData] -> ShowS
$cshowList :: [GuildMembersChunkData] -> ShowS
show :: GuildMembersChunkData -> String
$cshow :: GuildMembersChunkData -> String
showsPrec :: Int -> GuildMembersChunkData -> ShowS
$cshowsPrec :: Int -> 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)
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 (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
showList :: [GuildRoleData] -> ShowS
$cshowList :: [GuildRoleData] -> ShowS
show :: GuildRoleData -> String
$cshow :: GuildRoleData -> String
showsPrec :: Int -> GuildRoleData -> ShowS
$cshowsPrec :: Int -> 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 (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
showList :: [GuildRoleDeleteData] -> ShowS
$cshowList :: [GuildRoleDeleteData] -> ShowS
show :: GuildRoleDeleteData -> String
$cshow :: GuildRoleDeleteData -> String
showsPrec :: Int -> GuildRoleDeleteData -> ShowS
$cshowsPrec :: Int -> 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 (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
showList :: [InviteCreateData] -> ShowS
$cshowList :: [InviteCreateData] -> ShowS
show :: InviteCreateData -> String
$cshow :: InviteCreateData -> String
showsPrec :: Int -> InviteCreateData -> ShowS
$cshowsPrec :: Int -> 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 (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)
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 (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)
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 (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 (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 (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 (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 (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 (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 (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 (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 (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 (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
showList :: [InviteDeleteData] -> ShowS
$cshowList :: [InviteDeleteData] -> ShowS
show :: InviteDeleteData -> String
$cshow :: InviteDeleteData -> String
showsPrec :: Int -> InviteDeleteData -> ShowS
$cshowsPrec :: Int -> 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 (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 (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
showList :: [MessageDeleteData] -> ShowS
$cshowList :: [MessageDeleteData] -> ShowS
show :: MessageDeleteData -> String
$cshow :: MessageDeleteData -> String
showsPrec :: Int -> MessageDeleteData -> ShowS
$cshowsPrec :: Int -> 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 (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 (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
showList :: [MessageDeleteBulkData] -> ShowS
$cshowList :: [MessageDeleteBulkData] -> ShowS
show :: MessageDeleteBulkData -> String
$cshow :: MessageDeleteBulkData -> String
showsPrec :: Int -> MessageDeleteBulkData -> ShowS
$cshowsPrec :: Int -> 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 (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 (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
showList :: [MessageReactionRemoveAllData] -> ShowS
$cshowList :: [MessageReactionRemoveAllData] -> ShowS
show :: MessageReactionRemoveAllData -> String
$cshow :: MessageReactionRemoveAllData -> String
showsPrec :: Int -> MessageReactionRemoveAllData -> ShowS
$cshowsPrec :: Int -> 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 (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 (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
showList :: [PresenceUpdateData] -> ShowS
$cshowList :: [PresenceUpdateData] -> ShowS
show :: PresenceUpdateData -> String
$cshow :: PresenceUpdateData -> String
showsPrec :: Int -> PresenceUpdateData -> ShowS
$cshowsPrec :: Int -> 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 (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 (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
showList :: [TypingStartData] -> ShowS
$cshowList :: [TypingStartData] -> ShowS
show :: TypingStartData -> String
$cshow :: TypingStartData -> String
showsPrec :: Int -> TypingStartData -> ShowS
$cshowsPrec :: Int -> 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 (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 (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 (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
showList :: [VoiceServerUpdateData] -> ShowS
$cshowList :: [VoiceServerUpdateData] -> ShowS
show :: VoiceServerUpdateData -> String
$cshow :: VoiceServerUpdateData -> String
showsPrec :: Int -> VoiceServerUpdateData -> ShowS
$cshowsPrec :: Int -> VoiceServerUpdateData -> ShowS
Show)
  deriving newtype ([VoiceServerUpdateData] -> Encoding
[VoiceServerUpdateData] -> Value
VoiceServerUpdateData -> Encoding
VoiceServerUpdateData -> Value
(VoiceServerUpdateData -> Value)
-> (VoiceServerUpdateData -> Encoding)
-> ([VoiceServerUpdateData] -> Value)
-> ([VoiceServerUpdateData] -> Encoding)
-> ToJSON VoiceServerUpdateData
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [VoiceServerUpdateData] -> Encoding
$ctoEncodingList :: [VoiceServerUpdateData] -> Encoding
toJSONList :: [VoiceServerUpdateData] -> Value
$ctoJSONList :: [VoiceServerUpdateData] -> Value
toEncoding :: VoiceServerUpdateData -> Encoding
$ctoEncoding :: VoiceServerUpdateData -> Encoding
toJSON :: VoiceServerUpdateData -> Value
$ctoJSON :: VoiceServerUpdateData -> Value
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
parseJSONList :: Value -> Parser [VoiceServerUpdateData]
$cparseJSONList :: Value -> Parser [VoiceServerUpdateData]
parseJSON :: Value -> Parser VoiceServerUpdateData
$cparseJSON :: 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
showList :: [WebhooksUpdateData] -> ShowS
$cshowList :: [WebhooksUpdateData] -> ShowS
show :: WebhooksUpdateData -> String
$cshow :: WebhooksUpdateData -> String
showsPrec :: Int -> WebhooksUpdateData -> ShowS
$cshowsPrec :: Int -> WebhooksUpdateData -> ShowS
Show)
  deriving newtype ([WebhooksUpdateData] -> Encoding
[WebhooksUpdateData] -> Value
WebhooksUpdateData -> Encoding
WebhooksUpdateData -> Value
(WebhooksUpdateData -> Value)
-> (WebhooksUpdateData -> Encoding)
-> ([WebhooksUpdateData] -> Value)
-> ([WebhooksUpdateData] -> Encoding)
-> ToJSON WebhooksUpdateData
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [WebhooksUpdateData] -> Encoding
$ctoEncodingList :: [WebhooksUpdateData] -> Encoding
toJSONList :: [WebhooksUpdateData] -> Value
$ctoJSONList :: [WebhooksUpdateData] -> Value
toEncoding :: WebhooksUpdateData -> Encoding
$ctoEncoding :: WebhooksUpdateData -> Encoding
toJSON :: WebhooksUpdateData -> Value
$ctoJSON :: WebhooksUpdateData -> Value
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
parseJSONList :: Value -> Parser [WebhooksUpdateData]
$cparseJSONList :: Value -> Parser [WebhooksUpdateData]
parseJSON :: Value -> Parser WebhooksUpdateData
$cparseJSON :: 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
/= :: ReactionEvtData -> ReactionEvtData -> Bool
$c/= :: ReactionEvtData -> ReactionEvtData -> Bool
== :: ReactionEvtData -> ReactionEvtData -> Bool
$c== :: 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
showList :: [ReactionEvtData] -> ShowS
$cshowList :: [ReactionEvtData] -> ShowS
show :: ReactionEvtData -> String
$cshow :: ReactionEvtData -> String
showsPrec :: Int -> ReactionEvtData -> ShowS
$cshowsPrec :: Int -> 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 (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 (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 (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 (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)