[−][src]Crate rustcord
A safe wrapper around the Discord RichPresence API
Example
use discord_rpc::{DiscordRPC, EventHandlers, RichPresenceBuilder, User}; use std::time::SystemTime; struct Handlers; impl EventHandlers for Handlers { fn ready(_user: User) { println!("Welcome {}#{}", _user.username, _user.discriminator); } } fn main() { let discord = DiscordRPC::init::<Handlers>("544523578855391241", true, None) .expect("Could no initialize RPC"); let presence = RichPresenceBuilder::new() .state("Rusting") .details("Mining few crystals") .large_image_key("rust") .large_image_text("Rust") .small_image_key("amethyst") .small_image_text("Amethyst") .build(); discord.update_presence(presence).expect("Could not update presence"); loop { discord.run_callbacks() } }
Structs
RichPresence | Defines the data displayed on the rich presence screen on a user's profile. Due to the C API limits, this data is limited to a maximum amount of bytes will be listed below |
RichPresenceBuilder | A Builder struct for RichPresence which gives more ergonomic API |
Rustcord | The main struct of the API providing the RPC methods |
User | Represents a Discord user that has a rich presence on |
Enums
JoinRequestReply | A reply to the a user's request |
Traits
EventHandlers | A trait for handling the presence events |