packages feed

discord-haskell 1.8.6 → 1.8.7

raw patch · 6 files changed

+46/−3 lines, 6 files

Files

changelog.md view
@@ -6,6 +6,10 @@  ## master +## 1.8.7++Add [Stage channel](https://github.com/aquarial/discord-haskell/issues/68) and a catch-all Unknown channel so we stop crashing on new releases (?)+ ## 1.8.6  Add [missing fields](https://github.com/aquarial/discord-haskell/issues/67) to ChannelGuildCategory
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.6+version:             1.8.7 description:         Functions and data types to write discord bots.                      Official discord docs <https://discord.com/developers/docs/reference>.                      .
examples/ping-pong.hs view
@@ -67,6 +67,7 @@          -- A more complex message. Text-to-speech, does not mention everyone nor         -- the user, and uses Discord native replies.+<<<<<<< HEAD         -- Use ":info" in ghci to explore the type         let opts :: R.MessageDetailedOpts             opts = def { R.messageDetailedContent = "Here's a more complex message, but doesn't ping @everyone!"@@ -76,6 +77,15 @@                               , R.mentionRepliedUser = False                               }                        , R.messageDetailedReference = Just $+=======+        let opts = def { messageDetailedContent = "Here's a more complex message, but doesn't ping @everyone!"+                       , messageDetailedTTS = True+                       , messageDetailedAllowedMentions = Just $+                          def { mentionEveryone = False+                              , mentionRepliedUser = False+                              }+                       , messageDetailedReference = Just $+>>>>>>> 219a850... minor formatting to ping example                           def { referenceMessageId = Just $ messageId m }                        }         _ <- restCall (R.CreateMessageDetailed (messageChannel m) opts)
src/Discord/Internal/Rest/Prelude.hs view
@@ -29,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.6)"+  agent = "DiscordBot (https://github.com/aquarial/discord-haskell, 1.8.7)"  -- Append to an URL infixl 5 //
src/Discord/Internal/Types/Channel.hs view
@@ -50,6 +50,7 @@       , channelPosition    :: Integer       , channelNSFW        :: Bool       , channelPermissions :: [Overwrite]+      , parentId           :: Maybe ParentId       }   -- | A voice channel in a guild.   | ChannelVoice@@ -81,6 +82,16 @@       , channelName        :: T.Text       , channelPosition    :: Integer       , channelPermissions :: [Overwrite]+      }+  | ChannelStage+      { channelId          :: ChannelId+      , channelGuild       :: GuildId+      , channelStageId     :: StageId+      , channelStageTopic  :: Text+      }+  | ChannelUnknownType+      { channelId          :: ChannelId+      , channelJSON        :: Text       } deriving (Show, Eq, Ord)  instance FromJSON Channel where@@ -138,7 +149,14 @@                          <*> o .:  "position"                          <*> o .:? "nsfw" .!= False                          <*> o .:  "permission_overwrites"-      _ -> fail ("Unknown channel type:" <> show type')+                         <*> o .:? "parent_id"+      13 ->+        ChannelStage <$> o .:  "id"+                     <*> o .:? "guild_id" .!= 0+                     <*> o .:  "id"+                     <*> o .:? "topic" .!= ""+      _ -> ChannelUnknownType <$> o .:  "id"+                              <*> pure (T.pack (show o))  instance ToJSON Channel where   toJSON ChannelText{..} = object [(name,value) | (name, Just value) <-@@ -195,6 +213,16 @@               [ ("id",     toJSON <$> pure channelId)               , ("name", toJSON <$> pure channelName)               , ("guild_id", toJSON <$> pure channelGuild)+              ] ]+  toJSON ChannelStage{..} = object [(name,value) | (name, Just value) <-+              [ ("id",     toJSON <$> pure channelId)+              , ("guild_id", toJSON <$> pure channelGuild)+              , ("channel_id", toJSON <$> pure channelStageId)+              , ("topic", toJSON <$> pure channelStageTopic)+              ] ]+  toJSON ChannelUnknownType{..} = object [(name,value) | (name, Just value) <-+              [ ("id",     toJSON <$> pure channelId)+              , ("json", toJSON <$> pure channelJSON)               ] ]  -- | If the channel is part of a guild (has a guild id field)
src/Discord/Internal/Types/Prelude.hs view
@@ -45,6 +45,7 @@   parseJSON _ = mzero  type ChannelId = Snowflake+type StageId = Snowflake type GuildId = Snowflake type MessageId = Snowflake type EmojiId = Snowflake