packages feed

discord-haskell 1.2.0 → 1.3.0

raw patch · 10 files changed

+57/−17 lines, 10 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Discord.Internal.Types.Guild: Ban :: Text -> User -> Ban
- Discord.Internal.Types.Guild: [banReason] :: Ban -> Text
- Discord.Internal.Types.Guild: [banUser] :: Ban -> User
- Discord.Internal.Types.Guild: data Ban
- Discord.Internal.Types.Guild: instance Data.Aeson.Types.FromJSON.FromJSON Discord.Internal.Types.Guild.Ban
- Discord.Internal.Types.Guild: instance GHC.Classes.Eq Discord.Internal.Types.Guild.Ban
- Discord.Internal.Types.Guild: instance GHC.Classes.Ord Discord.Internal.Types.Guild.Ban
- Discord.Internal.Types.Guild: instance GHC.Show.Show Discord.Internal.Types.Guild.Ban
+ Discord.Internal.Rest.Channel: LatestReaction :: ReactionTiming
+ Discord.Internal.Rest.Channel: [DeleteSingleReaction] :: (ChannelId, MessageId) -> Text -> ChannelRequest ()
+ Discord.Internal.Types: UTCTime :: Day -> DiffTime -> UTCTime
+ Discord.Internal.Types: [utctDayTime] :: UTCTime -> DiffTime
+ Discord.Internal.Types: [utctDay] :: UTCTime -> Day
+ Discord.Internal.Types: data UTCTime
+ Discord.Internal.Types.Events: MessageReactionRemoveEmoji :: ReactionRemoveInfo -> Event
+ Discord.Internal.Types.Events: ReactionRemoveInfo :: ChannelId -> GuildId -> MessageId -> Emoji -> ReactionRemoveInfo
+ Discord.Internal.Types.Events: [reactionGuildId] :: ReactionInfo -> Maybe GuildId
+ Discord.Internal.Types.Events: [reactionRemoveChannelId] :: ReactionRemoveInfo -> ChannelId
+ Discord.Internal.Types.Events: [reactionRemoveEmoji] :: ReactionRemoveInfo -> Emoji
+ Discord.Internal.Types.Events: [reactionRemoveGuildId] :: ReactionRemoveInfo -> GuildId
+ Discord.Internal.Types.Events: [reactionRemoveMessageId] :: ReactionRemoveInfo -> MessageId
+ Discord.Internal.Types.Events: data ReactionRemoveInfo
+ Discord.Internal.Types.Events: instance Data.Aeson.Types.FromJSON.FromJSON Discord.Internal.Types.Events.ReactionRemoveInfo
+ Discord.Internal.Types.Events: instance GHC.Classes.Eq Discord.Internal.Types.Events.ReactionRemoveInfo
+ Discord.Internal.Types.Events: instance GHC.Classes.Ord Discord.Internal.Types.Events.ReactionRemoveInfo
+ Discord.Internal.Types.Events: instance GHC.Show.Show Discord.Internal.Types.Events.ReactionRemoveInfo
+ Discord.Internal.Types.Guild: GuildBan :: Text -> User -> GuildBan
+ Discord.Internal.Types.Guild: [guildBanReason] :: GuildBan -> Text
+ Discord.Internal.Types.Guild: [guildBanUser] :: GuildBan -> User
+ Discord.Internal.Types.Guild: data GuildBan
+ Discord.Internal.Types.Guild: instance Data.Aeson.Types.FromJSON.FromJSON Discord.Internal.Types.Guild.GuildBan
+ Discord.Internal.Types.Guild: instance GHC.Classes.Eq Discord.Internal.Types.Guild.GuildBan
+ Discord.Internal.Types.Guild: instance GHC.Classes.Ord Discord.Internal.Types.Guild.GuildBan
+ Discord.Internal.Types.Guild: instance GHC.Show.Show Discord.Internal.Types.Guild.GuildBan
- Discord.Internal.Rest.Channel: [GetReactions] :: (ChannelId, MessageId) -> Text -> (Int, ReactionTiming) -> ChannelRequest ()
+ Discord.Internal.Rest.Channel: [GetReactions] :: (ChannelId, MessageId) -> Text -> (Int, ReactionTiming) -> ChannelRequest [User]
- Discord.Internal.Rest.Guild: [GetGuildBan] :: GuildId -> UserId -> GuildRequest Ban
+ Discord.Internal.Rest.Guild: [GetGuildBan] :: GuildId -> UserId -> GuildRequest GuildBan
- Discord.Internal.Rest.Guild: [GetGuildBans] :: GuildId -> GuildRequest [Ban]
+ Discord.Internal.Rest.Guild: [GetGuildBans] :: GuildId -> GuildRequest [GuildBan]
- Discord.Internal.Types.Events: ReactionInfo :: UserId -> ChannelId -> MessageId -> Emoji -> ReactionInfo
+ Discord.Internal.Types.Events: ReactionInfo :: UserId -> Maybe GuildId -> ChannelId -> MessageId -> Emoji -> ReactionInfo

