From 304c4982669dadf01406af90b050e93f3b4cb354 Mon Sep 17 00:00:00 2001 From: Alex Kao Date: Tue, 18 Jun 2024 00:30:50 +0800 Subject: [PATCH] add official clan profile link in `clan` --- src/cmds/clan.rs | 7 +++++++ src/structs/clan.rs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/cmds/clan.rs b/src/cmds/clan.rs index 85f20c7..787c9fe 100644 --- a/src/cmds/clan.rs +++ b/src/cmds/clan.rs @@ -365,6 +365,12 @@ impl ClanView { .custom_id("clan_members") .style(ButtonStyle::Secondary); + let mut official_link = CreateButton::default(); + official_link + .label("Official") + .url(self.clan.official_url().unwrap()) + .style(ButtonStyle::Link); + let mut num_link = CreateButton::default(); num_link .label("Stats & Numbers") @@ -379,6 +385,7 @@ impl ClanView { row.add_button(descrip) .add_button(member) .add_button(self.last_season_btn.clone()) + .add_button(official_link) .add_button(num_link); view.set_action_row(row); view diff --git a/src/structs/clan.rs b/src/structs/clan.rs index 5abfe31..eee6078 100644 --- a/src/structs/clan.rs +++ b/src/structs/clan.rs @@ -27,6 +27,7 @@ impl Display for PartialClan { } impl PartialClan { + /// https://asia.wows-numbers.com/clan/2000007634,Dont-Cap-Kill-All/ pub fn wows_number_url(&self) -> Result { self.region.number_url(format!( "/clan/{},{}/", @@ -34,6 +35,11 @@ impl PartialClan { self.name.replace(' ', "-") )) } + // TODO: make tests for these urls availability (returned status) + /// https://clans.worldofwarships.asia/clan-profile/2000017937 + pub fn official_url(&self) -> Result { + self.region.clan_url(format!("/clan-profile/{}/", self.id)) + } pub fn decimal_to_hex(input: u32) -> String { format!("{:x}", input)