Skip to content

Commit

Permalink
add official clan profile link in clan
Browse files Browse the repository at this point in the history
  • Loading branch information
B-2U committed Jun 17, 2024
1 parent 841cc0f commit 304c498
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cmds/clan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/structs/clan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,19 @@ impl Display for PartialClan {
}

impl PartialClan {
/// https://asia.wows-numbers.com/clan/2000007634,Dont-Cap-Kill-All/
pub fn wows_number_url(&self) -> Result<Url, IsacError> {
self.region.number_url(format!(
"/clan/{},{}/",
self.id,
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<Url, IsacError> {
self.region.clan_url(format!("/clan-profile/{}/", self.id))
}

pub fn decimal_to_hex(input: u32) -> String {
format!("{:x}", input)
Expand Down

0 comments on commit 304c498

Please sign in to comment.