Skip to content

Commit

Permalink
Add method to retrieve the Role icon url (serenity-rs#2926)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbt365 authored Jul 29, 2024
1 parent 7b8dbad commit cd43fa5
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/model/guild/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,17 @@ impl Role {
self.permissions.contains(permissions)
}
}

#[inline]
#[must_use]
/// Generates a URL to the Role icon's image.
pub fn icon_url(&self) -> Option<String> {
self.icon.map(|icon| {
let ext = if icon.is_animated() { "gif" } else { "webp" };

cdn!("/role-icons/{}/{}.{}", self.id, icon, ext)
})
}
}

impl fmt::Display for Role {
Expand Down

0 comments on commit cd43fa5

Please sign in to comment.