Crates.io | adiscord |
lib.rs | adiscord |
version | 0.0.10 |
source | src |
created_at | 2023-03-26 15:19:08.605789 |
updated_at | 2023-09-10 21:01:42.834443 |
description | An API and Gateway Discord wrapper in Rust |
homepage | |
repository | https://github.com/MoskalykA/adiscord |
max_upload_size | |
id | 821294 |
size | 37,116 |
An API and Gateway Discord wrapper in Rust
Use the package manager cargo to install adiscord.
cargo add adiscord
cargo add tokio --features rt-multi-thread
cargo add adiscord --features gateway
cargo add adiscord_intents
cargo add tokio --features rt-multi-thread
(These examples require dotenv to be installed in order to have .env files. Here is the command cargo add dotenv
)
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),
};
}
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);
});
}
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.