Skip to content

Commit

Permalink
Update permissions for start_prune (#2881)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbt365 authored May 28, 2024
1 parent f53a56b commit ea0e0ae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/model/guild/guild_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1430,13 +1430,14 @@ impl GuildId {
///
/// See the documentation on [`GuildPrune`] for more information.
///
/// **Note**: Requires the [Kick Members] permission.
/// **Note**: Requires [Kick Members] and [Manage Guild] permissions.
///
/// # Errors
///
/// Returns [`Error::Http`] if the current user lacks permission.
///
/// [Kick Members]: Permissions::KICK_MEMBERS
/// [Manage Guild]: Permissions::KICK_MEMBERS
#[inline]
pub async fn start_prune(self, http: impl AsRef<Http>, days: u8) -> Result<GuildPrune> {
http.as_ref().start_guild_prune(self, days, None).await
Expand Down
5 changes: 3 additions & 2 deletions src/model/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2354,7 +2354,7 @@ impl Guild {
///
/// See the documentation on [`GuildPrune`] for more information.
///
/// **Note**: Requires the [Kick Members] permission.
/// **Note**: Requires [Kick Members] and [Manage Guild] permissions.
///
/// # Errors
///
Expand All @@ -2366,13 +2366,14 @@ impl Guild {
/// Can also return an [`Error::Json`] if there is an error deserializing the API response.
///
/// [Kick Members]: Permissions::KICK_MEMBERS
/// [Manage Guild]: Permissions::MANAGE_GUILD
/// [`Error::Http`]: crate::error::Error::Http
/// [`Error::Json`]: crate::error::Error::Json
pub async fn start_prune(&self, cache_http: impl CacheHttp, days: u8) -> Result<GuildPrune> {
#[cfg(feature = "cache")]
{
if let Some(cache) = cache_http.cache() {
self.require_perms(cache, Permissions::KICK_MEMBERS)?;
self.require_perms(cache, Permissions::KICK_MEMBERS | Permissions::MANAGE_GUILD)?;
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/model/guild/partial_guild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1119,7 +1119,7 @@ impl PartialGuild {
///
/// See the documentation on [`GuildPrune`] for more information.
///
/// **Note**: Requires the [Kick Members] permission.
/// **Note**: Requires [Kick Members] and [Manage Guild] permissions.
///
/// # Errors
///
Expand All @@ -1131,6 +1131,7 @@ impl PartialGuild {
/// Can also return an [`Error::Json`] if there is an error deserializing the API response.
///
/// [Kick Members]: Permissions::KICK_MEMBERS
/// [Manage Guild]: Permissions::MANAGE_GUILD
/// [`Error::Http`]: crate::error::Error::Http
/// [`Error::Json`]: crate::error::Error::Json
pub async fn start_prune(&self, cache_http: impl CacheHttp, days: u8) -> Result<GuildPrune> {
Expand Down

0 comments on commit ea0e0ae

Please sign in to comment.