10 releases
0.0.10 | Sep 10, 2023 |
---|---|
0.0.9 | Jul 14, 2023 |
0.0.8 | Jun 7, 2023 |
0.0.4 | May 31, 2023 |
0.0.3 | Mar 27, 2023 |
#1528 in Web programming
73 downloads per month
150KB
2.5K
SLoC
adiscord
An API and Gateway Discord wrapper in Rust
Installation
Use the package manager cargo to install adiscord.
API installation
cargo add adiscord
cargo add tokio --features rt-multi-thread
Gateway installation
cargo add adiscord --features gateway
cargo add adiscord_intents
cargo add tokio --features rt-multi-thread
Usage
(These examples require dotenv to be installed in order to have .env files. Here is the command cargo add dotenv
)
Example with the API
use adiscord::Client;
use dotenv_codegen::dotenv;
#[tokio::main]
async fn main() {
// Client initialisation
let mut client = Client::new(dotenv!("TOKEN"));
// Recover a server from its ID
match client.guild.get("1089521338286342195").await {
Ok(guild) => println!("{:?}", guild.name),
Err(error) => println!("{:?}", error),
};
}
Example with the Gateway
use adiscord::Client;
use adiscord_intents::Intent;
use dotenv_codegen::dotenv;
#[tokio::main]
async fn main() {
// Client initialisation
let mut client = Client::new(dotenv!("TOKEN"));
// Receive heartbeat messages, delete this line if you do not wish to do so
client.set_heartbeat_ack(true);
// Send all the permissions you need from your bot to discord
client.all_intents();
// The ready event will be launched once your bot is connected
client.on_ready(|ready| {
println!("{:?}", ready);
});
}
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
Dependencies
~4–17MB
~270K SLoC