Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/TiltMeSenpai/Discord.hs
Have you heard of our lord and savior Haskell?
https://github.com/TiltMeSenpai/Discord.hs
bot discord discord-api
Last synced: 16 days ago
JSON representation
Have you heard of our lord and savior Haskell?
- Host: GitHub
- URL: https://github.com/TiltMeSenpai/Discord.hs
- Owner: TiltMeSenpai
- License: mit
- Archived: true
- Created: 2016-10-14T01:25:33.000Z (about 8 years ago)
- Default Branch: dev
- Last Pushed: 2017-07-11T04:18:21.000Z (over 7 years ago)
- Last Synced: 2024-10-22T21:47:39.969Z (19 days ago)
- Topics: bot, discord, discord-api
- Language: Haskell
- Homepage:
- Size: 272 KB
- Stars: 57
- Watchers: 8
- Forks: 18
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- discord-api-libs - Discord.hs - Have you heard of our lord and savior Haskell? (Libraries / Haskell)
README
# Discord.hs
A Haskell wrapper for the Discord API[![Hackage](https://img.shields.io/hackage/v/discord-hs.svg?style=flat-square)](http://hackage.haskell.org/package/discord-hs)
[![Hackage-Deps](https://img.shields.io/hackage-deps/v/discord-hs.svg?style=flat-square)](http://packdeps.haskellers.com/feed?needle=discord-hs)
[![Travis](https://img.shields.io/travis/jano017/Discord.hs.svg?style=flat-square)](https://travis-ci.org/jano017/Discord.hs)## Using in a project
The preferred (and only supported) method of using discord.hs is through [stack](https://docs.haskellstack.org/en/stable/README/). Open your `stack.yaml`
and find the `extra-deps` section. Add the following:```yaml
extra-deps:
- discord-hs-0.2.1
```Then open your project.cabal file and add `discord-hs` to your build-depends.
Alternatively, you can add `discord-hs` to your project.cabal file, and run
`stack solver --update-config`. This will let stack catch other missing dependencies
in your project and is most likely the better option.## PingPong
```haskell
{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
import Data.Text
import Pipesimport Network.Discord
reply :: Message -> Text -> Effect DiscordM ()
reply Message{messageChannel=chan} cont = fetch' $ CreateMessage chan cont Nothingmain :: IO ()
main = runBot (Bot "TOKEN") $ do
with ReadyEvent $ \(Init v u _ _ _) ->
liftIO . putStrLn $ "Connected to gateway v" ++ show v ++ " as user " ++ show uwith MessageCreateEvent $ \msg@Message{..} -> do
when ("Ping" `isPrefixOf` messageContent && (not . userIsBot $ messageAuthor)) $
reply msg "Pong!"
```## Known issues:
- Init isn't parsing correctly
- Client doesn't close correctly
- Missing voice support## Future goals:
- [Eta](https://github.com/typelead/eta) compatibility
- [HaLVM](https://github.com/GaloisInc/HaLVM) compatibility (maybe)
- Command framework (Posibly through compat layer with marvin?)
- Ditch wreq (not included in stack lts-8.2)
- Upload to stackage