From d58c54425a18bbbdc8e66e8eebfb8191bad06901 Mon Sep 17 00:00:00 2001 From: Austin Hellyer Date: Sat, 17 Dec 2016 11:07:34 -0800 Subject: Add guild splash URL methods --- src/model/guild.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/model/guild.rs b/src/model/guild.rs index 5ae0804..e136ccc 100644 --- a/src/model/guild.rs +++ b/src/model/guild.rs @@ -137,6 +137,15 @@ impl GuildInfo { } } +impl InviteGuild { + /// Returns the formatted URL of the guild's splash image, if one exists. + #[cfg(feature="methods")] + pub fn splash_url(&self) -> Option { + self.icon.as_ref().map(|icon| + format!(cdn!("/splashes/{}/{}.jpg"), self.id, icon)) + } +} + impl PartialGuild { /// Finds a role by Id within the guild. #[cfg(feature="methods")] @@ -163,6 +172,13 @@ impl PartialGuild { format!(cdn!("/icons/{}/{}.jpg"), self.id, icon)) } + /// Returns the formatted URL of the guild's splash image, if one exists. + #[cfg(feature="methods")] + pub fn splash_url(&self) -> Option { + self.icon.as_ref().map(|icon| + format!(cdn!("/splashes/{}/{}.jpg"), self.id, icon)) + } + /// Retrieves the guild's webhooks. /// /// **Note**: Requires the [Manage Webhooks] permission. @@ -717,6 +733,13 @@ impl Guild { rest::get_guild_prune_count(self.id.0, map) } + /// Returns the formatted URL of the guild's splash image, if one exists. + #[cfg(feature="methods")] + pub fn splash_url(&self) -> Option { + self.icon.as_ref().map(|icon| + format!(cdn!("/splashes/{}/{}.jpg"), self.id, icon)) + } + /// Starts a prune of [`Member`]s. /// /// See the documentation on [`GuildPrune`] for more information. -- cgit v1.2.3