Examples
Asynchronous
use std::env;
use ksoft::{
Client,
EventHandler as KSoftEvents,
model::bans::BanUpdate,
prelude::async_trait
};
#[tokio::main]
async fn main() {
let ksoft = Client::new(env::var("KSOFT_TOKEN").unwrap());
//start doing things with the client here
}
struct EventHandler;
#[async_trait]
impl KSoftEvents for EventHandler {
async fn ban_updated(&self, data: Vec<BanUpdate>) {
println!("Ban updated received! data: {:#?}", data);
}
}
Blocking
use std::env;
use ksoft::blocking::{
Client,
EventHandler as KSoftEvents,
};
use ksoft::model::bans::BanUpdate;
fn main() {
let ksoft = Client::new(env::var("KSOFT_TOKEN").unwrap());
//start doing things with the client here
}
struct EventHandler;
impl KSoftEvents for EventHandler {
fn ban_updated(&self, data: Vec<BanUpdate>) {
println!("Ban updated received! data: {:#?}", data);
}
}
Last updated