Struct analyticord::client::Client []

pub struct Client { /* fields omitted */ }

The client struct used to interact with Analyticord.

Methods

impl 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());

Creates a new Client, giving you the option to also define the URL. Everything else is the same compared to default.

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),
}

Trait Implementations

impl Debug for Client

Formats the value using the given formatter.