diff options
| author | acdenisSK <[email protected]> | 2017-08-01 06:53:46 +0200 |
|---|---|---|
| committer | acdenisSK <[email protected]> | 2017-08-01 06:53:46 +0200 |
| commit | 25d49316133e2a8b7c4b26d3b6a44efdf5ad8834 (patch) | |
| tree | 1a313f96374118bed3da5aeea5744106b9509c88 /src/model/guild | |
| parent | Remove the `ext` module and remove a match (diff) | |
| download | serenity-25d49316133e2a8b7c4b26d3b6a44efdf5ad8834.tar.xz serenity-25d49316133e2a8b7c4b26d3b6a44efdf5ad8834.zip | |
Provide the input and limit back to the user, and do some consistencies
Diffstat (limited to 'src/model/guild')
| -rw-r--r-- | src/model/guild/guild_id.rs | 2 | ||||
| -rw-r--r-- | src/model/guild/member.rs | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/src/model/guild/guild_id.rs b/src/model/guild/guild_id.rs index 08fd1a1..a199331 100644 --- a/src/model/guild/guild_id.rs +++ b/src/model/guild/guild_id.rs @@ -54,7 +54,7 @@ impl GuildId { let reason = ban_options.reason(); if reason.len() > 512 { - return Err(Error::ExceededLimit); + return Err(Error::ExceededLimit(reason.to_string(), 512)); } http::ban_user(self.0, user.into().0, dmd, &*reason) diff --git a/src/model/guild/member.rs b/src/model/guild/member.rs index 70590b0..756477b 100644 --- a/src/model/guild/member.rs +++ b/src/model/guild/member.rs @@ -132,16 +132,21 @@ impl Member { /// [Ban Members]: permissions/constant.BAN_MEMBERS.html #[cfg(feature = "cache")] pub fn ban<BO: BanOptions>(&self, ban_options: BO) -> Result<()> { + let dmd = ban_options.dmd(); + if dmd > 7 { + return Err(Error::Model(ModelError::DeleteMessageDaysAmount(dmd))); + } + let reason = ban_options.reason(); if reason.len() > 512 { - return Err(Error::ExceededLimit); + return Err(Error::ExceededLimit(reason.to_string(), 512)); } http::ban_user( self.guild_id.0, self.user.read().unwrap().id.0, - ban_options.dmd(), + dmd, &*reason, ) } |