djs-model
Discord API v10 types — users, guilds, messages, gateway payloads and events — for djs-rs.
Status: alpha. Every documented Discord API v10 type: resources, gateway events and commands, interactions, REST bodies and responses, OAuth2 and webhook events. The API may still change between alpha releases; see the changelog.
discord.js counterpart: discord-api-types (v10)
This crate contains only data types and their (de)serialization. It has no networking and no async runtime, so it can be used by anything that speaks the Discord API: bots, dashboards, HTTP interaction servers, webhook receivers or tooling.
Highlights
- Typed IDs.
Id<T>wraps aNonZeroU64with a zero-sized marker, so aUserIdcan never be passed where aChannelIdis expected.Id<T>andOption<Id<T>>are both 8 bytes. - Compact values. Strings are
CompactString(short strings stored inline, without allocation); image hashes are stored as 16 bytes instead of a 34-character string; timestamps are a singlei64. - Forward compatible. Unknown fields are ignored and unknown enum values are preserved
(
MessageType::Unknown(250)), so new Discord features never break deserialization. - Fast gateway decoding.
GatewayEventDeserializerdecodes each payload in a single pass straight into its concrete type, without an intermediate JSON value.
Example
use ;
use DeserializeSeed;
let json = r#"{"t":"MESSAGE_CREATE","s":7,"op":0,"d":{
"id":"1300000000000000000","channel_id":"1200000000000000000",
"author":{"id":"80351110224678912","username":"nelly","discriminator":"0",
"global_name":"Nelly","avatar":null},
"content":"!ping","timestamp":"2026-11-10T19:42:07.123000+00:00",
"edited_timestamp":null,"tts":false,"mention_everyone":false,"pinned":false,"type":0
}}"#;
let seed = from_json.unwrap;
let event = seed.deserialize.unwrap;
if let Dispatch = event
Part of djs-rs
djs-model is one crate of djs-rs, a high-performance
Rust library for building Discord bots modelled on discord.js v14. It can be used on its own
or through the main djs-rs crate.
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.