diff options
| author | Austin Hellyer <[email protected]> | 2016-11-16 17:53:34 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-16 18:01:26 -0800 |
| commit | cabad4681d9557cf3a2357bdbd849d2a657250c3 (patch) | |
| tree | 767370094aa57f257c5d031923ab1de2588abd93 /src/client/context.rs | |
| parent | Add Colour::from_rgb (diff) | |
| download | serenity-cabad4681d9557cf3a2357bdbd849d2a657250c3.tar.xz serenity-cabad4681d9557cf3a2357bdbd849d2a657250c3.zip | |
Accepting invites only works for user accounts
They do not work for bot users. So return a
`ClientError::InvalidOperationAsBot` if someone tries to.
Diffstat (limited to 'src/client/context.rs')
| -rw-r--r-- | src/client/context.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/client/context.rs b/src/client/context.rs index 1046361..522361a 100644 --- a/src/client/context.rs +++ b/src/client/context.rs @@ -48,8 +48,24 @@ impl Context { /// Refer to the documentation for [`Invite::accept`] for restrictions on /// accepting an invite. /// + /// **Note**: Requires that the current user be a user account. Bots can not + /// accept invites. Instead they must be accepted via OAuth2 authorization + /// links. These are in the format of: + /// + /// `https://discordapp.com/oauth2/authorize?client_id=CLIENT_ID&scope=bot` + /// + /// # Errors + /// + /// Returns a [`ClientError::InvalidOperationAsBot`] if the current user is + /// a bot user. + /// + /// [`ClientError::InvalidOperationAsBot`]: enum.ClientError.html#variant.InvalidOperationAsBot /// [`Invite::accept`]: ../model/struct.Invite.html#method.accept pub fn accept_invite(&self, invite: &str) -> Result<Invite> { + if self.login_type == LoginType::Bot { + return Err(Error::Client(ClientError::InvalidOperationAsBot)); + } + let code = utils::parse_invite(invite); http::accept_invite(code) |