Write bots for Discord in Haskell https://github.com/aquarial/discord-haskell
|Latest on Hackage:||0.8.2|
This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.
Please refer to
Getting Started and
relevant. A few minutes of reading can save you
hours of debugging.
master branch has the potentially broken, most
stable has the most recent working version.
Pull requests are automatically made against
master and it’s
nice to merge pull requests to test them.
1 Create an application at the Developer Portal: https://discordapp.com/developers/applications.
2 Add a ‘Bot User’ using the settings pane on the left. Take
CLIENT ID on this page.
3 Use the BOT PERMISSIONS tab to compute a Permissions Int (this does not immediately affect anything, hold onto this number)
3 Invite the bot to a server filling in the
Client ID and Permissions come from previous steps.
4 Connect to the gateway once in order to send CreateMessage events. This is a Discord requirement.
6 Understand what’s available to the bot. Rest API calls can modify
etc. Most endpoints are covered with very similar names.
List Guild Emojis
ListGuildEmojis. You can use
ghci on type constructors to
explore the ADTs.
provide the other source of info, using
:info to explore
7 Add this library to your dependencies. discord-haskell is on hackage with strict version bounds to stackage lts-12.10. You can also use the github repo.
# in stack.yaml (if using stack) resolver: lts-12.10 extra-deps: - git: email@example.com:aquarial/discord-haskell.git commit: <most recent stable commit> extra-dep: true # in project.cabal build-depends: base , discord-haskell
loginRest if you don’t need the
stopDiscord to safely
kill background threads when running examples in ghci
(otherwise exit ghci and reopen to kill threads).
The examples will work on the
stable branch. The
has the most recent (potentially) breaking changes.
To get the format to use for Emoji, type
a discord chat. You should copy-paste that into the request. This
can be a bit finicky. The equivalent of
"👍\127997" for example, and a custom emoji will look
This library was originally forked from discord.hs. After rewriting the gateway/rest loops and extending the types I think it makes more sense to present this library as separate from the source. The APIs are not compatible.
In roughly the order I’m working on them:
View on github for newest version: https://github.com/aquarial/discord-haskell/blob/master/changelog.md
Hardcode CreateReaction delay so bots can add reactions 4 times faster
MP2E Fixed parse error on GuildBanAdd + GuildBanRevoke: user_object instead the whole object
MP2E Fixed parse error on GuildRoleDelete: role_id instead of role
MessageUpdate does not contain a full Message object, just
Message Author changed from
Either WebhookId User
Add Webhook ADT
Add requests: GetInvite, DeleteInvite
UpdateStatusVoiceOpts takes Bool for Mute
t1m0thyj Typo in RequestGuildMemberOpts fields fixed.
t1m0thyj Added Activity, ActivityType ADT
UpdateStatusTypes became UpdateStatusType (singular ADT)
t1m0thyj Retry connection on 1001 websocket close
Snowflake -> named id
Add requests: ModifyChanPositions, CreateGuildChannel
Changed constructors of Channel to have prefix “Channel”, isGuildChannel –> channelIsInGuild
Change Emoji Id ADTs
Add requests: CreateGuildEmoji, GroupDMRemoveRecipient, ModifyCurrentUser, EditChannelPermissions, CreateChannelInvite, GroupDMAddRecipient, ModifyGuild
restCall, readCache pass errors as an ADT, including underling http exceptions
Only add “Bot “ prefix to secret token if it’s not there
sendCommand with GatewaySendable types
restCall with Request types
nextEvent with Event types