aboutsummaryrefslogtreecommitdiff
path: root/src/model/guild/mod.rs
diff options
context:
space:
mode:
authorMei Boudreau <[email protected]>2017-10-07 17:54:08 -0400
committeralex <[email protected]>2017-10-07 23:54:08 +0200
commit14b92221184fcaca0f4a60a3b31d5a9470b14b1f (patch)
tree17c28573651c7a638092017c8ce5d39b8d61ba5d /src/model/guild/mod.rs
parentDo not to " " if none of the provided delimiters are found (#183) (diff)
downloadserenity-14b92221184fcaca0f4a60a3b31d5a9470b14b1f.tar.xz
serenity-14b92221184fcaca0f4a60a3b31d5a9470b14b1f.zip
Change behaviour of default_channel (#185)
Diffstat (limited to 'src/model/guild/mod.rs')
-rw-r--r--src/model/guild/mod.rs11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs
index df8bd2c..cec9e63 100644
--- a/src/model/guild/mod.rs
+++ b/src/model/guild/mod.rs
@@ -123,13 +123,10 @@ pub struct Guild {
#[cfg(feature = "model")]
impl Guild {
- #[cfg(feature = "cache")]
- /// Returns the "default" channel of the guild.
- /// (This returns the first channel that can be read by the bot, if there isn't one,
+ /// Returns the "default" channel of the guild for the passed user id.
+ /// (This returns the first channel that can be read by the user, if there isn't one,
/// returns `None`)
- pub fn default_channel(&self) -> Option<Arc<RwLock<GuildChannel>>> {
- let uid = CACHE.read().unwrap().user.id;
-
+ pub fn default_channel(&self, uid: UserId) -> Option<Arc<RwLock<GuildChannel>>> {
for (cid, channel) in &self.channels {
if self.permissions_for(*cid, uid).read_messages() {
return Some(channel.clone());
@@ -163,7 +160,7 @@ impl Guild {
None => return Err(Error::Model(ModelError::ItemMissing)),
};
- let default_channel = match self.default_channel() {
+ let default_channel = match self.default_channel(member.user.read().unwrap().id) {
Some(dc) => dc,
None => return Err(Error::Model(ModelError::ItemMissing)),
};