aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2018-07-09 16:34:24 -0700
committerZeyla Hellyer <[email protected]>2018-07-09 16:34:24 -0700
commit3121f90a9f98e82fab48d62cf95cd316ae9f0496 (patch)
treee4ad9d2c1d5feff991404eca78891edc2f4286a7 /src/model/channel
parentAdd voice::streamer::ffmpeg_optioned (diff)
downloadserenity-3121f90a9f98e82fab48d62cf95cd316ae9f0496.tar.xz
serenity-3121f90a9f98e82fab48d62cf95cd316ae9f0496.zip
Deprecate Message::guild_id()
Instead, using the structfield is preferred, since that comes from gateway events directly now anyway.
Diffstat (limited to 'src/model/channel')
-rw-r--r--src/model/channel/message.rs25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs
index be17772..3134725 100644
--- a/src/model/channel/message.rs
+++ b/src/model/channel/message.rs
@@ -30,17 +30,17 @@ pub struct Message {
///
/// [`Channel`]: enum.Channel.html
pub channel_id: ChannelId,
- /// The Id of the [`Guild`] that the message was sent in. This value will
- /// only be present if this message was received over the gateway.
- ///
- /// [`Guild`]: ../guild/struct.Guild.html
- pub guild_id: Option<GuildId>,
/// The content of the message.
pub content: String,
/// The timestamp of the last time the message was updated, if it was.
pub edited_timestamp: Option<DateTime<FixedOffset>>,
/// Array of embeds sent with the message.
pub embeds: Vec<Embed>,
+ /// The Id of the [`Guild`] that the message was sent in. This value will
+ /// only be present if this message was received over the gateway.
+ ///
+ /// [`Guild`]: ../guild/struct.Guild.html
+ pub guild_id: Option<GuildId>,
/// Indicator of the type of message this is, i.e. whether it is a regular
/// message or a system message.
#[serde(rename = "type")]
@@ -337,21 +337,18 @@ impl Message {
/// [`guild_id`]: #method.guild_id
#[cfg(feature = "cache")]
pub fn guild(&self) -> Option<Arc<RwLock<Guild>>> {
- self.guild_id()
- .and_then(|guild_id| CACHE.read().guild(guild_id))
+ CACHE.read().guild(self.guild_id?)
}
/// 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(feature = "cache")]
+ /// Refer to [`guild_id`] for more information.
+ ///
+ /// [`guild_id`]: #structfield.guild_id
+ #[deprecated(note = "Use `guild_id` structfield instead", since = "0.5.5")]
pub fn guild_id(&self) -> Option<GuildId> {
- match CACHE.read().channel(self.channel_id) {
- Some(Channel::Guild(ch)) => Some(ch.read().guild_id),
- _ => None,
- }
+ self.guild_id
}
/// True if message was sent using direct messages.