Files

README.md view
@@ -44,8 +44,9 @@  ```yaml extra-deps:-- discord-haskell-1.1.3 - emoji-0.1.0.2+- discord-haskell-1.2.0+    # check hackage for the most recent version ```  In `project.cabal`
changelog.md view
@@ -5,6 +5,16 @@ ## master  +## 1.3.0++[PixeLinc](https://github.com/aquarial/discord-haskell/pull/33) Add `DeleteSingleReaction` rest-request, Add GuildId to `ReactinInfo`, Add `MESSAGE_REACTION_REMOVE_EMOJI` gateway event++`GetReactions` actually returns the User objects request++Rename `Ban` to `GuildBan`++Re-export UTCTime from `time` package+ ## 1.2.0  [MDeltaX](https://github.com/aquarial/discord-haskell/pull/27) Fixed typo: depreciated --> deprecated
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.2.0+version:             1.3.0 description:         Functions and data types to write discord bots.                      Official discord docs <https://discordapp.com/developers/docs/reference>.                      .
src/Discord.hs view
@@ -90,7 +90,7 @@     Left (RestCallInternalNoParse _ _) -> libError "Couldn't parse GetCurrentUser"     _ -> do me <- try (discordOnStart opts handle)             case me of-              Left (e :: SomeException) -> libError ("Your code threw an exception:\n\n" <> T.pack (show e))+              Left (e :: SomeException) -> libError ("discordOnStart handler stopped on an exception:\n\n" <> T.pack (show e))               Right _ -> loop  where    libError :: T.Text -> IO T.Text@@ -107,7 +107,7 @@                  action $ do me <- try (discordOnEvent opts handle event)                              case me of                                Left (e :: SomeException) -> writeChan (discordHandleLog handle)-                                         ("Your code threw an exception:\n\n" <> T.pack (show e))+                                         ("discord-haskell stopped on an exception:\n\n" <> T.pack (show e))                                Right _ -> pure ()                  loop                Right (Left err) -> libError (T.pack (show err))
src/Discord/Internal/Rest/Channel.hs view
@@ -58,8 +58,10 @@   DeleteOwnReaction       :: (ChannelId, MessageId) -> T.Text -> ChannelRequest ()   -- | Remove a Reaction someone else added   DeleteUserReaction      :: (ChannelId, MessageId) -> UserId -> T.Text -> ChannelRequest ()+  -- | Deletes all reactions of a single emoji on a message+  DeleteSingleReaction    :: (ChannelId, MessageId) -> T.Text -> ChannelRequest ()   -- | List of users that reacted with this emoji-  GetReactions            :: (ChannelId, MessageId) -> T.Text -> (Int, ReactionTiming) -> ChannelRequest ()+  GetReactions            :: (ChannelId, MessageId) -> T.Text -> (Int, ReactionTiming) -> ChannelRequest [User]   -- | Delete all reactions on a message   DeleteAllReactions      :: (ChannelId, MessageId) -> ChannelRequest ()   -- | Edits a message content.@@ -94,11 +96,13 @@ -- | Data constructor for GetReaction requests data ReactionTiming = BeforeReaction MessageId                     | AfterReaction MessageId+                    | LatestReaction  reactionTimingToQuery :: ReactionTiming -> R.Option 'R.Https reactionTimingToQuery t = case t of   (BeforeReaction snow) -> "before" R.=: show snow   (AfterReaction snow) -> "after"  R.=: show snow+  (LatestReaction) -> mempty  -- | Data constructor for GetChannelMessages requests. See <https://discordapp.com/developers/docs/resources/channel#get-channel-messages> data MessageTiming = AroundMessage MessageId@@ -186,6 +190,7 @@   (CreateReaction (chan, _) _) ->     "add_react " <> show chan   (DeleteOwnReaction (chan, _) _) ->      "react " <> show chan   (DeleteUserReaction (chan, _) _ _) ->   "react " <> show chan+  (DeleteSingleReaction (chan, _) _) ->   "react " <> show chan   (GetReactions (chan, _) _ _) ->         "react " <> show chan   (DeleteAllReactions (chan, _)) ->       "react " <> show chan   (EditMessage (chan, _) _ _) ->        "get_msg " <> show chan@@ -268,6 +273,10 @@   (DeleteUserReaction (chan, msgid) uID emoji) ->       let e = cleanupEmoji emoji       in Delete (channels // chan /: "messages" // msgid /: "reactions" /: e // uID ) mempty++  (DeleteSingleReaction (chan, msgid) emoji) ->+    let e = cleanupEmoji emoji+    in Delete (channels // chan /: "messages" // msgid /: "reactions" /: e) mempty    (GetReactions (chan, msgid) emoji (n, timing)) ->       let e = cleanupEmoji emoji
src/Discord/Internal/Rest/Guild.hs view
@@ -76,10 +76,10 @@   RemoveGuildMember        :: GuildId -> UserId -> GuildRequest ()   -- | Returns a list of 'Ban' objects for users that are banned from this guild. Requires the   --   'BAN_MEMBERS' permission-  GetGuildBans             :: GuildId -> GuildRequest [Ban]+  GetGuildBans             :: GuildId -> GuildRequest [GuildBan]   -- | Returns a 'Ban' object for the user banned from this guild. Requires the   --   'BAN_MEMBERS' permission-  GetGuildBan              :: GuildId -> UserId -> GuildRequest Ban+  GetGuildBan              :: GuildId -> UserId -> GuildRequest GuildBan   -- | Create a guild ban, and optionally Delete previous messages sent by the banned   --   user. Requires the 'BAN_MEMBERS' permission. Fires a Guild Ban Add 'Event'.   CreateGuildBan           :: GuildId -> UserId -> CreateGuildBanOpts -> GuildRequest ()
src/Discord/Internal/Rest/Prelude.hs view
@@ -25,7 +25,7 @@   where   -- | https://discordapp.com/developers/docs/reference#user-agent   -- Second place where the library version is noted-  agent = "DiscordBot (https://github.com/aquarial/discord-haskell, 1.2.0)"+  agent = "DiscordBot (https://github.com/aquarial/discord-haskell, 1.3.0)"  -- Append to an URL infixl 5 //
src/Discord/Internal/Types.hs view
@@ -7,6 +7,7 @@   , module Discord.Internal.Types.Gateway   , module Discord.Internal.Types.Guild   , module Data.Aeson+  , module Data.Time.Clock   ) where  import Discord.Internal.Types.Channel@@ -16,3 +17,4 @@ import Discord.Internal.Types.Prelude  import Data.Aeson (Object)+import Data.Time.Clock (UTCTime(..))
src/Discord/Internal/Types/Events.hs view
@@ -47,6 +47,7 @@   | MessageReactionAdd      ReactionInfo   | MessageReactionRemove   ReactionInfo   | MessageReactionRemoveAll ChannelId MessageId+  | MessageReactionRemoveEmoji ReactionRemoveInfo   | PresenceUpdate          PresenceInfo   | TypingStart             TypingInfo   | UserUpdate              User@@ -57,6 +58,7 @@  data ReactionInfo = ReactionInfo   { reactionUserId    :: UserId+  , reactionGuildId   :: Maybe GuildId   , reactionChannelId :: ChannelId   , reactionMessageId :: MessageId   , reactionEmoji     :: Emoji@@ -64,11 +66,26 @@  instance FromJSON ReactionInfo where   parseJSON = withObject "ReactionInfo" $ \o ->-    ReactionInfo <$> o .: "user_id"-                 <*> o .: "channel_id"-                 <*> o .: "message_id"-                 <*> o .: "emoji"+    ReactionInfo <$> o .:  "user_id"+                 <*> o .:? "guild_id"+                 <*> o .:  "channel_id"+                 <*> o .:  "message_id"+                 <*> o .:  "emoji" +data ReactionRemoveInfo  = ReactionRemoveInfo+  { reactionRemoveChannelId :: ChannelId+  , reactionRemoveGuildId   :: GuildId+  , reactionRemoveMessageId :: MessageId+  , reactionRemoveEmoji     :: Emoji+  } deriving (Show, Eq, Ord)++instance FromJSON ReactionRemoveInfo where+  parseJSON = withObject "ReactionRemoveInfo" $ \o ->+    ReactionRemoveInfo <$> o .:  "guild_id"+                       <*> o .:  "channel_id"+                       <*> o .:  "message_id"+                       <*> o .:  "emoji"+ data PresenceInfo = PresenceInfo   { presenceUserId  :: UserId   , presenceRoles   :: [RoleId]@@ -147,6 +164,7 @@     "MESSAGE_REACTION_REMOVE"   -> MessageReactionRemove <$> reparse o     "MESSAGE_REACTION_REMOVE_ALL" -> MessageReactionRemoveAll <$> o .: "channel_id"                                                               <*> o .: "message_id"+    "MESSAGE_REACTION_REMOVE_EMOJI" -> MessageReactionRemoveEmoji <$> reparse o     "PRESENCE_UPDATE"           -> PresenceUpdate            <$> reparse o     "TYPING_START"              -> TypingStart               <$> reparse o     "USER_UPDATE"               -> UserUpdate                <$> reparse o
src/Discord/Internal/Types/Guild.hs view
@@ -184,13 +184,13 @@                 <*> o .: "custom"  -- | Info about a Ban-data Ban = Ban-      { banReason  :: T.Text-      , banUser    :: User+data GuildBan = GuildBan+      { guildBanReason  :: T.Text+      , guildBanUser    :: User       } deriving (Show, Eq, Ord) -instance FromJSON Ban where-  parseJSON = withObject "Ban" $ \o -> Ban <$> o .: "reason" <*> o .: "user"+instance FromJSON GuildBan where+  parseJSON = withObject "GuildBan" $ \o -> GuildBan <$> o .: "reason" <*> o .: "user"  -- | Represents a code to add a user to a guild data Invite = Invite