MCPcopy Index your code
hub / github.com/SpaceManiac/discord-rs

github.com/SpaceManiac/discord-rs @v0.9.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.9.0 ↗ · + Follow
361 symbols 648 edges 15 files 167 documented · 46%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

discord-rs

This project is only maintained occasionally. If you're having problems, open a pull request or check the network graph for up-to-date forks.

discord-rs is a Rust client library for the Discord chat client's API.

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 Discord::new, new_cache, or from_bot_token as 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 the 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 VoiceConnection and use connect to join a channel, then play and stop to control playback. Manipulating deaf/mute state and receiving audio are also possible.

For further details, browse the source or read the documentation. For examples, browse the examples directory.

Installation

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:

  • pkg-config
  • openssl
  • libsodium (if using voice)
  • opus (if using voice)
  • ffmpeg (if using ffmpeg features)
  • youtube-dl (if using youtube-dl features)

Extension points exported contracts — how you extend this code

AudioSource (Interface)
A readable audio source. [1 implementers]
src/voice.rs
ReceiverExt (Interface)
(no doc) [1 implementers]
src/lib.rs
NamedEnum (Interface)
(no doc)
src/serial.rs
AudioReceiver (Interface)
A receiver for incoming audio. [1 implementers]
src/voice.rs
SenderExt (Interface)
(no doc) [1 implementers]
src/lib.rs
NumericEnum (Interface)
(no doc)
src/serial.rs

Core symbols most depended-on inside this repo

from_reader
called by 59
src/lib.rs
remove
called by 35
src/model.rs
check_empty
called by 22
src/lib.rs
into_map
called by 17
src/model.rs
opt_modify
called by 14
src/state.rs
voice
called by 11
src/connection.rs
decode_array
called by 11
src/model.rs
connect
called by 9
src/lib.rs

Shape

Method 220
Class 61
Function 54
Enum 20
Interface 6

Languages

Rust100%

Modules by API surface

src/lib.rs106 symbols
src/model.rs89 symbols
src/voice.rs38 symbols
src/builders.rs38 symbols
src/state.rs24 symbols
src/connection.rs24 symbols
src/serial.rs19 symbols
src/ratelimit.rs6 symbols
src/error.rs6 symbols
examples/voice_receive.rs5 symbols
examples/dj.rs2 symbols
examples/login_cache.rs1 symbols

For agents

$ claude mcp add discord-rs \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page