dns-wrapper

Crates.iodns-wrapper
lib.rsdns-wrapper
version0.1.6
sourcesrc
created_at2024-11-03 20:44:07.90669
updated_at2024-11-04 23:06:56.739928
descriptionAn API wrapper for Diplomacy and Strife
homepage
repositoryhttps://gitlab.com/benniestudios1/dns-wrapper/
max_upload_size
id1434226
size8,411
(benniestudios)

documentation

https://docs.rs/dns-wrapper/

README

DNS Wrapper

What does it do?

DNS Wrapper is an API wrapper for the brower nation simulation game Diplomacy and Strife. It has several easy to use functions you can use in your Discord bot.

How do I use it?

Step 1:

Set your Diplomacy and Strife API key, this can be found here.

use dns_wrapper::api::ApiKey;

ApiKey::set_apikey("APIKEY");

Step 2:

Use one of the fetch functions.

use dns_wrapper::api::output::fetch_output;

//...
// Fetch nation data
let nation_data = match fetch_output(nation_id).await {
    Ok(data) => data,
    Err(e) => {
        println!("{:?}", e);
        return Ok(());
    }
};

// Create an embed
let embed = serenity::CreateEmbed::default()
    .title(format!("{}'s Output", nation_data.nation))
    .description(format!(
        "**Money**: ${}\n**Production**: {}\n**Minerals**: {}\n**Uranium**: {}\n**Rare Metals**: {}\n**Fuel**: {}\n**Political Power**: {}",
        nation_data.money.round().separate_with_commas(),
        nation_data.production.round().separate_with_commas(),
        nation_data.minerals.round().separate_with_commas(),
        nation_data.uranium.round().separate_with_commas(),
        nation_data.rare_metals.round().separate_with_commas(),
        nation_data.fuel.round().separate_with_commas(),
        nation_data.political_power.round().separate_with_commas()
    ))
    .colour(Colour::DARK_GREEN);

let message = poise::CreateReply::default().embed(embed);
ctx.send(message).await?;

Ok(())
//...

The example above shows a code snippet of my Discord bot using the fetch_output() function. This Discord bot is made with the Poise library.

Commit count: 0

cargo fmt