{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
module Discord.Internal.Types.ApplicationCommands
( ApplicationCommand (..),
Options (..),
OptionSubcommandOrGroup (..),
OptionSubcommand (..),
OptionValue (..),
createChatInput,
createUser,
createMessage,
CreateApplicationCommand (..),
EditApplicationCommand (..),
defaultEditApplicationCommand,
Choice (..),
ApplicationCommandChannelType (..),
GuildApplicationCommandPermissions (..),
ApplicationCommandPermissions (..),
Number,
)
where
import Data.Aeson (FromJSON (parseJSON), ToJSON (toJSON), Value (Number, Object), object, withArray, withObject, (.!=), (.:), (.:!), (.:?))
import Data.Aeson.Types (Pair, Parser)
import Data.Data (Data)
import Data.Foldable (Foldable (toList))
import Data.Scientific (Scientific)
import qualified Data.Text as T
import Discord.Internal.Types.Prelude (ApplicationCommandId, ApplicationId, GuildId, InternalDiscordEnum (..), Snowflake, discordTypeParseJSON, toMaybeJSON)
type Number = Scientific
data ApplicationCommand
= ApplicationCommandUser
{
ApplicationCommand -> ApplicationCommandId
applicationCommandId :: ApplicationCommandId,
ApplicationCommand -> ApplicationId
applicationCommandApplicationId :: ApplicationId,
ApplicationCommand -> Maybe GuildId
applicationCommandGuildId :: Maybe GuildId,
ApplicationCommand -> Text
applicationCommandName :: T.Text,
ApplicationCommand -> Bool
applicationCommandDefaultPermission :: Bool,
ApplicationCommand -> Snowflake
applicationCommandVersion :: Snowflake
}
| ApplicationCommandMessage
{
applicationCommandId :: ApplicationCommandId,
applicationCommandApplicationId :: ApplicationId,
applicationCommandGuildId :: Maybe GuildId,
applicationCommandName :: T.Text,
applicationCommandDefaultPermission :: Bool,
applicationCommandVersion :: Snowflake
}
| ApplicationCommandChatInput
{
applicationCommandId :: ApplicationCommandId,
applicationCommandApplicationId :: ApplicationId,
applicationCommandGuildId :: Maybe GuildId,
applicationCommandName :: T.Text,
ApplicationCommand -> Text
applicationCommandDescription :: T.Text,
ApplicationCommand -> Maybe Options
applicationCommandOptions :: Maybe Options,
applicationCommandDefaultPermission :: Bool,
applicationCommandVersion :: Snowflake
}
deriving (Int -> ApplicationCommand -> ShowS
[ApplicationCommand] -> ShowS
ApplicationCommand -> String
(Int -> ApplicationCommand -> ShowS)
-> (ApplicationCommand -> String)
-> ([ApplicationCommand] -> ShowS)
-> Show ApplicationCommand
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationCommand] -> ShowS
$cshowList :: [ApplicationCommand] -> ShowS
show :: ApplicationCommand -> String
$cshow :: ApplicationCommand -> String
showsPrec :: Int -> ApplicationCommand -> ShowS
$cshowsPrec :: Int -> ApplicationCommand -> ShowS
Show, ApplicationCommand -> ApplicationCommand -> Bool
(ApplicationCommand -> ApplicationCommand -> Bool)
-> (ApplicationCommand -> ApplicationCommand -> Bool)
-> Eq ApplicationCommand
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationCommand -> ApplicationCommand -> Bool
$c/= :: ApplicationCommand -> ApplicationCommand -> Bool
== :: ApplicationCommand -> ApplicationCommand -> Bool
$c== :: ApplicationCommand -> ApplicationCommand -> Bool
Eq, ReadPrec [ApplicationCommand]
ReadPrec ApplicationCommand
Int -> ReadS ApplicationCommand
ReadS [ApplicationCommand]
(Int -> ReadS ApplicationCommand)
-> ReadS [ApplicationCommand]
-> ReadPrec ApplicationCommand
-> ReadPrec [ApplicationCommand]
-> Read ApplicationCommand
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplicationCommand]
$creadListPrec :: ReadPrec [ApplicationCommand]
readPrec :: ReadPrec ApplicationCommand
$creadPrec :: ReadPrec ApplicationCommand
readList :: ReadS [ApplicationCommand]
$creadList :: ReadS [ApplicationCommand]
readsPrec :: Int -> ReadS ApplicationCommand
$creadsPrec :: Int -> ReadS ApplicationCommand
Read)
instance FromJSON ApplicationCommand where
parseJSON :: Value -> Parser ApplicationCommand
parseJSON =
String
-> (Object -> Parser ApplicationCommand)
-> Value
-> Parser ApplicationCommand
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject
String
"ApplicationCommand"
( \Object
v -> do
ApplicationCommandId
acid <- Object
v Object -> Text -> Parser ApplicationCommandId
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"id"
ApplicationId
aid <- Object
v Object -> Text -> Parser ApplicationId
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"application_id"
Maybe GuildId
gid <- Object
v Object -> Text -> Parser (Maybe GuildId)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"guild_id"
Text
name <- Object
v Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"name"
Bool
defPerm <- Object
v Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"default_permission" Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
.!= Bool
True
Snowflake
version <- Object
v Object -> Text -> Parser Snowflake
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"version"
Maybe Int
t <- Object
v Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"type" :: Parser (Maybe Int)
case Maybe Int
t of
(Just Int
2) -> ApplicationCommand -> Parser ApplicationCommand
forall (m :: * -> *) a. Monad m => a -> m a
return (ApplicationCommand -> Parser ApplicationCommand)
-> ApplicationCommand -> Parser ApplicationCommand
forall a b. (a -> b) -> a -> b
$ ApplicationCommandId
-> ApplicationId
-> Maybe GuildId
-> Text
-> Bool
-> Snowflake
-> ApplicationCommand
ApplicationCommandUser ApplicationCommandId
acid ApplicationId
aid Maybe GuildId
gid Text
name Bool
defPerm Snowflake
version
(Just Int
3) -> ApplicationCommand -> Parser ApplicationCommand
forall (m :: * -> *) a. Monad m => a -> m a
return (ApplicationCommand -> Parser ApplicationCommand)
-> ApplicationCommand -> Parser ApplicationCommand
forall a b. (a -> b) -> a -> b
$ ApplicationCommandId
-> ApplicationId
-> Maybe GuildId
-> Text
-> Bool
-> Snowflake
-> ApplicationCommand
ApplicationCommandMessage ApplicationCommandId
acid ApplicationId
aid Maybe GuildId
gid Text
name Bool
defPerm Snowflake
version
Maybe Int
_ -> do
Text
desc <- Object
v Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"description"
Maybe Options
options <- Object
v Object -> Text -> Parser (Maybe Options)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"options"
ApplicationCommand -> Parser ApplicationCommand
forall (m :: * -> *) a. Monad m => a -> m a
return (ApplicationCommand -> Parser ApplicationCommand)
-> ApplicationCommand -> Parser ApplicationCommand
forall a b. (a -> b) -> a -> b
$ ApplicationCommandId
-> ApplicationId
-> Maybe GuildId
-> Text
-> Text
-> Maybe Options
-> Bool
-> Snowflake
-> ApplicationCommand
ApplicationCommandChatInput ApplicationCommandId
acid ApplicationId
aid Maybe GuildId
gid Text
name Text
desc Maybe Options
options Bool
defPerm Snowflake
version
)
data Options
= OptionsSubcommands [OptionSubcommandOrGroup]
| OptionsValues [OptionValue]
deriving (Int -> Options -> ShowS
[Options] -> ShowS
Options -> String
(Int -> Options -> ShowS)
-> (Options -> String) -> ([Options] -> ShowS) -> Show Options
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Options] -> ShowS
$cshowList :: [Options] -> ShowS
show :: Options -> String
$cshow :: Options -> String
showsPrec :: Int -> Options -> ShowS
$cshowsPrec :: Int -> Options -> ShowS
Show, Options -> Options -> Bool
(Options -> Options -> Bool)
-> (Options -> Options -> Bool) -> Eq Options
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Options -> Options -> Bool
$c/= :: Options -> Options -> Bool
== :: Options -> Options -> Bool
$c== :: Options -> Options -> Bool
Eq, ReadPrec [Options]
ReadPrec Options
Int -> ReadS Options
ReadS [Options]
(Int -> ReadS Options)
-> ReadS [Options]
-> ReadPrec Options
-> ReadPrec [Options]
-> Read Options
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Options]
$creadListPrec :: ReadPrec [Options]
readPrec :: ReadPrec Options
$creadPrec :: ReadPrec Options
readList :: ReadS [Options]
$creadList :: ReadS [Options]
readsPrec :: Int -> ReadS Options
$creadsPrec :: Int -> ReadS Options
Read)
instance FromJSON Options where
parseJSON :: Value -> Parser Options
parseJSON =
String -> (Array -> Parser Options) -> Value -> Parser Options
forall a. String -> (Array -> Parser a) -> Value -> Parser a
withArray
String
"Options"
( \Array
a -> do
let a' :: [Value]
a' = Array -> [Value]
forall (t :: * -> *) a. Foldable t => t a -> [a]
toList Array
a
case [Value]
a' of
[] -> Options -> Parser Options
forall (m :: * -> *) a. Monad m => a -> m a
return (Options -> Parser Options) -> Options -> Parser Options
forall a b. (a -> b) -> a -> b
$ [OptionValue] -> Options
OptionsValues []
(Value
v' : [Value]
_) ->
String -> (Object -> Parser Options) -> Value -> Parser Options
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject
String
"Options item"
( \Object
v -> do
Int
t <- Object
v Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"type" :: Parser Int
if Int
t Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
1 Bool -> Bool -> Bool
|| Int
t Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
2
then [OptionSubcommandOrGroup] -> Options
OptionsSubcommands ([OptionSubcommandOrGroup] -> Options)
-> Parser [OptionSubcommandOrGroup] -> Parser Options
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value -> Parser OptionSubcommandOrGroup)
-> [Value] -> Parser [OptionSubcommandOrGroup]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Value -> Parser OptionSubcommandOrGroup
forall a. FromJSON a => Value -> Parser a
parseJSON [Value]
a'
else [OptionValue] -> Options
OptionsValues ([OptionValue] -> Options)
-> Parser [OptionValue] -> Parser Options
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Value -> Parser OptionValue) -> [Value] -> Parser [OptionValue]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Value -> Parser OptionValue
forall a. FromJSON a => Value -> Parser a
parseJSON [Value]
a'
)
Value
v'
)
instance ToJSON Options where
toJSON :: Options -> Value
toJSON (OptionsSubcommands [OptionSubcommandOrGroup]
o) = [OptionSubcommandOrGroup] -> Value
forall a. ToJSON a => a -> Value
toJSON [OptionSubcommandOrGroup]
o
toJSON (OptionsValues [OptionValue]
o) = [OptionValue] -> Value
forall a. ToJSON a => a -> Value
toJSON [OptionValue]
o
data OptionSubcommandOrGroup
= OptionSubcommandGroup
{
OptionSubcommandOrGroup -> Text
optionSubcommandGroupName :: T.Text,
OptionSubcommandOrGroup -> Text
optionSubcommandGroupDescription :: T.Text,
OptionSubcommandOrGroup -> [OptionSubcommand]
optionSubcommandGroupOptions :: [OptionSubcommand]
}
| OptionSubcommandOrGroupSubcommand OptionSubcommand
deriving (Int -> OptionSubcommandOrGroup -> ShowS
[OptionSubcommandOrGroup] -> ShowS
OptionSubcommandOrGroup -> String
(Int -> OptionSubcommandOrGroup -> ShowS)
-> (OptionSubcommandOrGroup -> String)
-> ([OptionSubcommandOrGroup] -> ShowS)
-> Show OptionSubcommandOrGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OptionSubcommandOrGroup] -> ShowS
$cshowList :: [OptionSubcommandOrGroup] -> ShowS
show :: OptionSubcommandOrGroup -> String
$cshow :: OptionSubcommandOrGroup -> String
showsPrec :: Int -> OptionSubcommandOrGroup -> ShowS
$cshowsPrec :: Int -> OptionSubcommandOrGroup -> ShowS
Show, OptionSubcommandOrGroup -> OptionSubcommandOrGroup -> Bool
(OptionSubcommandOrGroup -> OptionSubcommandOrGroup -> Bool)
-> (OptionSubcommandOrGroup -> OptionSubcommandOrGroup -> Bool)
-> Eq OptionSubcommandOrGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptionSubcommandOrGroup -> OptionSubcommandOrGroup -> Bool
$c/= :: OptionSubcommandOrGroup -> OptionSubcommandOrGroup -> Bool
== :: OptionSubcommandOrGroup -> OptionSubcommandOrGroup -> Bool
$c== :: OptionSubcommandOrGroup -> OptionSubcommandOrGroup -> Bool
Eq, ReadPrec [OptionSubcommandOrGroup]
ReadPrec OptionSubcommandOrGroup
Int -> ReadS OptionSubcommandOrGroup
ReadS [OptionSubcommandOrGroup]
(Int -> ReadS OptionSubcommandOrGroup)
-> ReadS [OptionSubcommandOrGroup]
-> ReadPrec OptionSubcommandOrGroup
-> ReadPrec [OptionSubcommandOrGroup]
-> Read OptionSubcommandOrGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OptionSubcommandOrGroup]
$creadListPrec :: ReadPrec [OptionSubcommandOrGroup]
readPrec :: ReadPrec OptionSubcommandOrGroup
$creadPrec :: ReadPrec OptionSubcommandOrGroup
readList :: ReadS [OptionSubcommandOrGroup]
$creadList :: ReadS [OptionSubcommandOrGroup]
readsPrec :: Int -> ReadS OptionSubcommandOrGroup
$creadsPrec :: Int -> ReadS OptionSubcommandOrGroup
Read)
instance FromJSON OptionSubcommandOrGroup where
parseJSON :: Value -> Parser OptionSubcommandOrGroup
parseJSON =
String
-> (Object -> Parser OptionSubcommandOrGroup)
-> Value
-> Parser OptionSubcommandOrGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject
String
"OptionSubcommandOrGroup"
( \Object
v -> do
Int
t <- Object
v Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"type" :: Parser Int
case Int
t of
Int
2 ->
Text -> Text -> [OptionSubcommand] -> OptionSubcommandOrGroup
OptionSubcommandGroup
(Text -> Text -> [OptionSubcommand] -> OptionSubcommandOrGroup)
-> Parser Text
-> Parser (Text -> [OptionSubcommand] -> OptionSubcommandOrGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"name"
Parser (Text -> [OptionSubcommand] -> OptionSubcommandOrGroup)
-> Parser Text
-> Parser ([OptionSubcommand] -> OptionSubcommandOrGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"description"
Parser ([OptionSubcommand] -> OptionSubcommandOrGroup)
-> Parser [OptionSubcommand] -> Parser OptionSubcommandOrGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser [OptionSubcommand]
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"options"
Int
1 -> OptionSubcommand -> OptionSubcommandOrGroup
OptionSubcommandOrGroupSubcommand (OptionSubcommand -> OptionSubcommandOrGroup)
-> Parser OptionSubcommand -> Parser OptionSubcommandOrGroup
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser OptionSubcommand
forall a. FromJSON a => Value -> Parser a
parseJSON (Object -> Value
Object Object
v)
Int
_ -> String -> Parser OptionSubcommandOrGroup
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"unexpected subcommand group type"
)
instance ToJSON OptionSubcommandOrGroup where
toJSON :: OptionSubcommandOrGroup -> Value
toJSON OptionSubcommandGroup {[OptionSubcommand]
Text
optionSubcommandGroupOptions :: [OptionSubcommand]
optionSubcommandGroupDescription :: Text
optionSubcommandGroupName :: Text
optionSubcommandGroupOptions :: OptionSubcommandOrGroup -> [OptionSubcommand]
optionSubcommandGroupDescription :: OptionSubcommandOrGroup -> Text
optionSubcommandGroupName :: OptionSubcommandOrGroup -> Text
..} =
[Pair] -> Value
object
[ (Text
"type", Scientific -> Value
Number Scientific
2),
(Text
"name", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionSubcommandGroupName),
(Text
"description", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionSubcommandGroupDescription),
(Text
"options", [OptionSubcommand] -> Value
forall a. ToJSON a => a -> Value
toJSON [OptionSubcommand]
optionSubcommandGroupOptions)
]
toJSON (OptionSubcommandOrGroupSubcommand OptionSubcommand
a) = OptionSubcommand -> Value
forall a. ToJSON a => a -> Value
toJSON OptionSubcommand
a
data OptionSubcommand = OptionSubcommand
{
OptionSubcommand -> Text
optionSubcommandName :: T.Text,
OptionSubcommand -> Text
optionSubcommandDescription :: T.Text,
OptionSubcommand -> [OptionValue]
optionSubcommandOptions :: [OptionValue]
}
deriving (Int -> OptionSubcommand -> ShowS
[OptionSubcommand] -> ShowS
OptionSubcommand -> String
(Int -> OptionSubcommand -> ShowS)
-> (OptionSubcommand -> String)
-> ([OptionSubcommand] -> ShowS)
-> Show OptionSubcommand
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OptionSubcommand] -> ShowS
$cshowList :: [OptionSubcommand] -> ShowS
show :: OptionSubcommand -> String
$cshow :: OptionSubcommand -> String
showsPrec :: Int -> OptionSubcommand -> ShowS
$cshowsPrec :: Int -> OptionSubcommand -> ShowS
Show, OptionSubcommand -> OptionSubcommand -> Bool
(OptionSubcommand -> OptionSubcommand -> Bool)
-> (OptionSubcommand -> OptionSubcommand -> Bool)
-> Eq OptionSubcommand
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptionSubcommand -> OptionSubcommand -> Bool
$c/= :: OptionSubcommand -> OptionSubcommand -> Bool
== :: OptionSubcommand -> OptionSubcommand -> Bool
$c== :: OptionSubcommand -> OptionSubcommand -> Bool
Eq, ReadPrec [OptionSubcommand]
ReadPrec OptionSubcommand
Int -> ReadS OptionSubcommand
ReadS [OptionSubcommand]
(Int -> ReadS OptionSubcommand)
-> ReadS [OptionSubcommand]
-> ReadPrec OptionSubcommand
-> ReadPrec [OptionSubcommand]
-> Read OptionSubcommand
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OptionSubcommand]
$creadListPrec :: ReadPrec [OptionSubcommand]
readPrec :: ReadPrec OptionSubcommand
$creadPrec :: ReadPrec OptionSubcommand
readList :: ReadS [OptionSubcommand]
$creadList :: ReadS [OptionSubcommand]
readsPrec :: Int -> ReadS OptionSubcommand
$creadsPrec :: Int -> ReadS OptionSubcommand
Read)
instance FromJSON OptionSubcommand where
parseJSON :: Value -> Parser OptionSubcommand
parseJSON =
String
-> (Object -> Parser OptionSubcommand)
-> Value
-> Parser OptionSubcommand
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject
String
"OptionSubcommand"
( \Object
v -> do
Int
t <- Object
v Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"type" :: Parser Int
case Int
t of
Int
1 ->
Text -> Text -> [OptionValue] -> OptionSubcommand
OptionSubcommand
(Text -> Text -> [OptionValue] -> OptionSubcommand)
-> Parser Text
-> Parser (Text -> [OptionValue] -> OptionSubcommand)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"name"
Parser (Text -> [OptionValue] -> OptionSubcommand)
-> Parser Text -> Parser ([OptionValue] -> OptionSubcommand)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"description"
Parser ([OptionValue] -> OptionSubcommand)
-> Parser [OptionValue] -> Parser OptionSubcommand
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser (Maybe [OptionValue])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"options" Parser (Maybe [OptionValue])
-> [OptionValue] -> Parser [OptionValue]
forall a. Parser (Maybe a) -> a -> Parser a
.!= []
Int
_ -> String -> Parser OptionSubcommand
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"unexpected subcommand type"
)
instance ToJSON OptionSubcommand where
toJSON :: OptionSubcommand -> Value
toJSON OptionSubcommand {[OptionValue]
Text
optionSubcommandOptions :: [OptionValue]
optionSubcommandDescription :: Text
optionSubcommandName :: Text
optionSubcommandOptions :: OptionSubcommand -> [OptionValue]
optionSubcommandDescription :: OptionSubcommand -> Text
optionSubcommandName :: OptionSubcommand -> Text
..} =
[Pair] -> Value
object
[ (Text
"type", Scientific -> Value
Number Scientific
1),
(Text
"name", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionSubcommandName),
(Text
"description", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionSubcommandDescription),
(Text
"options", [OptionValue] -> Value
forall a. ToJSON a => a -> Value
toJSON [OptionValue]
optionSubcommandOptions)
]
data OptionValue
= OptionValueString
{
OptionValue -> Text
optionValueName :: T.Text,
OptionValue -> Text
optionValueDescription :: T.Text,
OptionValue -> Bool
optionValueRequired :: Bool,
OptionValue -> AutocompleteOrChoice Text
optionValueStringChoices :: AutocompleteOrChoice T.Text
}
| OptionValueInteger
{
optionValueName :: T.Text,
optionValueDescription :: T.Text,
optionValueRequired :: Bool,
OptionValue -> AutocompleteOrChoice Integer
optionValueIntegerChoices :: AutocompleteOrChoice Integer,
OptionValue -> Maybe Integer
optionValueIntegerMinVal :: Maybe Integer,
OptionValue -> Maybe Integer
optionValueIntegerMaxVal :: Maybe Integer
}
| OptionValueBoolean
{
optionValueName :: T.Text,
optionValueDescription :: T.Text,
optionValueRequired :: Bool
}
| OptionValueUser
{
optionValueName :: T.Text,
optionValueDescription :: T.Text,
optionValueRequired :: Bool
}
| OptionValueChannel
{
optionValueName :: T.Text,
optionValueDescription :: T.Text,
optionValueRequired :: Bool,
OptionValue -> Maybe [ApplicationCommandChannelType]
optionValueChannelTypes :: Maybe [ApplicationCommandChannelType]
}
| OptionValueRole
{
optionValueName :: T.Text,
optionValueDescription :: T.Text,
optionValueRequired :: Bool
}
| OptionValueMentionable
{
optionValueName :: T.Text,
optionValueDescription :: T.Text,
optionValueRequired :: Bool
}
| OptionValueNumber
{
optionValueName :: T.Text,
optionValueDescription :: T.Text,
optionValueRequired :: Bool,
OptionValue -> AutocompleteOrChoice Scientific
optionValueNumberChoices :: AutocompleteOrChoice Number,
OptionValue -> Maybe Scientific
optionValueNumberMinVal :: Maybe Number,
OptionValue -> Maybe Scientific
optionValueNumberMaxVal :: Maybe Number
}
deriving (Int -> OptionValue -> ShowS
[OptionValue] -> ShowS
OptionValue -> String
(Int -> OptionValue -> ShowS)
-> (OptionValue -> String)
-> ([OptionValue] -> ShowS)
-> Show OptionValue
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OptionValue] -> ShowS
$cshowList :: [OptionValue] -> ShowS
show :: OptionValue -> String
$cshow :: OptionValue -> String
showsPrec :: Int -> OptionValue -> ShowS
$cshowsPrec :: Int -> OptionValue -> ShowS
Show, OptionValue -> OptionValue -> Bool
(OptionValue -> OptionValue -> Bool)
-> (OptionValue -> OptionValue -> Bool) -> Eq OptionValue
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptionValue -> OptionValue -> Bool
$c/= :: OptionValue -> OptionValue -> Bool
== :: OptionValue -> OptionValue -> Bool
$c== :: OptionValue -> OptionValue -> Bool
Eq, ReadPrec [OptionValue]
ReadPrec OptionValue
Int -> ReadS OptionValue
ReadS [OptionValue]
(Int -> ReadS OptionValue)
-> ReadS [OptionValue]
-> ReadPrec OptionValue
-> ReadPrec [OptionValue]
-> Read OptionValue
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OptionValue]
$creadListPrec :: ReadPrec [OptionValue]
readPrec :: ReadPrec OptionValue
$creadPrec :: ReadPrec OptionValue
readList :: ReadS [OptionValue]
$creadList :: ReadS [OptionValue]
readsPrec :: Int -> ReadS OptionValue
$creadsPrec :: Int -> ReadS OptionValue
Read)
instance FromJSON OptionValue where
parseJSON :: Value -> Parser OptionValue
parseJSON =
String
-> (Object -> Parser OptionValue) -> Value -> Parser OptionValue
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject
String
"OptionValue"
( \Object
v -> do
Text
name <- Object
v Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"name"
Text
desc <- Object
v Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"description"
Bool
required <- Object
v Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"required" Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
.!= Bool
False
Int
t <- Object
v Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"type" :: Parser Int
case Int
t of
Int
3 ->
Text -> Text -> Bool -> AutocompleteOrChoice Text -> OptionValue
OptionValueString Text
name Text
desc Bool
required
(AutocompleteOrChoice Text -> OptionValue)
-> Parser (AutocompleteOrChoice Text) -> Parser OptionValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (AutocompleteOrChoice Text)
forall a. FromJSON a => Value -> Parser a
parseJSON (Object -> Value
Object Object
v)
Int
4 ->
Text
-> Text
-> Bool
-> AutocompleteOrChoice Integer
-> Maybe Integer
-> Maybe Integer
-> OptionValue
OptionValueInteger Text
name Text
desc Bool
required
(AutocompleteOrChoice Integer
-> Maybe Integer -> Maybe Integer -> OptionValue)
-> Parser (AutocompleteOrChoice Integer)
-> Parser (Maybe Integer -> Maybe Integer -> OptionValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (AutocompleteOrChoice Integer)
forall a. FromJSON a => Value -> Parser a
parseJSON (Object -> Value
Object Object
v)
Parser (Maybe Integer -> Maybe Integer -> OptionValue)
-> Parser (Maybe Integer) -> Parser (Maybe Integer -> OptionValue)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"min_value"
Parser (Maybe Integer -> OptionValue)
-> Parser (Maybe Integer) -> Parser OptionValue
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"max_value"
Int
10 ->
Text
-> Text
-> Bool
-> AutocompleteOrChoice Scientific
-> Maybe Scientific
-> Maybe Scientific
-> OptionValue
OptionValueNumber Text
name Text
desc Bool
required
(AutocompleteOrChoice Scientific
-> Maybe Scientific -> Maybe Scientific -> OptionValue)
-> Parser (AutocompleteOrChoice Scientific)
-> Parser (Maybe Scientific -> Maybe Scientific -> OptionValue)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (AutocompleteOrChoice Scientific)
forall a. FromJSON a => Value -> Parser a
parseJSON (Object -> Value
Object Object
v)
Parser (Maybe Scientific -> Maybe Scientific -> OptionValue)
-> Parser (Maybe Scientific)
-> Parser (Maybe Scientific -> OptionValue)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser (Maybe Scientific)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"min_value"
Parser (Maybe Scientific -> OptionValue)
-> Parser (Maybe Scientific) -> Parser OptionValue
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser (Maybe Scientific)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"max_value"
Int
7 ->
Text
-> Text
-> Bool
-> Maybe [ApplicationCommandChannelType]
-> OptionValue
OptionValueChannel Text
name Text
desc Bool
required
(Maybe [ApplicationCommandChannelType] -> OptionValue)
-> Parser (Maybe [ApplicationCommandChannelType])
-> Parser OptionValue
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Text -> Parser (Maybe [ApplicationCommandChannelType])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"channel_types"
Int
5 -> OptionValue -> Parser OptionValue
forall (m :: * -> *) a. Monad m => a -> m a
return (OptionValue -> Parser OptionValue)
-> OptionValue -> Parser OptionValue
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Bool -> OptionValue
OptionValueBoolean Text
name Text
desc Bool
required
Int
6 -> OptionValue -> Parser OptionValue
forall (m :: * -> *) a. Monad m => a -> m a
return (OptionValue -> Parser OptionValue)
-> OptionValue -> Parser OptionValue
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Bool -> OptionValue
OptionValueUser Text
name Text
desc Bool
required
Int
8 -> OptionValue -> Parser OptionValue
forall (m :: * -> *) a. Monad m => a -> m a
return (OptionValue -> Parser OptionValue)
-> OptionValue -> Parser OptionValue
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Bool -> OptionValue
OptionValueRole Text
name Text
desc Bool
required
Int
9 -> OptionValue -> Parser OptionValue
forall (m :: * -> *) a. Monad m => a -> m a
return (OptionValue -> Parser OptionValue)
-> OptionValue -> Parser OptionValue
forall a b. (a -> b) -> a -> b
$ Text -> Text -> Bool -> OptionValue
OptionValueMentionable Text
name Text
desc Bool
required
Int
_ -> String -> Parser OptionValue
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"unknown application command option value type"
)
instance ToJSON OptionValue where
toJSON :: OptionValue -> Value
toJSON OptionValueString {Bool
AutocompleteOrChoice Text
Text
optionValueStringChoices :: AutocompleteOrChoice Text
optionValueRequired :: Bool
optionValueDescription :: Text
optionValueName :: Text
optionValueStringChoices :: OptionValue -> AutocompleteOrChoice Text
optionValueRequired :: OptionValue -> Bool
optionValueDescription :: OptionValue -> Text
optionValueName :: OptionValue -> Text
..} =
[Pair] -> Value
object
[ (Text
"type", Scientific -> Value
Number Scientific
3),
(Text
"name", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionValueName),
(Text
"description", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionValueDescription),
(Text
"required", Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
optionValueRequired),
AutocompleteOrChoice Text -> Pair
forall a. ToJSON a => AutocompleteOrChoice a -> Pair
choiceOrAutocompleteToJSON AutocompleteOrChoice Text
optionValueStringChoices
]
toJSON OptionValueInteger {Bool
Maybe Integer
AutocompleteOrChoice Integer
Text
optionValueIntegerMaxVal :: Maybe Integer
optionValueIntegerMinVal :: Maybe Integer
optionValueIntegerChoices :: AutocompleteOrChoice Integer
optionValueRequired :: Bool
optionValueDescription :: Text
optionValueName :: Text
optionValueIntegerMaxVal :: OptionValue -> Maybe Integer
optionValueIntegerMinVal :: OptionValue -> Maybe Integer
optionValueIntegerChoices :: OptionValue -> AutocompleteOrChoice Integer
optionValueRequired :: OptionValue -> Bool
optionValueDescription :: OptionValue -> Text
optionValueName :: OptionValue -> Text
..} =
[Pair] -> Value
object
[ (Text
"type", Scientific -> Value
Number Scientific
4),
(Text
"name", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionValueName),
(Text
"description", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionValueDescription),
(Text
"required", Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
optionValueRequired),
AutocompleteOrChoice Integer -> Pair
forall a. ToJSON a => AutocompleteOrChoice a -> Pair
choiceOrAutocompleteToJSON AutocompleteOrChoice Integer
optionValueIntegerChoices
]
toJSON OptionValueNumber {Bool
Maybe Scientific
AutocompleteOrChoice Scientific
Text
optionValueNumberMaxVal :: Maybe Scientific
optionValueNumberMinVal :: Maybe Scientific
optionValueNumberChoices :: AutocompleteOrChoice Scientific
optionValueRequired :: Bool
optionValueDescription :: Text
optionValueName :: Text
optionValueNumberMaxVal :: OptionValue -> Maybe Scientific
optionValueNumberMinVal :: OptionValue -> Maybe Scientific
optionValueNumberChoices :: OptionValue -> AutocompleteOrChoice Scientific
optionValueRequired :: OptionValue -> Bool
optionValueDescription :: OptionValue -> Text
optionValueName :: OptionValue -> Text
..} =
[Pair] -> Value
object
[ (Text
"type", Scientific -> Value
Number Scientific
10),
(Text
"name", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionValueName),
(Text
"description", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionValueDescription),
(Text
"required", Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
optionValueRequired),
AutocompleteOrChoice Scientific -> Pair
forall a. ToJSON a => AutocompleteOrChoice a -> Pair
choiceOrAutocompleteToJSON AutocompleteOrChoice Scientific
optionValueNumberChoices
]
toJSON OptionValueChannel {Bool
Maybe [ApplicationCommandChannelType]
Text
optionValueChannelTypes :: Maybe [ApplicationCommandChannelType]
optionValueRequired :: Bool
optionValueDescription :: Text
optionValueName :: Text
optionValueChannelTypes :: OptionValue -> Maybe [ApplicationCommandChannelType]
optionValueRequired :: OptionValue -> Bool
optionValueDescription :: OptionValue -> Text
optionValueName :: OptionValue -> Text
..} =
[Pair] -> Value
object
[ (Text
"type", Scientific -> Value
Number Scientific
7),
(Text
"name", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionValueName),
(Text
"description", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
optionValueDescription),
(Text
"required", Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
optionValueRequired),
(Text
"channel_types", Maybe [ApplicationCommandChannelType] -> Value
forall a. ToJSON a => a -> Value
toJSON Maybe [ApplicationCommandChannelType]
optionValueChannelTypes)
]
toJSON OptionValue
acov =
[Pair] -> Value
object
[ (Text
"type", Scientific -> Value
Number (OptionValue -> Scientific
forall p. Num p => OptionValue -> p
t OptionValue
acov)),
(Text
"name", Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ OptionValue -> Text
optionValueName OptionValue
acov),
(Text
"description", Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> Text -> Value
forall a b. (a -> b) -> a -> b
$ OptionValue -> Text
optionValueDescription OptionValue
acov),
(Text
"required", Bool -> Value
forall a. ToJSON a => a -> Value
toJSON (Bool -> Value) -> Bool -> Value
forall a b. (a -> b) -> a -> b
$ OptionValue -> Bool
optionValueRequired OptionValue
acov)
]
where
t :: OptionValue -> p
t OptionValueBoolean {} = p
5
t OptionValueUser {} = p
6
t OptionValueRole {} = p
8
t OptionValueMentionable {} = p
9
t OptionValue
_ = -p
1
data CreateApplicationCommand
= CreateApplicationCommandChatInput
{
CreateApplicationCommand -> Text
createName :: T.Text,
CreateApplicationCommand -> Text
createDescription :: T.Text,
CreateApplicationCommand -> Maybe Options
createOptions :: Maybe Options,
CreateApplicationCommand -> Maybe Text
createDefaultMemberPermissions :: Maybe T.Text,
CreateApplicationCommand -> Bool
createDefaultPermission :: Bool
}
| CreateApplicationCommandUser
{
createName :: T.Text,
createDefaultMemberPermissions :: Maybe T.Text,
createDefaultPermission :: Bool
}
| CreateApplicationCommandMessage
{
createName :: T.Text,
createDefaultMemberPermissions :: Maybe T.Text,
createDefaultPermission :: Bool
}
deriving (Int -> CreateApplicationCommand -> ShowS
[CreateApplicationCommand] -> ShowS
CreateApplicationCommand -> String
(Int -> CreateApplicationCommand -> ShowS)
-> (CreateApplicationCommand -> String)
-> ([CreateApplicationCommand] -> ShowS)
-> Show CreateApplicationCommand
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateApplicationCommand] -> ShowS
$cshowList :: [CreateApplicationCommand] -> ShowS
show :: CreateApplicationCommand -> String
$cshow :: CreateApplicationCommand -> String
showsPrec :: Int -> CreateApplicationCommand -> ShowS
$cshowsPrec :: Int -> CreateApplicationCommand -> ShowS
Show, CreateApplicationCommand -> CreateApplicationCommand -> Bool
(CreateApplicationCommand -> CreateApplicationCommand -> Bool)
-> (CreateApplicationCommand -> CreateApplicationCommand -> Bool)
-> Eq CreateApplicationCommand
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateApplicationCommand -> CreateApplicationCommand -> Bool
$c/= :: CreateApplicationCommand -> CreateApplicationCommand -> Bool
== :: CreateApplicationCommand -> CreateApplicationCommand -> Bool
$c== :: CreateApplicationCommand -> CreateApplicationCommand -> Bool
Eq, ReadPrec [CreateApplicationCommand]
ReadPrec CreateApplicationCommand
Int -> ReadS CreateApplicationCommand
ReadS [CreateApplicationCommand]
(Int -> ReadS CreateApplicationCommand)
-> ReadS [CreateApplicationCommand]
-> ReadPrec CreateApplicationCommand
-> ReadPrec [CreateApplicationCommand]
-> Read CreateApplicationCommand
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateApplicationCommand]
$creadListPrec :: ReadPrec [CreateApplicationCommand]
readPrec :: ReadPrec CreateApplicationCommand
$creadPrec :: ReadPrec CreateApplicationCommand
readList :: ReadS [CreateApplicationCommand]
$creadList :: ReadS [CreateApplicationCommand]
readsPrec :: Int -> ReadS CreateApplicationCommand
$creadsPrec :: Int -> ReadS CreateApplicationCommand
Read)
instance ToJSON CreateApplicationCommand where
toJSON :: CreateApplicationCommand -> Value
toJSON CreateApplicationCommandChatInput {Bool
Maybe Text
Maybe Options
Text
createDefaultPermission :: Bool
createDefaultMemberPermissions :: Maybe Text
createOptions :: Maybe Options
createDescription :: Text
createName :: Text
createDefaultPermission :: CreateApplicationCommand -> Bool
createDefaultMemberPermissions :: CreateApplicationCommand -> Maybe Text
createOptions :: CreateApplicationCommand -> Maybe Options
createDescription :: CreateApplicationCommand -> Text
createName :: CreateApplicationCommand -> Text
..} =
[Pair] -> Value
object
[ (Text
name, Value
value)
| (Text
name, Just Value
value) <-
[ (Text
"name", Text -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Text
createName),
(Text
"description", Text -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Text
createDescription),
(Text
"options", Options -> Value
forall a. ToJSON a => a -> Value
toJSON (Options -> Value) -> Maybe Options -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Options
createOptions),
(Text
"default_member_permissions", Maybe Text -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Maybe Text
createDefaultMemberPermissions),
(Text
"default_permission", Bool -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Bool
createDefaultPermission),
(Text
"type", Value -> Maybe Value
forall a. a -> Maybe a
Just (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ Scientific -> Value
Number Scientific
1)
]
]
toJSON CreateApplicationCommandUser {Bool
Maybe Text
Text
createDefaultPermission :: Bool
createDefaultMemberPermissions :: Maybe Text
createName :: Text
createDefaultPermission :: CreateApplicationCommand -> Bool
createDefaultMemberPermissions :: CreateApplicationCommand -> Maybe Text
createName :: CreateApplicationCommand -> Text
..} =
[Pair] -> Value
object
[ (Text
name, Value
value)
| (Text
name, Just Value
value) <-
[ (Text
"name", Text -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Text
createName),
(Text
"default_member_permissions", Maybe Text -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Maybe Text
createDefaultMemberPermissions),
(Text
"default_permission", Bool -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Bool
createDefaultPermission),
(Text
"type", Value -> Maybe Value
forall a. a -> Maybe a
Just (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ Scientific -> Value
Number Scientific
2)
]
]
toJSON CreateApplicationCommandMessage {Bool
Maybe Text
Text
createDefaultPermission :: Bool
createDefaultMemberPermissions :: Maybe Text
createName :: Text
createDefaultPermission :: CreateApplicationCommand -> Bool
createDefaultMemberPermissions :: CreateApplicationCommand -> Maybe Text
createName :: CreateApplicationCommand -> Text
..} =
[Pair] -> Value
object
[ (Text
name, Value
value)
| (Text
name, Just Value
value) <-
[ (Text
"name", Text -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Text
createName),
(Text
"default_member_permissions", Maybe Text -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Maybe Text
createDefaultMemberPermissions),
(Text
"default_permission", Bool -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Bool
createDefaultPermission),
(Text
"type", Value -> Maybe Value
forall a. a -> Maybe a
Just (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ Scientific -> Value
Number Scientific
3)
]
]
nameIsValid :: Bool -> T.Text -> Bool
nameIsValid :: Bool -> Text -> Bool
nameIsValid Bool
isChatInput Text
name = Int
l Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
1 Bool -> Bool -> Bool
&& Int
l Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
32 Bool -> Bool -> Bool
&& (Bool
isChatInput Bool -> Bool -> Bool
forall a. Ord a => a -> a -> Bool
<= (Char -> Bool) -> Text -> Bool
T.all (Char -> String -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` String
validChars) Text
name)
where
l :: Int
l = Text -> Int
T.length Text
name
validChars :: String
validChars = Char
'-' Char -> ShowS
forall a. a -> [a] -> [a]
: [Char
'a' .. Char
'z']
createChatInput :: T.Text -> T.Text -> Maybe CreateApplicationCommand
createChatInput :: Text -> Text -> Maybe CreateApplicationCommand
createChatInput Text
name Text
desc
| Bool -> Text -> Bool
nameIsValid Bool
True Text
name Bool -> Bool -> Bool
&& Bool -> Bool
not (Text -> Bool
T.null Text
desc) Bool -> Bool -> Bool
&& Text -> Int
T.length Text
desc Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
100 = CreateApplicationCommand -> Maybe CreateApplicationCommand
forall a. a -> Maybe a
Just (CreateApplicationCommand -> Maybe CreateApplicationCommand)
-> CreateApplicationCommand -> Maybe CreateApplicationCommand
forall a b. (a -> b) -> a -> b
$ Text
-> Text
-> Maybe Options
-> Maybe Text
-> Bool
-> CreateApplicationCommand
CreateApplicationCommandChatInput Text
name Text
desc Maybe Options
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Bool
True
| Bool
otherwise = Maybe CreateApplicationCommand
forall a. Maybe a
Nothing
createUser :: T.Text -> Maybe CreateApplicationCommand
createUser :: Text -> Maybe CreateApplicationCommand
createUser Text
name
| Bool -> Text -> Bool
nameIsValid Bool
False Text
name = CreateApplicationCommand -> Maybe CreateApplicationCommand
forall a. a -> Maybe a
Just (CreateApplicationCommand -> Maybe CreateApplicationCommand)
-> CreateApplicationCommand -> Maybe CreateApplicationCommand
forall a b. (a -> b) -> a -> b
$ Text -> Maybe Text -> Bool -> CreateApplicationCommand
CreateApplicationCommandUser Text
name Maybe Text
forall a. Maybe a
Nothing Bool
True
| Bool
otherwise = Maybe CreateApplicationCommand
forall a. Maybe a
Nothing
createMessage :: T.Text -> Maybe CreateApplicationCommand
createMessage :: Text -> Maybe CreateApplicationCommand
createMessage Text
name
| Bool -> Text -> Bool
nameIsValid Bool
False Text
name = CreateApplicationCommand -> Maybe CreateApplicationCommand
forall a. a -> Maybe a
Just (CreateApplicationCommand -> Maybe CreateApplicationCommand)
-> CreateApplicationCommand -> Maybe CreateApplicationCommand
forall a b. (a -> b) -> a -> b
$ Text -> Maybe Text -> Bool -> CreateApplicationCommand
CreateApplicationCommandMessage Text
name Maybe Text
forall a. Maybe a
Nothing Bool
True
| Bool
otherwise = Maybe CreateApplicationCommand
forall a. Maybe a
Nothing
data EditApplicationCommand
= EditApplicationCommandChatInput
{ EditApplicationCommand -> Maybe Text
editName :: Maybe T.Text,
EditApplicationCommand -> Maybe Text
editDescription :: Maybe T.Text,
EditApplicationCommand -> Maybe Options
editOptions :: Maybe Options,
EditApplicationCommand -> Maybe Bool
editDefaultPermission :: Maybe Bool
}
| EditApplicationCommandUser
{ editName :: Maybe T.Text,
editDefaultPermission :: Maybe Bool
}
| EditApplicationCommandMessage
{ editName :: Maybe T.Text,
editDefaultPermission :: Maybe Bool
}
defaultEditApplicationCommand :: Int -> EditApplicationCommand
defaultEditApplicationCommand :: Int -> EditApplicationCommand
defaultEditApplicationCommand Int
2 = Maybe Text -> Maybe Bool -> EditApplicationCommand
EditApplicationCommandUser Maybe Text
forall a. Maybe a
Nothing Maybe Bool
forall a. Maybe a
Nothing
defaultEditApplicationCommand Int
3 = Maybe Text -> Maybe Bool -> EditApplicationCommand
EditApplicationCommandMessage Maybe Text
forall a. Maybe a
Nothing Maybe Bool
forall a. Maybe a
Nothing
defaultEditApplicationCommand Int
_ = Maybe Text
-> Maybe Text
-> Maybe Options
-> Maybe Bool
-> EditApplicationCommand
EditApplicationCommandChatInput Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Options
forall a. Maybe a
Nothing Maybe Bool
forall a. Maybe a
Nothing
instance ToJSON EditApplicationCommand where
toJSON :: EditApplicationCommand -> Value
toJSON EditApplicationCommandChatInput {Maybe Bool
Maybe Text
Maybe Options
editDefaultPermission :: Maybe Bool
editOptions :: Maybe Options
editDescription :: Maybe Text
editName :: Maybe Text
editDefaultPermission :: EditApplicationCommand -> Maybe Bool
editOptions :: EditApplicationCommand -> Maybe Options
editDescription :: EditApplicationCommand -> Maybe Text
editName :: EditApplicationCommand -> Maybe Text
..} =
[Pair] -> Value
object
[ (Text
name, Value
value)
| (Text
name, Just Value
value) <-
[ (Text
"name", Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> Maybe Text -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
editName),
(Text
"description", Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> Maybe Text -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
editDescription),
(Text
"options", Options -> Value
forall a. ToJSON a => a -> Value
toJSON (Options -> Value) -> Maybe Options -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Options
editOptions),
(Text
"default_permission", Bool -> Value
forall a. ToJSON a => a -> Value
toJSON (Bool -> Value) -> Maybe Bool -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
editDefaultPermission),
(Text
"type", Value -> Maybe Value
forall a. a -> Maybe a
Just (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ Scientific -> Value
Number Scientific
1)
]
]
toJSON EditApplicationCommandUser {Maybe Bool
Maybe Text
editDefaultPermission :: Maybe Bool
editName :: Maybe Text
editDefaultPermission :: EditApplicationCommand -> Maybe Bool
editName :: EditApplicationCommand -> Maybe Text
..} =
[Pair] -> Value
object
[ (Text
name, Value
value)
| (Text
name, Just Value
value) <-
[ (Text
"name", Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> Maybe Text -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
editName),
(Text
"default_permission", Bool -> Value
forall a. ToJSON a => a -> Value
toJSON (Bool -> Value) -> Maybe Bool -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
editDefaultPermission),
(Text
"type", Value -> Maybe Value
forall a. a -> Maybe a
Just (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ Scientific -> Value
Number Scientific
2)
]
]
toJSON EditApplicationCommandMessage {Maybe Bool
Maybe Text
editDefaultPermission :: Maybe Bool
editName :: Maybe Text
editDefaultPermission :: EditApplicationCommand -> Maybe Bool
editName :: EditApplicationCommand -> Maybe Text
..} =
[Pair] -> Value
object
[ (Text
name, Value
value)
| (Text
name, Just Value
value) <-
[ (Text
"name", Text -> Value
forall a. ToJSON a => a -> Value
toJSON (Text -> Value) -> Maybe Text -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Text
editName),
(Text
"default_permission", Bool -> Value
forall a. ToJSON a => a -> Value
toJSON (Bool -> Value) -> Maybe Bool -> Maybe Value
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe Bool
editDefaultPermission),
(Text
"type", Value -> Maybe Value
forall a. a -> Maybe a
Just (Value -> Maybe Value) -> Value -> Maybe Value
forall a b. (a -> b) -> a -> b
$ Scientific -> Value
Number Scientific
3)
]
]
data Choice a = Choice {Choice a -> Text
choiceName :: T.Text, Choice a -> a
choiceValue :: a}
deriving (Int -> Choice a -> ShowS
[Choice a] -> ShowS
Choice a -> String
(Int -> Choice a -> ShowS)
-> (Choice a -> String) -> ([Choice a] -> ShowS) -> Show (Choice a)
forall a. Show a => Int -> Choice a -> ShowS
forall a. Show a => [Choice a] -> ShowS
forall a. Show a => Choice a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Choice a] -> ShowS
$cshowList :: forall a. Show a => [Choice a] -> ShowS
show :: Choice a -> String
$cshow :: forall a. Show a => Choice a -> String
showsPrec :: Int -> Choice a -> ShowS
$cshowsPrec :: forall a. Show a => Int -> Choice a -> ShowS
Show, ReadPrec [Choice a]
ReadPrec (Choice a)
Int -> ReadS (Choice a)
ReadS [Choice a]
(Int -> ReadS (Choice a))
-> ReadS [Choice a]
-> ReadPrec (Choice a)
-> ReadPrec [Choice a]
-> Read (Choice a)
forall a. Read a => ReadPrec [Choice a]
forall a. Read a => ReadPrec (Choice a)
forall a. Read a => Int -> ReadS (Choice a)
forall a. Read a => ReadS [Choice a]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Choice a]
$creadListPrec :: forall a. Read a => ReadPrec [Choice a]
readPrec :: ReadPrec (Choice a)
$creadPrec :: forall a. Read a => ReadPrec (Choice a)
readList :: ReadS [Choice a]
$creadList :: forall a. Read a => ReadS [Choice a]
readsPrec :: Int -> ReadS (Choice a)
$creadsPrec :: forall a. Read a => Int -> ReadS (Choice a)
Read, Choice a -> Choice a -> Bool
(Choice a -> Choice a -> Bool)
-> (Choice a -> Choice a -> Bool) -> Eq (Choice a)
forall a. Eq a => Choice a -> Choice a -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Choice a -> Choice a -> Bool
$c/= :: forall a. Eq a => Choice a -> Choice a -> Bool
== :: Choice a -> Choice a -> Bool
$c== :: forall a. Eq a => Choice a -> Choice a -> Bool
Eq, Eq (Choice a)
Eq (Choice a)
-> (Choice a -> Choice a -> Ordering)
-> (Choice a -> Choice a -> Bool)
-> (Choice a -> Choice a -> Bool)
-> (Choice a -> Choice a -> Bool)
-> (Choice a -> Choice a -> Bool)
-> (Choice a -> Choice a -> Choice a)
-> (Choice a -> Choice a -> Choice a)
-> Ord (Choice a)
Choice a -> Choice a -> Bool
Choice a -> Choice a -> Ordering
Choice a -> Choice a -> Choice a
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall a. Ord a => Eq (Choice a)
forall a. Ord a => Choice a -> Choice a -> Bool
forall a. Ord a => Choice a -> Choice a -> Ordering
forall a. Ord a => Choice a -> Choice a -> Choice a
min :: Choice a -> Choice a -> Choice a
$cmin :: forall a. Ord a => Choice a -> Choice a -> Choice a
max :: Choice a -> Choice a -> Choice a
$cmax :: forall a. Ord a => Choice a -> Choice a -> Choice a
>= :: Choice a -> Choice a -> Bool
$c>= :: forall a. Ord a => Choice a -> Choice a -> Bool
> :: Choice a -> Choice a -> Bool
$c> :: forall a. Ord a => Choice a -> Choice a -> Bool
<= :: Choice a -> Choice a -> Bool
$c<= :: forall a. Ord a => Choice a -> Choice a -> Bool
< :: Choice a -> Choice a -> Bool
$c< :: forall a. Ord a => Choice a -> Choice a -> Bool
compare :: Choice a -> Choice a -> Ordering
$ccompare :: forall a. Ord a => Choice a -> Choice a -> Ordering
$cp1Ord :: forall a. Ord a => Eq (Choice a)
Ord)
instance Functor Choice where
fmap :: (a -> b) -> Choice a -> Choice b
fmap a -> b
f (Choice Text
s a
a) = Text -> b -> Choice b
forall a. Text -> a -> Choice a
Choice Text
s (a -> b
f a
a)
instance (ToJSON a) => ToJSON (Choice a) where
toJSON :: Choice a -> Value
toJSON Choice {a
Text
choiceValue :: a
choiceName :: Text
choiceValue :: forall a. Choice a -> a
choiceName :: forall a. Choice a -> Text
..} = [Pair] -> Value
object [(Text
"name", Text -> Value
forall a. ToJSON a => a -> Value
toJSON Text
choiceName), (Text
"value", a -> Value
forall a. ToJSON a => a -> Value
toJSON a
choiceValue)]
instance (FromJSON a) => FromJSON (Choice a) where
parseJSON :: Value -> Parser (Choice a)
parseJSON =
String
-> (Object -> Parser (Choice a)) -> Value -> Parser (Choice a)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject
String
"Choice"
( \Object
v ->
Text -> a -> Choice a
forall a. Text -> a -> Choice a
Choice
(Text -> a -> Choice a) -> Parser Text -> Parser (a -> Choice a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"name"
Parser (a -> Choice a) -> Parser a -> Parser (Choice a)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser a
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"value"
)
type AutocompleteOrChoice a = Either Bool [Choice a]
instance {-# OVERLAPPING #-} (FromJSON a) => FromJSON (AutocompleteOrChoice a) where
parseJSON :: Value -> Parser (AutocompleteOrChoice a)
parseJSON =
String
-> (Object -> Parser (AutocompleteOrChoice a))
-> Value
-> Parser (AutocompleteOrChoice a)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject
String
"AutocompleteOrChoice"
( \Object
v -> do
Maybe [Choice a]
mcs <- Object
v Object -> Text -> Parser (Maybe [Choice a])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:! Text
"choices"
case Maybe [Choice a]
mcs of
Maybe [Choice a]
Nothing -> Bool -> AutocompleteOrChoice a
forall a b. a -> Either a b
Left (Bool -> AutocompleteOrChoice a)
-> Parser Bool -> Parser (AutocompleteOrChoice a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
.:? Text
"autocomplete" Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
.!= Bool
False
Just [Choice a]
cs -> AutocompleteOrChoice a -> Parser (AutocompleteOrChoice a)
forall (m :: * -> *) a. Monad m => a -> m a
return (AutocompleteOrChoice a -> Parser (AutocompleteOrChoice a))
-> AutocompleteOrChoice a -> Parser (AutocompleteOrChoice a)
forall a b. (a -> b) -> a -> b
$ [Choice a] -> AutocompleteOrChoice a
forall a b. b -> Either a b
Right [Choice a]
cs
)
choiceOrAutocompleteToJSON :: (ToJSON a) => AutocompleteOrChoice a -> Pair
choiceOrAutocompleteToJSON :: AutocompleteOrChoice a -> Pair
choiceOrAutocompleteToJSON (Left Bool
b) = (Text
"autocomplete", Bool -> Value
forall a. ToJSON a => a -> Value
toJSON Bool
b)
choiceOrAutocompleteToJSON (Right [Choice a]
cs) = (Text
"choices", [Choice a] -> Value
forall a. ToJSON a => a -> Value
toJSON [Choice a]
cs)
data ApplicationCommandChannelType
=
ApplicationCommandChannelTypeGuildText
|
ApplicationCommandChannelTypeDM
|
ApplicationCommandChannelTypeGuildVoice
|
ApplicationCommandChannelTypeGroupDM
|
ApplicationCommandChannelTypeGuildCategory
|
ApplicationCommandChannelTypeGuildNews
|
ApplicationCommandChannelTypeGuildStore
|
ApplicationCommandChannelTypeGuildNewsThread
|
ApplicationCommandChannelTypeGuildPublicThread
|
ApplicationCommandChannelTypeGuildPrivateThread
|
ApplicationCommandChannelTypeGuildStageVoice
deriving (Int -> ApplicationCommandChannelType -> ShowS
[ApplicationCommandChannelType] -> ShowS
ApplicationCommandChannelType -> String
(Int -> ApplicationCommandChannelType -> ShowS)
-> (ApplicationCommandChannelType -> String)
-> ([ApplicationCommandChannelType] -> ShowS)
-> Show ApplicationCommandChannelType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationCommandChannelType] -> ShowS
$cshowList :: [ApplicationCommandChannelType] -> ShowS
show :: ApplicationCommandChannelType -> String
$cshow :: ApplicationCommandChannelType -> String
showsPrec :: Int -> ApplicationCommandChannelType -> ShowS
$cshowsPrec :: Int -> ApplicationCommandChannelType -> ShowS
Show, ReadPrec [ApplicationCommandChannelType]
ReadPrec ApplicationCommandChannelType
Int -> ReadS ApplicationCommandChannelType
ReadS [ApplicationCommandChannelType]
(Int -> ReadS ApplicationCommandChannelType)
-> ReadS [ApplicationCommandChannelType]
-> ReadPrec ApplicationCommandChannelType
-> ReadPrec [ApplicationCommandChannelType]
-> Read ApplicationCommandChannelType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplicationCommandChannelType]
$creadListPrec :: ReadPrec [ApplicationCommandChannelType]
readPrec :: ReadPrec ApplicationCommandChannelType
$creadPrec :: ReadPrec ApplicationCommandChannelType
readList :: ReadS [ApplicationCommandChannelType]
$creadList :: ReadS [ApplicationCommandChannelType]
readsPrec :: Int -> ReadS ApplicationCommandChannelType
$creadsPrec :: Int -> ReadS ApplicationCommandChannelType
Read, Typeable ApplicationCommandChannelType
DataType
Constr
Typeable ApplicationCommandChannelType
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ApplicationCommandChannelType
-> c ApplicationCommandChannelType)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c ApplicationCommandChannelType)
-> (ApplicationCommandChannelType -> Constr)
-> (ApplicationCommandChannelType -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c ApplicationCommandChannelType))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ApplicationCommandChannelType))
-> ((forall b. Data b => b -> b)
-> ApplicationCommandChannelType -> ApplicationCommandChannelType)
-> (forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> ApplicationCommandChannelType
-> r)
-> (forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> ApplicationCommandChannelType
-> r)
-> (forall u.
(forall d. Data d => d -> u)
-> ApplicationCommandChannelType -> [u])
-> (forall u.
Int
-> (forall d. Data d => d -> u)
-> ApplicationCommandChannelType
-> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ApplicationCommandChannelType
-> m ApplicationCommandChannelType)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ApplicationCommandChannelType
-> m ApplicationCommandChannelType)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ApplicationCommandChannelType
-> m ApplicationCommandChannelType)
-> Data ApplicationCommandChannelType
ApplicationCommandChannelType -> DataType
ApplicationCommandChannelType -> Constr
(forall b. Data b => b -> b)
-> ApplicationCommandChannelType -> ApplicationCommandChannelType
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ApplicationCommandChannelType
-> c ApplicationCommandChannelType
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c ApplicationCommandChannelType
forall a.
Typeable a
-> (forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u.
Int
-> (forall d. Data d => d -> u)
-> ApplicationCommandChannelType
-> u
forall u.
(forall d. Data d => d -> u)
-> ApplicationCommandChannelType -> [u]
forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> ApplicationCommandChannelType
-> r
forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> ApplicationCommandChannelType
-> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ApplicationCommandChannelType -> m ApplicationCommandChannelType
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ApplicationCommandChannelType -> m ApplicationCommandChannelType
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c ApplicationCommandChannelType
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ApplicationCommandChannelType
-> c ApplicationCommandChannelType
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c ApplicationCommandChannelType)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ApplicationCommandChannelType)
$cApplicationCommandChannelTypeGuildStageVoice :: Constr
$cApplicationCommandChannelTypeGuildPrivateThread :: Constr
$cApplicationCommandChannelTypeGuildPublicThread :: Constr
$cApplicationCommandChannelTypeGuildNewsThread :: Constr
$cApplicationCommandChannelTypeGuildStore :: Constr
$cApplicationCommandChannelTypeGuildNews :: Constr
$cApplicationCommandChannelTypeGuildCategory :: Constr
$cApplicationCommandChannelTypeGroupDM :: Constr
$cApplicationCommandChannelTypeGuildVoice :: Constr
$cApplicationCommandChannelTypeDM :: Constr
$cApplicationCommandChannelTypeGuildText :: Constr
$tApplicationCommandChannelType :: DataType
gmapMo :: (forall d. Data d => d -> m d)
-> ApplicationCommandChannelType -> m ApplicationCommandChannelType
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ApplicationCommandChannelType -> m ApplicationCommandChannelType
gmapMp :: (forall d. Data d => d -> m d)
-> ApplicationCommandChannelType -> m ApplicationCommandChannelType
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d)
-> ApplicationCommandChannelType -> m ApplicationCommandChannelType
gmapM :: (forall d. Data d => d -> m d)
-> ApplicationCommandChannelType -> m ApplicationCommandChannelType
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d)
-> ApplicationCommandChannelType -> m ApplicationCommandChannelType
gmapQi :: Int
-> (forall d. Data d => d -> u)
-> ApplicationCommandChannelType
-> u
$cgmapQi :: forall u.
Int
-> (forall d. Data d => d -> u)
-> ApplicationCommandChannelType
-> u
gmapQ :: (forall d. Data d => d -> u)
-> ApplicationCommandChannelType -> [u]
$cgmapQ :: forall u.
(forall d. Data d => d -> u)
-> ApplicationCommandChannelType -> [u]
gmapQr :: (r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> ApplicationCommandChannelType
-> r
$cgmapQr :: forall r r'.
(r' -> r -> r)
-> r
-> (forall d. Data d => d -> r')
-> ApplicationCommandChannelType
-> r
gmapQl :: (r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> ApplicationCommandChannelType
-> r
$cgmapQl :: forall r r'.
(r -> r' -> r)
-> r
-> (forall d. Data d => d -> r')
-> ApplicationCommandChannelType
-> r
gmapT :: (forall b. Data b => b -> b)
-> ApplicationCommandChannelType -> ApplicationCommandChannelType
$cgmapT :: (forall b. Data b => b -> b)
-> ApplicationCommandChannelType -> ApplicationCommandChannelType
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ApplicationCommandChannelType)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e))
-> Maybe (c ApplicationCommandChannelType)
dataCast1 :: (forall d. Data d => c (t d))
-> Maybe (c ApplicationCommandChannelType)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d))
-> Maybe (c ApplicationCommandChannelType)
dataTypeOf :: ApplicationCommandChannelType -> DataType
$cdataTypeOf :: ApplicationCommandChannelType -> DataType
toConstr :: ApplicationCommandChannelType -> Constr
$ctoConstr :: ApplicationCommandChannelType -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c ApplicationCommandChannelType
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r)
-> Constr
-> c ApplicationCommandChannelType
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ApplicationCommandChannelType
-> c ApplicationCommandChannelType
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g)
-> ApplicationCommandChannelType
-> c ApplicationCommandChannelType
$cp1Data :: Typeable ApplicationCommandChannelType
Data, ApplicationCommandChannelType
-> ApplicationCommandChannelType -> Bool
(ApplicationCommandChannelType
-> ApplicationCommandChannelType -> Bool)
-> (ApplicationCommandChannelType
-> ApplicationCommandChannelType -> Bool)
-> Eq ApplicationCommandChannelType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationCommandChannelType
-> ApplicationCommandChannelType -> Bool
$c/= :: ApplicationCommandChannelType
-> ApplicationCommandChannelType -> Bool
== :: ApplicationCommandChannelType
-> ApplicationCommandChannelType -> Bool
$c== :: ApplicationCommandChannelType
-> ApplicationCommandChannelType -> Bool
Eq)
instance InternalDiscordEnum ApplicationCommandChannelType where
discordTypeStartValue :: ApplicationCommandChannelType
discordTypeStartValue = ApplicationCommandChannelType
ApplicationCommandChannelTypeGuildText
fromDiscordType :: ApplicationCommandChannelType -> Int
fromDiscordType ApplicationCommandChannelType
ApplicationCommandChannelTypeGuildText = Int
0
fromDiscordType ApplicationCommandChannelType
ApplicationCommandChannelTypeDM = Int
1
fromDiscordType ApplicationCommandChannelType
ApplicationCommandChannelTypeGuildVoice = Int
2
fromDiscordType ApplicationCommandChannelType
ApplicationCommandChannelTypeGroupDM = Int
3
fromDiscordType ApplicationCommandChannelType
ApplicationCommandChannelTypeGuildCategory = Int
4
fromDiscordType ApplicationCommandChannelType
ApplicationCommandChannelTypeGuildNews = Int
5
fromDiscordType ApplicationCommandChannelType
ApplicationCommandChannelTypeGuildStore = Int
6
fromDiscordType ApplicationCommandChannelType
ApplicationCommandChannelTypeGuildNewsThread = Int
10
fromDiscordType ApplicationCommandChannelType
ApplicationCommandChannelTypeGuildPublicThread = Int
11
fromDiscordType ApplicationCommandChannelType
ApplicationCommandChannelTypeGuildPrivateThread = Int
12
fromDiscordType ApplicationCommandChannelType
ApplicationCommandChannelTypeGuildStageVoice = Int
13
instance ToJSON ApplicationCommandChannelType where
toJSON :: ApplicationCommandChannelType -> Value
toJSON = Int -> Value
forall a. ToJSON a => a -> Value
toJSON (Int -> Value)
-> (ApplicationCommandChannelType -> Int)
-> ApplicationCommandChannelType
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ApplicationCommandChannelType -> Int
forall a. InternalDiscordEnum a => a -> Int
fromDiscordType
instance FromJSON ApplicationCommandChannelType where
parseJSON :: Value -> Parser ApplicationCommandChannelType
parseJSON = String -> Value -> Parser ApplicationCommandChannelType
forall a. InternalDiscordEnum a => String -> Value -> Parser a
discordTypeParseJSON String
"ApplicationCommandChannelType"
data GuildApplicationCommandPermissions = GuildApplicationCommandPermissions
{
GuildApplicationCommandPermissions -> ApplicationCommandId
guildApplicationCommandPermissionsId :: ApplicationCommandId,
GuildApplicationCommandPermissions -> ApplicationId
guildApplicationCommandPermissionsApplicationId :: ApplicationId,
GuildApplicationCommandPermissions -> GuildId
guildApplicationCommandPermissionsGuildId :: GuildId,
GuildApplicationCommandPermissions
-> [ApplicationCommandPermissions]
guildApplicationCommandPermissionsPermissions :: [ApplicationCommandPermissions]
}
deriving (Int -> GuildApplicationCommandPermissions -> ShowS
[GuildApplicationCommandPermissions] -> ShowS
GuildApplicationCommandPermissions -> String
(Int -> GuildApplicationCommandPermissions -> ShowS)
-> (GuildApplicationCommandPermissions -> String)
-> ([GuildApplicationCommandPermissions] -> ShowS)
-> Show GuildApplicationCommandPermissions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GuildApplicationCommandPermissions] -> ShowS
$cshowList :: [GuildApplicationCommandPermissions] -> ShowS
show :: GuildApplicationCommandPermissions -> String
$cshow :: GuildApplicationCommandPermissions -> String
showsPrec :: Int -> GuildApplicationCommandPermissions -> ShowS
$cshowsPrec :: Int -> GuildApplicationCommandPermissions -> ShowS
Show, ReadPrec [GuildApplicationCommandPermissions]
ReadPrec GuildApplicationCommandPermissions
Int -> ReadS GuildApplicationCommandPermissions
ReadS [GuildApplicationCommandPermissions]
(Int -> ReadS GuildApplicationCommandPermissions)
-> ReadS [GuildApplicationCommandPermissions]
-> ReadPrec GuildApplicationCommandPermissions
-> ReadPrec [GuildApplicationCommandPermissions]
-> Read GuildApplicationCommandPermissions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GuildApplicationCommandPermissions]
$creadListPrec :: ReadPrec [GuildApplicationCommandPermissions]
readPrec :: ReadPrec GuildApplicationCommandPermissions
$creadPrec :: ReadPrec GuildApplicationCommandPermissions
readList :: ReadS [GuildApplicationCommandPermissions]
$creadList :: ReadS [GuildApplicationCommandPermissions]
readsPrec :: Int -> ReadS GuildApplicationCommandPermissions
$creadsPrec :: Int -> ReadS GuildApplicationCommandPermissions
Read, GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
(GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool)
-> (GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool)
-> Eq GuildApplicationCommandPermissions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
$c/= :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
== :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
$c== :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
Eq, Eq GuildApplicationCommandPermissions
Eq GuildApplicationCommandPermissions
-> (GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Ordering)
-> (GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool)
-> (GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool)
-> (GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool)
-> (GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool)
-> (GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions)
-> (GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions)
-> Ord GuildApplicationCommandPermissions
GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Ordering
GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
$cmin :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
max :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
$cmax :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions
>= :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
$c>= :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
> :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
$c> :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
<= :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
$c<= :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
< :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
$c< :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Bool
compare :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Ordering
$ccompare :: GuildApplicationCommandPermissions
-> GuildApplicationCommandPermissions -> Ordering
$cp1Ord :: Eq GuildApplicationCommandPermissions
Ord)
instance FromJSON GuildApplicationCommandPermissions where
parseJSON :: Value -> Parser GuildApplicationCommandPermissions
parseJSON =
String
-> (Object -> Parser GuildApplicationCommandPermissions)
-> Value
-> Parser GuildApplicationCommandPermissions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject
String
"GuildApplicationCommandPermissions"
( \Object
v ->
ApplicationCommandId
-> ApplicationId
-> GuildId
-> [ApplicationCommandPermissions]
-> GuildApplicationCommandPermissions
GuildApplicationCommandPermissions
(ApplicationCommandId
-> ApplicationId
-> GuildId
-> [ApplicationCommandPermissions]
-> GuildApplicationCommandPermissions)
-> Parser ApplicationCommandId
-> Parser
(ApplicationId
-> GuildId
-> [ApplicationCommandPermissions]
-> GuildApplicationCommandPermissions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Text -> Parser ApplicationCommandId
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"id"
Parser
(ApplicationId
-> GuildId
-> [ApplicationCommandPermissions]
-> GuildApplicationCommandPermissions)
-> Parser ApplicationId
-> Parser
(GuildId
-> [ApplicationCommandPermissions]
-> GuildApplicationCommandPermissions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser ApplicationId
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"application_id"
Parser
(GuildId
-> [ApplicationCommandPermissions]
-> GuildApplicationCommandPermissions)
-> Parser GuildId
-> Parser
([ApplicationCommandPermissions]
-> GuildApplicationCommandPermissions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser GuildId
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"guild_id"
Parser
([ApplicationCommandPermissions]
-> GuildApplicationCommandPermissions)
-> Parser [ApplicationCommandPermissions]
-> Parser GuildApplicationCommandPermissions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser [ApplicationCommandPermissions]
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"permissions"
)
instance ToJSON GuildApplicationCommandPermissions where
toJSON :: GuildApplicationCommandPermissions -> Value
toJSON GuildApplicationCommandPermissions {[ApplicationCommandPermissions]
ApplicationCommandId
ApplicationId
GuildId
guildApplicationCommandPermissionsPermissions :: [ApplicationCommandPermissions]
guildApplicationCommandPermissionsGuildId :: GuildId
guildApplicationCommandPermissionsApplicationId :: ApplicationId
guildApplicationCommandPermissionsId :: ApplicationCommandId
guildApplicationCommandPermissionsPermissions :: GuildApplicationCommandPermissions
-> [ApplicationCommandPermissions]
guildApplicationCommandPermissionsGuildId :: GuildApplicationCommandPermissions -> GuildId
guildApplicationCommandPermissionsApplicationId :: GuildApplicationCommandPermissions -> ApplicationId
guildApplicationCommandPermissionsId :: GuildApplicationCommandPermissions -> ApplicationCommandId
..} =
[Pair] -> Value
object
[ (Text
name, Value
value)
| (Text
name, Just Value
value) <-
[ (Text
"id", ApplicationCommandId -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON ApplicationCommandId
guildApplicationCommandPermissionsId),
(Text
"application_id", ApplicationId -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON ApplicationId
guildApplicationCommandPermissionsApplicationId),
(Text
"guild_id", GuildId -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON GuildId
guildApplicationCommandPermissionsGuildId),
(Text
"permissions", [ApplicationCommandPermissions] -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON [ApplicationCommandPermissions]
guildApplicationCommandPermissionsPermissions)
]
]
data ApplicationCommandPermissions = ApplicationCommandPermissions
{
ApplicationCommandPermissions -> Snowflake
applicationCommandPermissionsId :: Snowflake,
ApplicationCommandPermissions -> Integer
applicationCommandPermissionsType :: Integer,
ApplicationCommandPermissions -> Bool
applicationCommandPermissionsPermission :: Bool
}
deriving (Int -> ApplicationCommandPermissions -> ShowS
[ApplicationCommandPermissions] -> ShowS
ApplicationCommandPermissions -> String
(Int -> ApplicationCommandPermissions -> ShowS)
-> (ApplicationCommandPermissions -> String)
-> ([ApplicationCommandPermissions] -> ShowS)
-> Show ApplicationCommandPermissions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ApplicationCommandPermissions] -> ShowS
$cshowList :: [ApplicationCommandPermissions] -> ShowS
show :: ApplicationCommandPermissions -> String
$cshow :: ApplicationCommandPermissions -> String
showsPrec :: Int -> ApplicationCommandPermissions -> ShowS
$cshowsPrec :: Int -> ApplicationCommandPermissions -> ShowS
Show, ReadPrec [ApplicationCommandPermissions]
ReadPrec ApplicationCommandPermissions
Int -> ReadS ApplicationCommandPermissions
ReadS [ApplicationCommandPermissions]
(Int -> ReadS ApplicationCommandPermissions)
-> ReadS [ApplicationCommandPermissions]
-> ReadPrec ApplicationCommandPermissions
-> ReadPrec [ApplicationCommandPermissions]
-> Read ApplicationCommandPermissions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ApplicationCommandPermissions]
$creadListPrec :: ReadPrec [ApplicationCommandPermissions]
readPrec :: ReadPrec ApplicationCommandPermissions
$creadPrec :: ReadPrec ApplicationCommandPermissions
readList :: ReadS [ApplicationCommandPermissions]
$creadList :: ReadS [ApplicationCommandPermissions]
readsPrec :: Int -> ReadS ApplicationCommandPermissions
$creadsPrec :: Int -> ReadS ApplicationCommandPermissions
Read, ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
(ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool)
-> (ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool)
-> Eq ApplicationCommandPermissions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
$c/= :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
== :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
$c== :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
Eq, Eq ApplicationCommandPermissions
Eq ApplicationCommandPermissions
-> (ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Ordering)
-> (ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool)
-> (ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool)
-> (ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool)
-> (ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool)
-> (ApplicationCommandPermissions
-> ApplicationCommandPermissions -> ApplicationCommandPermissions)
-> (ApplicationCommandPermissions
-> ApplicationCommandPermissions -> ApplicationCommandPermissions)
-> Ord ApplicationCommandPermissions
ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Ordering
ApplicationCommandPermissions
-> ApplicationCommandPermissions -> ApplicationCommandPermissions
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> ApplicationCommandPermissions
$cmin :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> ApplicationCommandPermissions
max :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> ApplicationCommandPermissions
$cmax :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> ApplicationCommandPermissions
>= :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
$c>= :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
> :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
$c> :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
<= :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
$c<= :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
< :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
$c< :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Bool
compare :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Ordering
$ccompare :: ApplicationCommandPermissions
-> ApplicationCommandPermissions -> Ordering
$cp1Ord :: Eq ApplicationCommandPermissions
Ord)
instance FromJSON ApplicationCommandPermissions where
parseJSON :: Value -> Parser ApplicationCommandPermissions
parseJSON =
String
-> (Object -> Parser ApplicationCommandPermissions)
-> Value
-> Parser ApplicationCommandPermissions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject
String
"ApplicationCommandPermissions"
( \Object
v ->
Snowflake -> Integer -> Bool -> ApplicationCommandPermissions
ApplicationCommandPermissions
(Snowflake -> Integer -> Bool -> ApplicationCommandPermissions)
-> Parser Snowflake
-> Parser (Integer -> Bool -> ApplicationCommandPermissions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Text -> Parser Snowflake
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"id"
Parser (Integer -> Bool -> ApplicationCommandPermissions)
-> Parser Integer -> Parser (Bool -> ApplicationCommandPermissions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser Integer
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"type"
Parser (Bool -> ApplicationCommandPermissions)
-> Parser Bool -> Parser ApplicationCommandPermissions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
.: Text
"permission"
)
instance ToJSON ApplicationCommandPermissions where
toJSON :: ApplicationCommandPermissions -> Value
toJSON ApplicationCommandPermissions {Bool
Integer
Snowflake
applicationCommandPermissionsPermission :: Bool
applicationCommandPermissionsType :: Integer
applicationCommandPermissionsId :: Snowflake
applicationCommandPermissionsPermission :: ApplicationCommandPermissions -> Bool
applicationCommandPermissionsType :: ApplicationCommandPermissions -> Integer
applicationCommandPermissionsId :: ApplicationCommandPermissions -> Snowflake
..} =
[Pair] -> Value
object
[ (Text
name, Value
value)
| (Text
name, Just Value
value) <-
[ (Text
"id", Snowflake -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Snowflake
applicationCommandPermissionsId),
(Text
"type", Integer -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Integer
applicationCommandPermissionsType),
(Text
"permission", Bool -> Maybe Value
forall a. ToJSON a => a -> Maybe Value
toMaybeJSON Bool
applicationCommandPermissionsPermission)
]
]