| Crates.io | discord_client_rest |
| lib.rs | discord_client_rest |
| version | 0.1.1 |
| created_at | 2025-03-24 14:24:33.747872+00 |
| updated_at | 2025-06-16 17:14:08.936506+00 |
| description | Undetected discord client rest API reimplementation |
| homepage | |
| repository | https://github.com/UwUDev/discord-client-rs |
| max_upload_size | |
| id | 1603833 |
| size | 173,393 |
A high-level Rust implementation of the Discord REST API, designed to provide a robust and efficient client-side interface to Discord's HTTP API.
This crate offers a seamless integration for Discord bot developers, featuring:
Add this crate to your Cargo.toml:
[dependencies]
discord_client_rest = "0.1.0"
let token = ...
let custom_api_version = None;
let custom_build_number = None;
let mut client = RestClient::connect(token, custom_api_version, custom_build_number)
.await
.unwrap();
println!("API Version: {}", client.api_version);
// Useful for the gateway client
println!("Build Number: {}", client.build_number);
let path = "/channels/1234567890/messages";
// alwasy make sur to add a referer
let referer: Referer = match guild_id {
Some(guild_id) => GuildChannelReferer {
guild_id,
channel_id: self.channel_id,
}
.into(),
None => DmChannelReferer {
channel_id: self.channel_id,
}
.into(),
};
let props = RequestPropertiesBuilder::default()
.referer::<Referer>(referer.into())
// .context(....)
// .solved_captcha(...)
.build()?;
// Any struct that implements Serialize can be used as the body
let body = MessageBuilder::default()
.content("Hello, world!")
.build()?;
// This will automatically handle ratelimits and return the response
// The return type is an Option<T> where T is Deserialize
let resp: ? = self.client
.post::<Message, Message>(&path, Some(message), Some(props))
.await?;
You call also use put, patch, delete, get methods to make requests.
The get method is used to make requests that cannot send a body but instead can receive query parameters.
let path = format!("channels/{}/messages/search", self.channel_id);
let referer = DmChannelReferer {
channel_id: self.channel_id,
};
let props = RequestPropertiesBuilder::default()
.referer::<Referer>(referer.into())
.build()?;
// Format is HashMap<String, String> for the query
self.client
.get::<MessageSearchResult>(&path, Some(query.to_map()), Some(props))
.await