diff options
| author | Austin Hellyer <[email protected]> | 2017-01-16 10:45:29 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2017-01-16 10:45:29 -0800 |
| commit | ce0ac36e308ebc436204679e90aabc5489a1b792 (patch) | |
| tree | 4ddd5c29ee973acb5c3b7d26064503be37f6208f /src/model | |
| parent | Credit Shard::latency (diff) | |
| download | serenity-ce0ac36e308ebc436204679e90aabc5489a1b792.tar.xz serenity-ce0ac36e308ebc436204679e90aabc5489a1b792.zip | |
Add back Message::guild_id()
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/channel.rs | 13 |
1 files changed, 13 insertions, 0 deletions
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<GuildId> { + 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 { |