KSoft.rs

KSoft.SI api wrapper written in pure Rust

FIRSTS STEPS

Add this to your Cargo.toml to add the crate to your project

[dependencies.ksoft]
version = "1.1.4"

Since the crate is fully asynchronous, you might want to also add tokio to your project, but if you have a non-asynchronous context, you can enable the `blocking` feature to support blocking operations.

In order to enable the `blocking` feature, you must disable default features

Added `serenity` feature implementing TypeMapKey for the client

Asynchronous example

use ksoft::Client;

#[tokio::main]
async fn main() {
    let client = Client::new("TOKEN HERE"); //crate the client
    
    if let Ok(meme) = client.images.random_meme().await { //try to get a random meme handling the possible error
        //Do some logical stuff here...
    } else {
        //Handle possible response error
    }
}

Blocking example

use ksoft::blocking::Client

fn main() {
    let client = Client::new("TOKEN HERE"); //create the client
    
    if let Ok(meme) = client.images.random_meme() { //try to get a random meme handling the possible error
        //Do some logical stuff here...
    } else {
        //Error handling stuff
    }
}

Last updated