diff options
| -rw-r--r-- | src/model/user.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/model/user.rs b/src/model/user.rs index 441944d..e1483d2 100644 --- a/src/model/user.rs +++ b/src/model/user.rs @@ -116,6 +116,18 @@ impl CurrentUser { } } + /// Retrieves the URL to the current user's avatar, falling back to the + /// default avatar if needed. + /// + /// This will call [`avatar_url`] first, and if that returns `None`, it + /// then falls back to [`default_avatar_url`]. + /// + /// [`avatar_url`]: #method.avatar_url + /// [`default_avatar_url`]: #method.default_avatar_url + pub fn face(&self) -> String { + self.avatar_url().unwrap_or_else(|| self.default_avatar_url()) + } + /// Gets a list of guilds that the current user is in. /// /// # Examples @@ -474,6 +486,18 @@ impl User { self.direct_message(content) } + /// Retrieves the URL to the user's avatar, falling back to the default + /// avatar if needed. + /// + /// This will call [`avatar_url`] first, and if that returns `None`, it + /// then falls back to [`default_avatar_url`]. + /// + /// [`avatar_url`]: #method.avatar_url + /// [`default_avatar_url`]: #method.default_avatar_url + pub fn face(&self) -> String { + self.avatar_url().unwrap_or_else(|| self.default_avatar_url()) + } + /// Gets a user by its Id over the REST API. /// /// **Note**: The current user must be a bot user. |