-- | Guild Members
module Calamity.Types.Model.Guild.Member
    ( Member(..) ) where

import           Calamity.Internal.AesonThings
import           Calamity.Internal.Utils          ()
import {-# SOURCE #-} Calamity.Types.Model.Guild.Guild
import           Calamity.Types.Model.Guild.Role
import           Calamity.Types.Model.User
import           Calamity.Types.Snowflake

import           Control.Lens

import           Data.Aeson
import           Data.Generics.Product.Fields
import           Data.Text.Lazy                   ( Text )
import           Data.Time
import           Data.Vector.Unboxed              ( Vector )

import           GHC.Generics

import           TextShow
import qualified TextShow.Generic                 as TSG

data Member = Member
  { Member -> User
user     :: User
  , Member -> Snowflake Guild
guildID  :: Snowflake Guild
  , Member -> Maybe Text
nick     :: Maybe Text
  , Member -> Vector (Snowflake Role)
roles    :: Vector (Snowflake Role)
  , Member -> UTCTime
joinedAt :: UTCTime
  , Member -> Bool
deaf     :: Bool
  , Member -> Bool
mute     :: Bool
  }
  deriving ( Member -> Member -> Bool
(Member -> Member -> Bool)
-> (Member -> Member -> Bool) -> Eq Member
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Member -> Member -> Bool
$c/= :: Member -> Member -> Bool
== :: Member -> Member -> Bool
$c== :: Member -> Member -> Bool
Eq, Int -> Member -> ShowS
[Member] -> ShowS
Member -> String
(Int -> Member -> ShowS)
-> (Member -> String) -> ([Member] -> ShowS) -> Show Member
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Member] -> ShowS
$cshowList :: [Member] -> ShowS
show :: Member -> String
$cshow :: Member -> String
showsPrec :: Int -> Member -> ShowS
$cshowsPrec :: Int -> Member -> ShowS
Show, (forall x. Member -> Rep Member x)
-> (forall x. Rep Member x -> Member) -> Generic Member
forall x. Rep Member x -> Member
forall x. Member -> Rep Member x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Member x -> Member
$cfrom :: forall x. Member -> Rep Member x
Generic )
  deriving ( Int -> Member -> Builder
Int -> Member -> Text
Int -> Member -> Text
[Member] -> Builder
[Member] -> Text
[Member] -> Text
Member -> Builder
Member -> Text
Member -> Text
(Int -> Member -> Builder)
-> (Member -> Builder)
-> ([Member] -> Builder)
-> (Int -> Member -> Text)
-> (Member -> Text)
-> ([Member] -> Text)
-> (Int -> Member -> Text)
-> (Member -> Text)
-> ([Member] -> Text)
-> TextShow Member
forall a.
(Int -> a -> Builder)
-> (a -> Builder)
-> ([a] -> Builder)
-> (Int -> a -> Text)
-> (a -> Text)
-> ([a] -> Text)
-> (Int -> a -> Text)
-> (a -> Text)
-> ([a] -> Text)
-> TextShow a
showtlList :: [Member] -> Text
$cshowtlList :: [Member] -> Text
showtl :: Member -> Text
$cshowtl :: Member -> Text
showtlPrec :: Int -> Member -> Text
$cshowtlPrec :: Int -> Member -> Text
showtList :: [Member] -> Text
$cshowtList :: [Member] -> Text
showt :: Member -> Text
$cshowt :: Member -> Text
showtPrec :: Int -> Member -> Text
$cshowtPrec :: Int -> Member -> Text
showbList :: [Member] -> Builder
$cshowbList :: [Member] -> Builder
showb :: Member -> Builder
$cshowb :: Member -> Builder
showbPrec :: Int -> Member -> Builder
$cshowbPrec :: Int -> Member -> Builder
TextShow ) via TSG.FromGeneric Member
  deriving ( [Member] -> Encoding
[Member] -> Value
Member -> Encoding
Member -> Value
(Member -> Value)
-> (Member -> Encoding)
-> ([Member] -> Value)
-> ([Member] -> Encoding)
-> ToJSON Member
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Member] -> Encoding
$ctoEncodingList :: [Member] -> Encoding
toJSONList :: [Member] -> Value
$ctoJSONList :: [Member] -> Value
toEncoding :: Member -> Encoding
$ctoEncoding :: Member -> Encoding
toJSON :: Member -> Value
$ctoJSON :: Member -> Value
ToJSON, Value -> Parser [Member]
Value -> Parser Member
(Value -> Parser Member)
-> (Value -> Parser [Member]) -> FromJSON Member
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Member]
$cparseJSONList :: Value -> Parser [Member]
parseJSON :: Value -> Parser Member
$cparseJSON :: Value -> Parser Member
FromJSON ) via CalamityJSON Member
  deriving ( HasID Guild ) via HasIDField "guildID" Member

instance HasID User Member where
  getID :: Member -> Snowflake User
getID = User -> Snowflake User
forall b a. HasID b a => a -> Snowflake b
getID (User -> Snowflake User)
-> (Member -> User) -> Member -> Snowflake User
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Member -> Getting User Member User -> User
forall s a. s -> Getting a s a -> a
^. forall s t a b. HasField "user" s t a b => Lens s t a b
forall (field :: Symbol) s t a b.
HasField field s t a b =>
Lens s t a b
field @"user")

instance HasID Member Member where
  getID :: Member -> Snowflake Member
getID = Snowflake User -> Snowflake Member
forall a b. Snowflake a -> Snowflake b
coerceSnowflake (Snowflake User -> Snowflake Member)
-> (Member -> Snowflake User) -> Member -> Snowflake Member
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. HasID User a => a -> Snowflake User
forall b a. HasID b a => a -> Snowflake b
getID @User