Merge pull request #14

Add more details to profiles
This commit is contained in:
Em (Ethan) Ruszanowski 2023-07-13 15:17:27 -04:00 committed by GitHub
commit ecb0e2af30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 4 deletions

View file

@ -33,6 +33,14 @@ pub struct Profile {
pub losses: i32,
#[serde(rename = "Wins")]
pub wins: i32,
#[serde(rename = "Team_Name")]
pub clan: Option<String>,
#[serde(rename = "Level")]
pub level: i32,
#[serde(rename = "Platform")]
pub platform: Option<String>,
#[serde(rename = "Leaves")]
pub leaves: i32,
pub ret_msg: Option<String>,
}

View file

@ -22,8 +22,7 @@ pub async fn profile(
return Ok(());
}
let winrate =
(profile.wins as f32 / (profile.wins as f32 + profile.losses as f32)) * 100 as f32;
let winrate = (profile.wins as f32 / (profile.wins as f32 + profile.losses as f32)) * 100f32;
ctx.send(|f| {
f.embed(|f| {
f.title(format!("{}", profile.name.as_ref().unwrap()))
@ -32,11 +31,23 @@ pub async fn profile(
profile.hz_player_name.as_ref().unwrap()
))
.field(
"Status",
"Clan Name",
format!("{}", profile.clan.as_ref().unwrap_or(&String::from(""))),
true,
)
.field(
"Status Message",
format!("{}", profile.personal_status_message.as_ref().unwrap()),
false,
)
.field("Hours played", format!("{}", profile.hours_played), false)
.field("Level", format!("{}", profile.level), true)
.field("Hours Played", format!("{}", profile.hours_played), true)
.field("Leaves", format!("{}", profile.leaves), true)
.field(
"Platform",
format!("{}", profile.platform.as_ref().unwrap()),
false,
)
.field("Wins", format!("{}", profile.wins), true)
.field("Losses", format!("{}", profile.losses), true)
.field("Winrate", format!("{:.2}%", winrate), true)