Crates.io | dns-wrapper |
lib.rs | dns-wrapper |
version | 0.1.6 |
source | src |
created_at | 2024-11-03 20:44:07.90669 |
updated_at | 2024-11-04 23:06:56.739928 |
description | An API wrapper for Diplomacy and Strife |
homepage | |
repository | https://gitlab.com/benniestudios1/dns-wrapper/ |
max_upload_size | |
id | 1434226 |
size | 8,411 |
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.
Set your Diplomacy and Strife API key, this can be found here.
use dns_wrapper::api::ApiKey;
ApiKey::set_apikey("APIKEY");
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.