diff options
| author | Austin Hellyer <[email protected]> | 2016-11-25 21:04:27 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-25 21:04:27 -0800 |
| commit | 4b3b3a7024ecdd77eb6ac24b6ad5bd936e7a5f3f (patch) | |
| tree | 686d13936289a76801d1188ce06119feff6675e5 /src/model/invite.rs | |
| parent | Catch some clippy lints (diff) | |
| download | serenity-4b3b3a7024ecdd77eb6ac24b6ad5bd936e7a5f3f.tar.xz serenity-4b3b3a7024ecdd77eb6ac24b6ad5bd936e7a5f3f.zip | |
More widely support no-cache method compiles
Conditional compiles with the 'methods' feature enabled - but the
'cache' feature disabled - were supported, but methods would call an
empty function to check if the current user has permissions. Instead,
put these function calls behind macros which check for feature cfgs.
Diffstat (limited to 'src/model/invite.rs')
| -rw-r--r-- | src/model/invite.rs | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/model/invite.rs b/src/model/invite.rs index 8322ddb..c05b4d4 100644 --- a/src/model/invite.rs +++ b/src/model/invite.rs @@ -44,19 +44,21 @@ impl Invite { /// /// # Errors /// - /// Returns a [`ClientError::InvalidPermissions`] if the current user does - /// not have the required [permission]. + /// If the `cache` is enabled, returns a [`ClientError::InvalidPermissions`] + /// if the current user does not have the required [permission]. /// /// [`ClientError::InvalidPermissions`]: ../client/enum.ClientError.html#variant.InvalidPermissions /// [Manage Guild]: permissions/constant.MANAGE_GUILD.html /// [permission]: permissions/index.html #[cfg(feature="methods")] pub fn delete(&self) -> Result<Invite> { - let req = permissions::MANAGE_GUILD; + feature_cache_enabled! {{ + let req = permissions::MANAGE_GUILD; - if !try!(utils::user_has_perms(self.channel.id, req)) { - return Err(Error::Client(ClientError::InvalidPermissions(req))); - } + if !try!(utils::user_has_perms(self.channel.id, req)) { + return Err(Error::Client(ClientError::InvalidPermissions(req))); + } + }} rest::delete_invite(&self.code) } @@ -75,8 +77,9 @@ impl RichInvite { /// /// # Errors /// - /// Returns a [`ClientError::InvalidOperationAsBot`] if the current user is - /// a bot user. + /// If the `cache` is enabled, returns a + /// [`ClientError::InvalidOperationAsBot`] if the current user is a bot + /// user. /// /// [`ClientError::InvalidOperationAsBot`]: enum.ClientError.html#variant.InvalidOperationAsBot /// [`Guild`]: struct.Guild.html |