Struct analyticord::client::Client
[−]
pub struct Client { /* fields omitted */ }
The client struct used to interact with Analyticord.
Methods
impl Client
fn default(token: String) -> Result<Client>
Creates a new Client using the default URL. If the bot is invalid it will return an AnalyticordError.
Arguments
token
- Your Analyticord bot token
Example
use analyticord::client::Client; let _client = Client::default("YOUR_TOKEN_HERE".into());
fn with_url(url: String, token: String) -> Result<Client>
Creates a new Client, giving you the option to also define the URL. Everything else is the
same compared to default
.
fn send_event<T: Event>(self, event: T) -> Result<SubmitData>
Submits an Event to the Analyticord API and returns a Result
Arguments
event
- The Event you want to submit
Example
use analyticord::client::Client; use analyticord::events::Messages; let client = Client::default("YOUR_TOKEN".into()); if client.is_err() { print!("{}", "borked token, try again."); std::process::exit(0); } let res = client.unwrap().send_event(Messages { amount: 10 }); match res { Ok(data) => print!("Successfully submitted. ID: {}", data.id), Err(error) => print!("Error: {:?}", error), }