discord-haskell 1.8.0 → 1.8.1
raw patch · 14 files changed
+51/−56 lines, 14 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Discord.Internal.Types.Guild: Emoji :: Maybe EmojiId -> Text -> Maybe [RoleId] -> Maybe User -> Maybe Bool -> Emoji
- Discord.Internal.Types.Guild: [emojiId] :: Emoji -> Maybe EmojiId
- Discord.Internal.Types.Guild: [emojiManaged] :: Emoji -> Maybe Bool
- Discord.Internal.Types.Guild: [emojiName] :: Emoji -> Text
- Discord.Internal.Types.Guild: [emojiRoles] :: Emoji -> Maybe [RoleId]
- Discord.Internal.Types.Guild: [emojiUser] :: Emoji -> Maybe User
- Discord.Internal.Types.Guild: data Emoji
- Discord.Internal.Types.Guild: instance Data.Aeson.Types.FromJSON.FromJSON Discord.Internal.Types.Guild.Emoji
- Discord.Internal.Types.Guild: instance GHC.Classes.Eq Discord.Internal.Types.Guild.Emoji
- Discord.Internal.Types.Guild: instance GHC.Classes.Ord Discord.Internal.Types.Guild.Emoji
- Discord.Internal.Types.Guild: instance GHC.Show.Show Discord.Internal.Types.Guild.Emoji
+ Discord.Internal.Rest.Prelude: baseUrl :: Url 'Https
+ Discord.Internal.Types.Channel: Emoji :: Maybe EmojiId -> Text -> Maybe [RoleId] -> Maybe User -> Maybe Bool -> Emoji
+ Discord.Internal.Types.Channel: MessageReaction :: Int -> Bool -> Emoji -> MessageReaction
+ Discord.Internal.Types.Channel: [emojiId] :: Emoji -> Maybe EmojiId
+ Discord.Internal.Types.Channel: [emojiManaged] :: Emoji -> Maybe Bool
+ Discord.Internal.Types.Channel: [emojiName] :: Emoji -> Text
+ Discord.Internal.Types.Channel: [emojiRoles] :: Emoji -> Maybe [RoleId]
+ Discord.Internal.Types.Channel: [emojiUser] :: Emoji -> Maybe User
+ Discord.Internal.Types.Channel: [messageReactionCount] :: MessageReaction -> Int
+ Discord.Internal.Types.Channel: [messageReactionEmoji] :: MessageReaction -> Emoji
+ Discord.Internal.Types.Channel: [messageReactionMeIncluded] :: MessageReaction -> Bool
+ Discord.Internal.Types.Channel: [messageReactions] :: Message -> [MessageReaction]
+ Discord.Internal.Types.Channel: data Emoji
+ Discord.Internal.Types.Channel: data MessageReaction
+ Discord.Internal.Types.Channel: instance Data.Aeson.Types.FromJSON.FromJSON Discord.Internal.Types.Channel.Emoji
+ Discord.Internal.Types.Channel: instance Data.Aeson.Types.FromJSON.FromJSON Discord.Internal.Types.Channel.MessageReaction
+ Discord.Internal.Types.Channel: instance GHC.Classes.Eq Discord.Internal.Types.Channel.Emoji
+ Discord.Internal.Types.Channel: instance GHC.Classes.Eq Discord.Internal.Types.Channel.MessageReaction
+ Discord.Internal.Types.Channel: instance GHC.Classes.Ord Discord.Internal.Types.Channel.Emoji
+ Discord.Internal.Types.Channel: instance GHC.Classes.Ord Discord.Internal.Types.Channel.MessageReaction
+ Discord.Internal.Types.Channel: instance GHC.Show.Show Discord.Internal.Types.Channel.Emoji
+ Discord.Internal.Types.Channel: instance GHC.Show.Show Discord.Internal.Types.Channel.MessageReaction
- Discord.Internal.Rest.HTTP: [Delete] :: Url 'Https -> Option 'Https -> JsonRequest
+ Discord.Internal.Rest.HTTP: [Delete] :: Url 'Https -> Option 'Https -> JsonRequest
- Discord.Internal.Rest.HTTP: [Get] :: Url 'Https -> Option 'Https -> JsonRequest
+ Discord.Internal.Rest.HTTP: [Get] :: Url 'Https -> Option 'Https -> JsonRequest
- Discord.Internal.Rest.HTTP: [Patch] :: HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest
+ Discord.Internal.Rest.HTTP: [Patch] :: HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest
- Discord.Internal.Rest.HTTP: [Post] :: HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest
+ Discord.Internal.Rest.HTTP: [Post] :: HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest
- Discord.Internal.Rest.HTTP: [Put] :: HttpBody a => Url 'Https -> a -> Option 'Https -> JsonRequest
+ Discord.Internal.Rest.HTTP: [Put] :: HttpBody a => Url 'Https -> a -> Option 'Https -> JsonRequest
- Discord.Internal.Rest.Prelude: [Delete] :: Url 'Https -> Option 'Https -> JsonRequest
+ Discord.Internal.Rest.Prelude: [Delete] :: Url 'Https -> Option 'Https -> JsonRequest
- Discord.Internal.Rest.Prelude: [Get] :: Url 'Https -> Option 'Https -> JsonRequest
+ Discord.Internal.Rest.Prelude: [Get] :: Url 'Https -> Option 'Https -> JsonRequest
- Discord.Internal.Rest.Prelude: [Patch] :: HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest
+ Discord.Internal.Rest.Prelude: [Patch] :: HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest
- Discord.Internal.Rest.Prelude: [Post] :: HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest
+ Discord.Internal.Rest.Prelude: [Post] :: HttpBody a => Url 'Https -> RestIO a -> Option 'Https -> JsonRequest
- Discord.Internal.Rest.Prelude: [Put] :: HttpBody a => Url 'Https -> a -> Option 'Https -> JsonRequest
+ Discord.Internal.Rest.Prelude: [Put] :: HttpBody a => Url 'Https -> a -> Option 'Https -> JsonRequest
- Discord.Internal.Rest.Prelude: authHeader :: Auth -> Option 'Https
+ Discord.Internal.Rest.Prelude: authHeader :: Auth -> Option 'Https
- Discord.Internal.Types.Channel: Message :: MessageId -> ChannelId -> User -> Text -> UTCTime -> Maybe UTCTime -> Bool -> Bool -> [User] -> [RoleId] -> [Attachment] -> [Embed] -> Maybe Nonce -> Bool -> Maybe GuildId -> Message
+ Discord.Internal.Types.Channel: Message :: MessageId -> ChannelId -> User -> Text -> UTCTime -> Maybe UTCTime -> Bool -> Bool -> [User] -> [RoleId] -> [Attachment] -> [Embed] -> [MessageReaction] -> Maybe Nonce -> Bool -> Maybe GuildId -> Message
Files
- README.md +4/−1
- changelog.md +5/−0
- discord-haskell.cabal +1/−1
- src/Discord.hs +1/−1
- src/Discord/Internal/Rest/Channel.hs +0/−5
- src/Discord/Internal/Rest/Emoji.hs +0/−5
- src/Discord/Internal/Rest/Guild.hs +0/−5
- src/Discord/Internal/Rest/Invite.hs +0/−5
- src/Discord/Internal/Rest/Prelude.hs +6/−1
- src/Discord/Internal/Rest/User.hs +0/−5
- src/Discord/Internal/Rest/Voice.hs +0/−5
- src/Discord/Internal/Rest/Webhook.hs +0/−5
- src/Discord/Internal/Types/Channel.hs +33/−0
- src/Discord/Internal/Types/Guild.hs +1/−17
README.md view
@@ -1,6 +1,9 @@ # discord-haskell [](https://travis-ci.org/aquarial/discord-haskell) [](https://hackage.haskell.org/package/discord-haskell) -Build that discord bot in Haskell! This is an example bot that replies "pong" to messages that start with "ping".+Build that discord bot in Haskell! Also checkout the [calamity](https://github.com/nitros12/calamity) +haskell discord library for a more advanced interface than `discord-haskell`.++This is an example bot that replies "pong" to messages that start with "ping". ```haskell {-# LANGUAGE OverloadedStrings #-} -- allows "string literals" to be Text
changelog.md view
@@ -4,6 +4,11 @@ Discord API changes, so use the most recent version at all times ++## 1.8.1++Added `MessageReaction` to Message https://github.com/aquarial/discord-haskell/issues/56+ ## 1.8.0 Fixed [null parent_id on channel](https://github.com/aquarial/discord-haskell/issues/55)
discord-haskell.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.0 name: discord-haskell -- library version is also noted at src/Discord/Rest/Prelude.hs-version: 1.8.0+version: 1.8.1 description: Functions and data types to write discord bots. Official discord docs <https://discord.com/developers/docs/reference>. .
src/Discord.hs view
@@ -20,7 +20,7 @@ ) where import Prelude hiding (log)-import Control.Monad.Reader+import Control.Monad.Reader (ReaderT, runReaderT, void, ask, liftIO, forever) import Data.Aeson (FromJSON) import Data.Default (Default, def) import qualified Data.Text as T
src/Discord/Internal/Rest/Channel.hs view
@@ -226,11 +226,6 @@ , ("footer.png", createEmbedFooterIcon) ]] in maybe [] (map mkPart . uploads) --- | The base url (Req) for API requests-baseUrl :: R.Url 'R.Https-baseUrl = R.https "discord.com" R./: "api" R./: apiVersion- where apiVersion = "v6"- channels :: R.Url 'R.Https channels = baseUrl /: "channels"
src/Discord/Internal/Rest/Emoji.hs view
@@ -84,11 +84,6 @@ (ModifyGuildEmoji g _ _) -> "emoji " <> show g (DeleteGuildEmoji g _) -> "emoji " <> show g --- | The base url (Req) for API requests-baseUrl :: R.Url 'R.Https-baseUrl = R.https "discord.com" R./: "api" R./: apiVersion- where apiVersion = "v6"- guilds :: R.Url 'R.Https guilds = baseUrl /: "guilds"
src/Discord/Internal/Rest/Guild.hs view
@@ -339,11 +339,6 @@ (GetGuildVanityURL g) -> "guild " <> show g --- | The base url (Req) for API requests-baseUrl :: R.Url 'R.Https-baseUrl = R.https "discord.com" R./: "api" R./: apiVersion- where apiVersion = "v6"- guilds :: R.Url 'R.Https guilds = baseUrl /: "guilds"
src/Discord/Internal/Rest/Invite.hs view
@@ -34,11 +34,6 @@ (GetInvite _) -> "invite " (DeleteInvite _) -> "invite " --- | The base url (Req) for API requests-baseUrl :: R.Url 'R.Https-baseUrl = R.https "discord.com" R./: "api" R./: apiVersion- where apiVersion = "v6"- invite :: R.Url 'R.Https invite = baseUrl /: "invites"
src/Discord/Internal/Rest/Prelude.hs view
@@ -16,6 +16,11 @@ import Discord.Internal.Types +-- | The base url (Req) for API requests+baseUrl :: R.Url 'R.Https+baseUrl = R.https "discord.com" R./: "api" R./: apiVersion+ where apiVersion = "v6"+ -- | Discord requires HTTP headers for authentication. authHeader :: Auth -> R.Option 'R.Https authHeader auth =@@ -24,7 +29,7 @@ where -- | https://discord.com/developers/docs/reference#user-agent -- Second place where the library version is noted- agent = "DiscordBot (https://github.com/aquarial/discord-haskell, 1.8.0)"+ agent = "DiscordBot (https://github.com/aquarial/discord-haskell, 1.8.1)" -- Append to an URL infixl 5 //
src/Discord/Internal/Rest/User.hs view
@@ -74,11 +74,6 @@ (CreateDM _) -> "make_dm " (GetUserConnections) -> "connections " --- | The base url (Req) for API requests-baseUrl :: R.Url 'R.Https-baseUrl = R.https "discord.com" R./: "api" R./: apiVersion- where apiVersion = "v6"- users :: R.Url 'R.Https users = baseUrl /: "users"
src/Discord/Internal/Rest/Voice.hs view
@@ -28,11 +28,6 @@ voiceMajorRoute c = case c of (ListVoiceRegions) -> "whatever " --- | The base url (Req) for API requests-baseUrl :: R.Url 'R.Https-baseUrl = R.https "discord.com" R./: "api" R./: apiVersion- where apiVersion = "v6"- voices :: R.Url 'R.Https voices = baseUrl /: "voice"
src/Discord/Internal/Rest/Webhook.hs view
@@ -102,11 +102,6 @@ (DeleteWebhookWithToken w _) -> "deletehook " <> show w (ExecuteWebhookWithToken w _ _) -> "executehk " <> show w --- | The base url (Req) for API requests-baseUrl :: R.Url 'R.Https-baseUrl = R.https "discord.com" R./: "api" R./: apiVersion- where apiVersion = "v6"- webhookJsonRequest :: WebhookRequest r -> JsonRequest webhookJsonRequest ch = case ch of (CreateWebhook channel patch) ->
src/Discord/Internal/Types/Channel.hs view
@@ -245,6 +245,7 @@ -- the message , messageAttachments :: [Attachment] -- ^ Any attached files , messageEmbeds :: [Embed] -- ^ Any embedded content+ , messageReactions :: [MessageReaction] -- ^ Any reactions to message , messageNonce :: Maybe Nonce -- ^ Used for validating if a message -- was sent , messagePinned :: Bool -- ^ Whether this message is pinned@@ -269,10 +270,42 @@ <*> o .:? "mention_roles" .!= [] <*> o .:? "attachments" .!= [] <*> o .: "embeds"+ <*> o .:? "reactions" .!= [] <*> o .:? "nonce" <*> o .:? "pinned" .!= False <*> o .:? "guild_id" .!= Nothing ++data MessageReaction = MessageReaction+ { messageReactionCount :: Int+ , messageReactionMeIncluded :: Bool+ , messageReactionEmoji :: Emoji+ } deriving (Show, Eq, Ord)++instance FromJSON MessageReaction where+ parseJSON = withObject "MessageReaction" $ \o ->+ MessageReaction <$> o .: "count"+ <*> o .: "me"+ <*> o .: "emoji"++-- | Represents an emoticon (emoji)+data Emoji = Emoji+ { emojiId :: Maybe EmojiId -- ^ The emoji id+ , emojiName :: T.Text -- ^ The emoji name+ , emojiRoles :: Maybe [RoleId] -- ^ Roles the emoji is active for+ , emojiUser :: Maybe User -- ^ User that created this emoji+ , emojiManaged :: Maybe Bool -- ^ Whether this emoji is managed+ } deriving (Show, Eq, Ord)++instance FromJSON Emoji where+ parseJSON = withObject "Emoji" $ \o ->+ Emoji <$> o .: "id"+ <*> o .: "name"+ <*> o .:? "roles"+ <*> o .:? "user"+ <*> o .:? "managed"++ -- | Represents an attached to a message file. data Attachment = Attachment { attachmentId :: Snowflake -- ^ Attachment id
src/Discord/Internal/Types/Guild.hs view
@@ -9,7 +9,7 @@ import qualified Data.Text as T import Discord.Internal.Types.Prelude-import Discord.Internal.Types.Channel (Channel)+import Discord.Internal.Types.Channel (Channel, Emoji) import Discord.Internal.Types.User (User) -- | Representation of a guild member.@@ -123,22 +123,6 @@ <*> o .:? "owner" .!= False <*> o .: "permissions" --- | Represents an emoticon (emoji)-data Emoji = Emoji- { emojiId :: Maybe EmojiId -- ^ The emoji id- , emojiName :: T.Text -- ^ The emoji name- , emojiRoles :: Maybe [RoleId] -- ^ Roles the emoji is active for- , emojiUser :: Maybe User -- ^ User that created this emoji- , emojiManaged :: Maybe Bool -- ^ Whether this emoji is managed- } deriving (Show, Eq, Ord)--instance FromJSON Emoji where- parseJSON = withObject "Emoji" $ \o ->- Emoji <$> o .: "id"- <*> o .: "name"- <*> o .:? "roles"- <*> o .:? "user"- <*> o .:? "managed" -- | Roles represent a set of permissions attached to a group of users. Roles have unique -- names, colors, and can be "pinned" to the side bar, causing their members to be listed separately.