{-# LANGUAGE TemplateHaskell #-}
module Calamity.Types.Model.Channel.Guild.Voice (VoiceChannel (..)) where
import Calamity.Internal.SnowflakeMap (SnowflakeMap)
import {-# SOURCE #-} Calamity.Types.Model.Channel
import Calamity.Types.Model.Channel.Guild.Category
import {-# SOURCE #-} Calamity.Types.Model.Guild.Guild
import Calamity.Types.Model.Guild.Overwrite
import Calamity.Types.Snowflake
import Data.Aeson ((.:), (.:?))
import Data.Aeson qualified as Aeson
import Data.Text (Text)
import Optics.TH
import TextShow.TH
data VoiceChannel = VoiceChannel
{ VoiceChannel -> Snowflake VoiceChannel
id :: Snowflake VoiceChannel
, VoiceChannel -> Snowflake Guild
guildID :: Snowflake Guild
, VoiceChannel -> Int
position :: Int
, VoiceChannel -> SnowflakeMap Overwrite
permissionOverwrites :: SnowflakeMap Overwrite
, VoiceChannel -> Text
name :: Text
, VoiceChannel -> Int
bitrate :: Int
, VoiceChannel -> Int
userLimit :: Int
, VoiceChannel -> Maybe (Snowflake Category)
parentID :: Maybe (Snowflake Category)
}
deriving (Int -> VoiceChannel -> ShowS
[VoiceChannel] -> ShowS
VoiceChannel -> String
(Int -> VoiceChannel -> ShowS)
-> (VoiceChannel -> String)
-> ([VoiceChannel] -> ShowS)
-> Show VoiceChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VoiceChannel -> ShowS
showsPrec :: Int -> VoiceChannel -> ShowS
$cshow :: VoiceChannel -> String
show :: VoiceChannel -> String
$cshowList :: [VoiceChannel] -> ShowS
showList :: [VoiceChannel] -> ShowS
Show, VoiceChannel -> VoiceChannel -> Bool
(VoiceChannel -> VoiceChannel -> Bool)
-> (VoiceChannel -> VoiceChannel -> Bool) -> Eq VoiceChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VoiceChannel -> VoiceChannel -> Bool
== :: VoiceChannel -> VoiceChannel -> Bool
$c/= :: VoiceChannel -> VoiceChannel -> Bool
/= :: VoiceChannel -> VoiceChannel -> Bool
Eq)
deriving (HasID VoiceChannel) via HasIDField "id" VoiceChannel
deriving (HasID Channel) via HasIDFieldCoerce' "id" VoiceChannel
deriving (HasID Guild) via HasIDField "guildID" VoiceChannel
instance Aeson.FromJSON VoiceChannel where
parseJSON :: Value -> Parser VoiceChannel
parseJSON = String
-> (Object -> Parser VoiceChannel) -> Value -> Parser VoiceChannel
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"TextChannel" ((Object -> Parser VoiceChannel) -> Value -> Parser VoiceChannel)
-> (Object -> Parser VoiceChannel) -> Value -> Parser VoiceChannel
forall a b. (a -> b) -> a -> b
$ \Object
v ->
Snowflake VoiceChannel
-> Snowflake Guild
-> Int
-> SnowflakeMap Overwrite
-> Text
-> Int
-> Int
-> Maybe (Snowflake Category)
-> VoiceChannel
VoiceChannel
(Snowflake VoiceChannel
-> Snowflake Guild
-> Int
-> SnowflakeMap Overwrite
-> Text
-> Int
-> Int
-> Maybe (Snowflake Category)
-> VoiceChannel)
-> Parser (Snowflake VoiceChannel)
-> Parser
(Snowflake Guild
-> Int
-> SnowflakeMap Overwrite
-> Text
-> Int
-> Int
-> Maybe (Snowflake Category)
-> VoiceChannel)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Snowflake VoiceChannel)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id"
Parser
(Snowflake Guild
-> Int
-> SnowflakeMap Overwrite
-> Text
-> Int
-> Int
-> Maybe (Snowflake Category)
-> VoiceChannel)
-> Parser (Snowflake Guild)
-> Parser
(Int
-> SnowflakeMap Overwrite
-> Text
-> Int
-> Int
-> Maybe (Snowflake Category)
-> VoiceChannel)
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"
Parser
(Int
-> SnowflakeMap Overwrite
-> Text
-> Int
-> Int
-> Maybe (Snowflake Category)
-> VoiceChannel)
-> Parser Int
-> Parser
(SnowflakeMap Overwrite
-> Text
-> Int
-> Int
-> Maybe (Snowflake Category)
-> VoiceChannel)
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
"position"
Parser
(SnowflakeMap Overwrite
-> Text
-> Int
-> Int
-> Maybe (Snowflake Category)
-> VoiceChannel)
-> Parser (SnowflakeMap Overwrite)
-> Parser
(Text -> Int -> Int -> Maybe (Snowflake Category) -> VoiceChannel)
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 (SnowflakeMap Overwrite)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"permission_overwrites"
Parser
(Text -> Int -> Int -> Maybe (Snowflake Category) -> VoiceChannel)
-> Parser Text
-> Parser
(Int -> Int -> Maybe (Snowflake Category) -> VoiceChannel)
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
"name"
Parser (Int -> Int -> Maybe (Snowflake Category) -> VoiceChannel)
-> Parser Int
-> Parser (Int -> Maybe (Snowflake Category) -> VoiceChannel)
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
"bitrate"
Parser (Int -> Maybe (Snowflake Category) -> VoiceChannel)
-> Parser Int
-> Parser (Maybe (Snowflake Category) -> VoiceChannel)
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
"user_limit"
Parser (Maybe (Snowflake Category) -> VoiceChannel)
-> Parser (Maybe (Snowflake Category)) -> Parser VoiceChannel
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 Category))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"parent_id"
$(deriveTextShow ''VoiceChannel)
$(makeFieldLabelsNoPrefix ''VoiceChannel)