Skip to content

Commit

Permalink
fix: checking if the map has been captured by the clan in the Capture…
Browse files Browse the repository at this point in the history
… the map command
  • Loading branch information
motzel committed May 22, 2024
1 parent 7628c85 commit dc3b801
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bl-bot"
version = "0.18.5"
version = "0.18.6"
description = "Beat Leader Discord Bot"
readme = "README.md"
repository = "https://github.com/motzel/bl-bot"
Expand Down
12 changes: 11 additions & 1 deletion src/beatleader/clan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ pub struct ClanMapScore {
pub timepost: DateTime<Utc>,
}

#[serde_as]
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
#[serde(rename_all = "camelCase")]
pub struct ClanLeaderboard {
pub id: LeaderboardId,
pub clan_id: ClanId,
pub play_count: u32,
pub plays: u32,
}

#[serde_as]
#[derive(Deserialize, Debug)]
#[serde(rename_all = "camelCase")]
Expand All @@ -191,7 +201,7 @@ pub struct BlApiClanRankingScoresResponse {
#[serde(with = "ts_seconds")]
pub last_update_time: DateTime<Utc>,
#[serde_as(deserialize_as = "DefaultOnNull")]
pub leaderboard: Leaderboard,
pub leaderboard: ClanLeaderboard,
#[serde_as(deserialize_as = "DefaultOnNull")]
pub associated_scores_count: u32,
#[serde_as(deserialize_as = "DefaultOnNull")]
Expand Down
8 changes: 3 additions & 5 deletions src/discord/bot/commands/clan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ pub(crate) async fn cmd_capture(
data: scores.associated_scores,
items_per_page: None,
total: Some(scores.associated_scores_count),
other_data: Some((scores.clan, scores.pp)),
other_data: Some((scores.clan, scores.pp, scores.leaderboard)),
})
})
.await
Expand All @@ -671,10 +671,8 @@ pub(crate) async fn cmd_capture(
};

let mut is_captured = false;
if let Some((clan, ..)) = data.other_data {
if clan.captured_leaderboards.is_some()
&& !clan.captured_leaderboards.unwrap().is_empty()
{
if let Some((clan, .., leaderboard)) = data.other_data {
if clan.id == leaderboard.clan_id {
is_captured = true;
}
}
Expand Down

0 comments on commit dc3b801

Please sign in to comment.