diff options
Diffstat (limited to 'src/model/channel.rs')
| -rw-r--r-- | src/model/channel.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/model/channel.rs b/src/model/channel.rs index 0513966..d00bec5 100644 --- a/src/model/channel.rs +++ b/src/model/channel.rs @@ -436,7 +436,7 @@ impl Message { #[cfg(feature = "methods")] pub fn delete(&self) -> Result<()> { let req = permissions::MANAGE_MESSAGES; - let is_author = self.author.id != CACHE.lock().unwrap().user.id; + let is_author = self.author.id != CACHE.read().unwrap().user.id; if is_author { return Err(Error::Client(ClientError::InvalidUser)); @@ -503,7 +503,7 @@ impl Message { return Err(Error::Client(ClientError::MessageTooLong(length_over))); } - if self.author.id != CACHE.lock().unwrap().user.id { + if self.author.id != CACHE.read().unwrap().user.id { return Err(Error::Client(ClientError::InvalidUser)); } @@ -720,7 +720,7 @@ impl PrivateChannel { /// [`ClientError::InvalidUser`]: ../client/enum.ClientError.html#variant.InvalidOperationAsUser #[cfg(feature = "methods")] pub fn delete_messages(&self, message_ids: &[MessageId]) -> Result<()> { - if !CACHE.lock().unwrap().user.bot { + if !CACHE.read().unwrap().user.bot { return Err(Error::Client(ClientError::InvalidOperationAsUser)); } @@ -889,7 +889,7 @@ impl PublicChannel { /// optimized in the future. #[cfg(all(feature = "cache", feature = "methods"))] pub fn guild(&self) -> Option<LiveGuild> { - CACHE.lock().unwrap().get_guild(self.guild_id).cloned() + CACHE.read().unwrap().get_guild(self.guild_id).cloned() } /// Return a [`Mention`] which will link to this channel. @@ -978,7 +978,7 @@ impl Reaction { /// [permissions]: permissions #[cfg(feature = "methods")] pub fn delete(&self) -> Result<()> { - let user = if self.user_id == CACHE.lock().unwrap().user.id { + let user = if self.user_id == CACHE.read().unwrap().user.id { None } else { Some(self.user_id.0) |