diff --git a/src/model/guild/member.rs b/src/model/guild/member.rs index f1a5114d2fd..d9ac2304e67 100644 --- a/src/model/guild/member.rs +++ b/src/model/guild/member.rs @@ -274,8 +274,11 @@ impl Member { /// /// Returns a [`ModelError::GuildNotFound`] if the guild the member's in could not be /// found in the cache. + /// + /// And/or returns [`ModelError::ItemMissing`] if the "default channel" of the guild is not found. /// /// [`ModelError::GuildNotFound`]: enum.ModelError.html#variant.GuildNotFound + /// [`ModelError::ItemMissing`]: enum.ModelError.html#variant.ItemMissing #[cfg(feature = "cache")] pub fn permissions(&self) -> Result { let guild = match self.guild_id.find() { @@ -285,8 +288,13 @@ impl Member { let guild = guild.read().unwrap(); + let default_channel = match guild.default_channel() { + Some(dc) => dc, + None => return Err(From::from(ModelError::ItemMissing)), + }; + Ok(guild.permissions_for( - ChannelId(guild.id.0), + default_channel.id, self.user.read().unwrap().id, )) } diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs index dee97afdffc..714cf5ca46d 100644 --- a/src/model/guild/mod.rs +++ b/src/model/guild/mod.rs @@ -207,13 +207,7 @@ impl Guild { /// [`Guild::ban`]: struct.Guild.html#method.ban /// [`User`]: struct.User.html /// [Ban Members]: permissions/constant.BAN_MEMBERS.html - pub fn ban>(&self, user: U, delete_message_days: u8) -> Result<()> { - if delete_message_days > 7 { - return Err(Error::Model( - ModelError::DeleteMessageDaysAmount(delete_message_days), - )); - } - + pub fn ban, BO: BanOptions>(&self, user: U, options: BO) -> Result<()> { #[cfg(feature = "cache")] { let req = permissions::BAN_MEMBERS; @@ -223,7 +217,7 @@ impl Guild { } } - self.id.ban(user, delete_message_days) + self.id.ban(user, options) } /// Retrieves a list of [`Ban`]s for the guild.