aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorAustin Hellyer <[email protected]>2017-01-16 10:45:29 -0800
committerAustin Hellyer <[email protected]>2017-01-16 10:45:29 -0800
commitce0ac36e308ebc436204679e90aabc5489a1b792 (patch)
tree4ddd5c29ee973acb5c3b7d26064503be37f6208f /src/model
parentCredit Shard::latency (diff)
downloadserenity-ce0ac36e308ebc436204679e90aabc5489a1b792.tar.xz
serenity-ce0ac36e308ebc436204679e90aabc5489a1b792.zip
Add back Message::guild_id()
Diffstat (limited to 'src/model')
-rw-r--r--src/model/channel.rs13
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 {