From ce0ac36e308ebc436204679e90aabc5489a1b792 Mon Sep 17 00:00:00 2001 From: Austin Hellyer Date: Mon, 16 Jan 2017 10:45:29 -0800 Subject: Add back Message::guild_id() --- src/model/channel.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/model') diff --git a/src/model/channel.rs b/src/model/channel.rs index 7cd4077..a773cc7 100644 --- a/src/model/channel.rs +++ b/src/model/channel.rs @@ -550,6 +550,19 @@ impl Message { .replace("@here", "@\u{200B}here") } + /// Retrieves the Id of the guild that the message was sent in, if sent in + /// one. + /// + /// Returns `None` if the channel data or guild data does not exist in the + /// cache. + #[cfg(all(feature="cache", feature="methods"))] + pub fn guild_id(&self) -> Option { + match CACHE.read().unwrap().get_channel(self.channel_id) { + Some(ChannelRef::Guild(channel)) => Some(channel.guild_id), + _ => None, + } + } + /// True if message was sent using direct messages. #[cfg(all(feature="cache", feature="methods"))] pub fn is_private(&self) -> bool { -- cgit v1.2.3