diff options
| author | Zeyla Hellyer <[email protected]> | 2017-03-04 20:23:25 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-03-04 20:23:25 -0800 |
| commit | e4b484f1c823ccb0aa2be7c54e0def07e5a01806 (patch) | |
| tree | 4ed1e33ae233c5f7583b4c0941ee8e5e19778ff3 /src | |
| parent | Fix client::rest::get_guilds doctest (diff) | |
| download | serenity-e4b484f1c823ccb0aa2be7c54e0def07e5a01806.tar.xz serenity-e4b484f1c823ccb0aa2be7c54e0def07e5a01806.zip | |
Remove invite accepting
Diffstat (limited to 'src')
| -rw-r--r-- | src/client/rest/mod.rs | 45 | ||||
| -rw-r--r-- | src/model/invite.rs | 63 |
2 files changed, 0 insertions, 108 deletions
diff --git a/src/client/rest/mod.rs b/src/client/rest/mod.rs index 68606ec..12a9a39 100644 --- a/src/client/rest/mod.rs +++ b/src/client/rest/mod.rs @@ -82,51 +82,6 @@ pub fn set_token(token: &str) { TOKEN.lock().unwrap().clone_from(&token.to_owned()); } -/// Accepts the [`Invite`] given its code, placing the current user in the -/// [`Guild`] that the invite was for. -/// -/// Use [`utils::parse_invite`] to retrieve codes from URLs. -/// -/// Refer to the documentation for [`Context::accept_invite`] for restrictions on -/// accepting an invite. -/// -/// This will fire the [`Client::on_guild_create`] handler once the associated -/// event is received. -/// -/// **Note**: This will fail if you are already in the guild, or are banned. A -/// ban is equivalent to an IP ban. -/// -/// **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` -/// -/// # Examples -/// -/// Accept an invite given a code from a URL: -/// -/// ```rust,no_run -/// use serenity::client::rest; -/// use serenity::utils; -/// -/// let url = "https://discord.gg/0cDvIgU2voY8RSYL"; -/// let code = utils::parse_invite(url); -/// -/// let _result = rest::accept_invite(code); -/// ``` -/// -/// [`Client::on_guild_create`]: ../struct.Client.html#method.on_guild_create -/// [`Context::accept_invite`]: ../struct.Context.html#method.accept_invite -/// [`Guild`]: ../../model/struct.Guild.html -/// [`Invite`]: ../../model/struct.Invite.html -/// [`utils::parse_invite`]: ../../utils/fn.parse_invite.html -pub fn accept_invite(code: &str) -> Result<Invite> { - let response = request!(Route::InvitesCode, post, "/invites/{}", code); - - Invite::decode(serde_json::from_reader(response)?) -} - /// Marks a [`Channel`] as being "read" up to a certain [`Message`]. Any /// message past the given one will not be marked as read. /// diff --git a/src/model/invite.rs b/src/model/invite.rs index 7d7378e..4e33a3f 100644 --- a/src/model/invite.rs +++ b/src/model/invite.rs @@ -9,41 +9,8 @@ use ::utils; use super::permissions; #[cfg(feature="cache")] use super::utils as model_utils; -#[cfg(feature="cache")] -use ::client::CACHE; impl Invite { - /// Accepts the invite, placing the current user in the [`Guild`] that the - /// invite was for. - /// - /// Refer to [`rest::accept_invite`] for more information. - /// - /// **Note**: This will fail if you are already in the guild, or are banned. - /// A ban is equivalent to an IP ban. - /// - /// **Note**: Requires that the current user be a user account. - /// - /// # Errors - /// - /// If the `cache` features is enabled, then this returns a - /// [`ClientError::InvalidOperationAsBot`] if the current user does not have - /// the required [permission]. - /// - /// [`ClientError::InvalidOperationAsBot`]: ../client/enum.ClientError.html#variant.InvalidOperationAsBot - /// [`Guild`]: struct.Guild.html - /// [`rest::accept_invite`]: ../client/rest/fn.accept_invite.html - /// [permission]: permissions/index.html - pub fn accept(&self) -> Result<Invite> { - #[cfg(feature="cache")] - { - if CACHE.read().unwrap().user.bot { - return Err(Error::Client(ClientError::InvalidOperationAsBot)); - } - } - - rest::accept_invite(&self.code) - } - /// Creates an invite for a [`GuildChannel`], providing a builder so that /// fields may optionally be set. /// @@ -110,36 +77,6 @@ impl Invite { } impl RichInvite { - /// Accepts the invite, placing the current user in the [`Guild`] that the - /// invite was for. - /// - /// Refer to [`rest::accept_invite`] for more information. - /// - /// **Note**: This will fail if you are already in the guild, or are banned. - /// A ban is equivalent to an IP ban. - /// - /// **Note**: Requires that the current user be a user account. - /// - /// # Errors - /// - /// If the `cache` is enabled, returns a - /// [`ClientError::InvalidOperationAsBot`] if the current user is a bot - /// user. - /// - /// [`ClientError::InvalidOperationAsBot`]: ../client/enum.ClientError.html#variant.InvalidOperationAsBot - /// [`Guild`]: struct.Guild.html - /// [`rest::accept_invite`]: ../client/rest/fn.accept_invite.html - pub fn accept(&self) -> Result<Invite> { - #[cfg(feature="cache")] - { - if CACHE.read().unwrap().user.bot { - return Err(Error::Client(ClientError::InvalidOperationAsBot)); - } - } - - rest::accept_invite(&self.code) - } - /// Deletes the invite. /// /// Refer to [`rest::delete_invite`] for more information. |