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() {
let mut client = Client::new("10", dotenv!("TOKEN"));
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() {
let mut client = Client::new("10", dotenv!("TOKEN"));
client.set_heartbeat_ack(true);
client.add_intents(vec![
Intent::Guilds,
Intent::GuildMembers,
Intent::GuildModeration,
Intent::GuildEmojisAndStickers,
Intent::GuildIntegrations,
Intent::GuildWebhooks,
Intent::GuildInvites,
Intent::GuildVoiceStates,
Intent::GuildPresences,
Intent::GuildMessages,
Intent::GuildMessageReactions,
Intent::GuildMessageTyping,
Intent::DirectMessages,
Intent::DirectMessageReactions,
Intent::DirectMessageTyping,
Intent::MessageContent,
Intent::GuildScheduledEvents,
Intent::AutoModerationConfiguration,
Intent::AutoModerationExecution,
]);
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
MIT