-- | A DM channel with a single person
module Calamity.Types.Model.Channel.DM (DMChannel (..)) where

import Calamity.Internal.AesonThings
import Calamity.Internal.OverriddenVia
import Calamity.Internal.Utils
import {-# SOURCE #-} Calamity.Types.Model.Channel
import {-# SOURCE #-} Calamity.Types.Model.Channel.Message
import Calamity.Types.Model.User
import Calamity.Types.Snowflake
import Control.DeepSeq (NFData)
import Data.Aeson
import Data.Time
import Data.Vector.Unboxing (Vector)
import GHC.Generics
import TextShow
import qualified TextShow.Generic as TSG

data DMChannel' = DMChannel'
  { DMChannel' -> Snowflake DMChannel
id :: Snowflake DMChannel
  , DMChannel' -> Maybe (Snowflake Message)
lastMessageID :: Maybe (Snowflake Message)
  , DMChannel' -> Maybe (CalamityFromStringShow UTCTime)
lastPinTimestamp :: Maybe (CalamityFromStringShow UTCTime)
  , DMChannel' -> AesonVector (Snowflake User)
recipients :: AesonVector (Snowflake User)
  }
  deriving ((forall x. DMChannel' -> Rep DMChannel' x)
-> (forall x. Rep DMChannel' x -> DMChannel') -> Generic DMChannel'
forall x. Rep DMChannel' x -> DMChannel'
forall x. DMChannel' -> Rep DMChannel' x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DMChannel' x -> DMChannel'
$cfrom :: forall x. DMChannel' -> Rep DMChannel' x
Generic)
  deriving (Int -> DMChannel' -> Builder
Int -> DMChannel' -> Text
Int -> DMChannel' -> Text
[DMChannel'] -> Builder
[DMChannel'] -> Text
[DMChannel'] -> Text
DMChannel' -> Builder
DMChannel' -> Text
DMChannel' -> Text
(Int -> DMChannel' -> Builder)
-> (DMChannel' -> Builder)
-> ([DMChannel'] -> Builder)
-> (Int -> DMChannel' -> Text)
-> (DMChannel' -> Text)
-> ([DMChannel'] -> Text)
-> (Int -> DMChannel' -> Text)
-> (DMChannel' -> Text)
-> ([DMChannel'] -> Text)
-> TextShow DMChannel'
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 :: [DMChannel'] -> Text
$cshowtlList :: [DMChannel'] -> Text
showtl :: DMChannel' -> Text
$cshowtl :: DMChannel' -> Text
showtlPrec :: Int -> DMChannel' -> Text
$cshowtlPrec :: Int -> DMChannel' -> Text
showtList :: [DMChannel'] -> Text
$cshowtList :: [DMChannel'] -> Text
showt :: DMChannel' -> Text
$cshowt :: DMChannel' -> Text
showtPrec :: Int -> DMChannel' -> Text
$cshowtPrec :: Int -> DMChannel' -> Text
showbList :: [DMChannel'] -> Builder
$cshowbList :: [DMChannel'] -> Builder
showb :: DMChannel' -> Builder
$cshowb :: DMChannel' -> Builder
showbPrec :: Int -> DMChannel' -> Builder
$cshowbPrec :: Int -> DMChannel' -> Builder
TextShow) via TSG.FromGeneric DMChannel'
  deriving
    (Value -> Parser [DMChannel']
Value -> Parser DMChannel'
(Value -> Parser DMChannel')
-> (Value -> Parser [DMChannel']) -> FromJSON DMChannel'
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [DMChannel']
$cparseJSONList :: Value -> Parser [DMChannel']
parseJSON :: Value -> Parser DMChannel'
$cparseJSON :: Value -> Parser DMChannel'
FromJSON)
    via WithSpecialCases
          '["recipients" `ExtractArrayField` "id"]
          DMChannel'

data DMChannel = DMChannel
  { DMChannel -> Snowflake DMChannel
id :: Snowflake DMChannel
  , DMChannel -> Maybe (Snowflake Message)
lastMessageID :: Maybe (Snowflake Message)
  , DMChannel -> Maybe UTCTime
lastPinTimestamp :: Maybe UTCTime
  , DMChannel -> Vector (Snowflake User)
recipients :: Vector (Snowflake User)
  }
  deriving (Int -> DMChannel -> ShowS
[DMChannel] -> ShowS
DMChannel -> String
(Int -> DMChannel -> ShowS)
-> (DMChannel -> String)
-> ([DMChannel] -> ShowS)
-> Show DMChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DMChannel] -> ShowS
$cshowList :: [DMChannel] -> ShowS
show :: DMChannel -> String
$cshow :: DMChannel -> String
showsPrec :: Int -> DMChannel -> ShowS
$cshowsPrec :: Int -> DMChannel -> ShowS
Show, DMChannel -> DMChannel -> Bool
(DMChannel -> DMChannel -> Bool)
-> (DMChannel -> DMChannel -> Bool) -> Eq DMChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DMChannel -> DMChannel -> Bool
$c/= :: DMChannel -> DMChannel -> Bool
== :: DMChannel -> DMChannel -> Bool
$c== :: DMChannel -> DMChannel -> Bool
Eq, (forall x. DMChannel -> Rep DMChannel x)
-> (forall x. Rep DMChannel x -> DMChannel) -> Generic DMChannel
forall x. Rep DMChannel x -> DMChannel
forall x. DMChannel -> Rep DMChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DMChannel x -> DMChannel
$cfrom :: forall x. DMChannel -> Rep DMChannel x
Generic, DMChannel -> ()
(DMChannel -> ()) -> NFData DMChannel
forall a. (a -> ()) -> NFData a
rnf :: DMChannel -> ()
$crnf :: DMChannel -> ()
NFData)
  deriving (Int -> DMChannel -> Builder
Int -> DMChannel -> Text
Int -> DMChannel -> Text
[DMChannel] -> Builder
[DMChannel] -> Text
[DMChannel] -> Text
DMChannel -> Builder
DMChannel -> Text
DMChannel -> Text
(Int -> DMChannel -> Builder)
-> (DMChannel -> Builder)
-> ([DMChannel] -> Builder)
-> (Int -> DMChannel -> Text)
-> (DMChannel -> Text)
-> ([DMChannel] -> Text)
-> (Int -> DMChannel -> Text)
-> (DMChannel -> Text)
-> ([DMChannel] -> Text)
-> TextShow DMChannel
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 :: [DMChannel] -> Text
$cshowtlList :: [DMChannel] -> Text
showtl :: DMChannel -> Text
$cshowtl :: DMChannel -> Text
showtlPrec :: Int -> DMChannel -> Text
$cshowtlPrec :: Int -> DMChannel -> Text
showtList :: [DMChannel] -> Text
$cshowtList :: [DMChannel] -> Text
showt :: DMChannel -> Text
$cshowt :: DMChannel -> Text
showtPrec :: Int -> DMChannel -> Text
$cshowtPrec :: Int -> DMChannel -> Text
showbList :: [DMChannel] -> Builder
$cshowbList :: [DMChannel] -> Builder
showb :: DMChannel -> Builder
$cshowb :: DMChannel -> Builder
showbPrec :: Int -> DMChannel -> Builder
$cshowbPrec :: Int -> DMChannel -> Builder
TextShow, Value -> Parser [DMChannel]
Value -> Parser DMChannel
(Value -> Parser DMChannel)
-> (Value -> Parser [DMChannel]) -> FromJSON DMChannel
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [DMChannel]
$cparseJSONList :: Value -> Parser [DMChannel]
parseJSON :: Value -> Parser DMChannel
$cparseJSON :: Value -> Parser DMChannel
FromJSON) via OverriddenVia DMChannel DMChannel'
  deriving (HasID DMChannel) via HasIDField "id" DMChannel
  deriving (HasID Channel) via HasIDFieldCoerce' "id" DMChannel