diff options
| author | Austin Hellyer <[email protected]> | 2016-12-12 20:42:17 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-12-12 20:42:17 -0800 |
| commit | ef6eba37636a487c0d6f3b93b8e76c94f28abbab (patch) | |
| tree | 97e9674db3d81882b02fe5a990915b73f84017eb /src/model | |
| parent | Add related projects to readme (diff) | |
| download | serenity-ef6eba37636a487c0d6f3b93b8e76c94f28abbab.tar.xz serenity-ef6eba37636a487c0d6f3b93b8e76c94f28abbab.zip | |
Add emoji URL generation methods
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/guild.rs | 7 | ||||
| -rw-r--r-- | src/model/misc.rs | 9 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/model/guild.rs b/src/model/guild.rs index 0d379b9..5ae0804 100644 --- a/src/model/guild.rs +++ b/src/model/guild.rs @@ -106,6 +106,13 @@ impl Emoji { None => Err(Error::Client(ClientError::ItemMissing)), } } + + /// Generates a URL to the emoji's image. + #[cfg(feature="methods")] + #[inline] + pub fn url(&self) -> String { + format!(cdn!("/emojis/{}.png"), self.id) + } } impl fmt::Display for Emoji { diff --git a/src/model/misc.rs b/src/model/misc.rs index 0a07738..5d9017d 100644 --- a/src/model/misc.rs +++ b/src/model/misc.rs @@ -124,6 +124,15 @@ impl FromStr for RoleId { } } +impl EmojiIdentifier { + /// Generates a URL to the emoji's image. + #[cfg(feature="methods")] + #[inline] + pub fn url(&self) -> String { + format!(cdn!("/emojis/{}.png"), self.id) + } +} + impl FromStr for EmojiIdentifier { type Err = (); fn from_str(s: &str) -> StdResult<Self, ()> { |