The Discord API can be divided into three main components: the RESTful API to which calls can be made to take actions, a websocket-based permanent connection over which state updates are received, and the voice calling system.
Log in to Discord with
appropriate. The resulting value can be used to make REST API calls to post
messages and manipulate Discord state. Calling
connect() will open a
websocket connection, through which events can be received. These two channels
are enough to write a simple chatbot which can read and respond to messages.
For more in-depth tracking of Discord state, a
State can be seeded with
ReadyEvent obtained when opening a
Connection and kept updated with
the events received over it.
To join voice servers, call
Connection::voice to get a
connect to join a channel, then
stop to control
playback. Manipulating deaf/mute state and receiving audio are also possible.
On Windows, discord-rs currently requires a GNU-like environment. For details, read the installation guide.
On all platforms, discord-rs has several system dependencies, which should be installed as appropriate:
libsodium(if using voice)
opus(if using voice)
ffmpeg(if using ffmpeg features)
youtube-dl(if using youtube-dl features)