diff --git a/command_attr/src/structures.rs b/command_attr/src/structures.rs index 5b5375d9f37..bab59084704 100644 --- a/command_attr/src/structures.rs +++ b/command_attr/src/structures.rs @@ -334,8 +334,8 @@ impl Permissions { "MANAGE_NICKNAMES" => 1 << 27, "MANAGE_ROLES" => 1 << 28, "MANAGE_WEBHOOKS" => 1 << 29, - "MANAGE_EMOJIS_AND_STICKERS" => 1 << 30, - "USE_SLASH_COMMANDS" => 1 << 31, + "MANAGE_EMOJIS_AND_STICKERS" | "MANAGE_GUILD_EXPRESSIONS" => 1 << 30, + "USE_SLASH_COMMANDS" | "USE_APPLICATION_COMMANDS" => 1 << 31, "REQUEST_TO_SPEAK" => 1 << 32, "MANAGE_EVENTS" => 1 << 33, "MANAGE_THREADS" => 1 << 34, @@ -345,6 +345,12 @@ impl Permissions { "SEND_MESSAGES_IN_THREADS" => 1 << 38, "USE_EMBEDDED_ACTIVITIES" => 1 << 39, "MODERATE_MEMBERS" => 1 << 40, + "VIEW_CREATOR_MONETIZATION_ANALYTICS" => 1 << 41, + "USE_SOUNDBOARD" => 1 << 42, + "CREATE_GUILD_EXPRESSIONS" => 1 << 43, + "CREATE_EVENTS" => 1 << 44, + "USE_EXTERNAL_SOUNDS" => 1 << 45, + "SEND_VOICE_MESSAGES" => 1 << 46, "SET_VOICE_CHANNEL_STATUS" => 1 << 48, _ => return None, })) diff --git a/src/builder/create_scheduled_event.rs b/src/builder/create_scheduled_event.rs index 87d7180e664..47a8e4d91df 100644 --- a/src/builder/create_scheduled_event.rs +++ b/src/builder/create_scheduled_event.rs @@ -130,21 +130,21 @@ impl<'a> Builder for CreateScheduledEvent<'a> { /// Creates a new scheduled event in the guild with the data set, if any. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [Create Events] permission. /// /// # Errors /// /// If the `cache` is enabled, returns a [`ModelError::InvalidPermissions`] if the current user /// lacks permission. Otherwise returns [`Error::Http`], as well as if invalid data is given. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [Create Events]: Permissions::CREATE_EVENTS async fn execute( self, cache_http: impl CacheHttp, ctx: Self::Context<'_>, ) -> Result { #[cfg(feature = "cache")] - crate::utils::user_has_guild_perms(&cache_http, ctx, Permissions::MANAGE_EVENTS).await?; + crate::utils::user_has_guild_perms(&cache_http, ctx, Permissions::CREATE_EVENTS).await?; cache_http.http().create_scheduled_event(ctx, &self, self.audit_log_reason).await } diff --git a/src/builder/create_sticker.rs b/src/builder/create_sticker.rs index 828cff14275..46cde7143f0 100644 --- a/src/builder/create_sticker.rs +++ b/src/builder/create_sticker.rs @@ -81,26 +81,22 @@ impl<'a> Builder for CreateSticker<'a> { /// Creates a new sticker in the guild with the data set, if any. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: Requires the [Create Guild Expressions] permission. /// /// # Errors /// /// If the `cache` is enabled, returns a [`ModelError::InvalidPermissions`] if the current user /// lacks permission. Otherwise returns [`Error::Http`], as well as if invalid data is given. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS async fn execute( self, cache_http: impl CacheHttp, ctx: Self::Context<'_>, ) -> Result { #[cfg(feature = "cache")] - crate::utils::user_has_guild_perms( - &cache_http, - ctx, - Permissions::MANAGE_EMOJIS_AND_STICKERS, - ) - .await?; + crate::utils::user_has_guild_perms(&cache_http, ctx, Permissions::CREATE_GUILD_EXPRESSIONS) + .await?; let map = vec![("name", self.name), ("tags", self.tags), ("description", self.description)]; diff --git a/src/builder/edit_scheduled_event.rs b/src/builder/edit_scheduled_event.rs index 0672c237d3f..77b94fd0921 100644 --- a/src/builder/edit_scheduled_event.rs +++ b/src/builder/edit_scheduled_event.rs @@ -174,22 +174,21 @@ impl<'a> Builder for EditScheduledEvent<'a> { /// Modifies a scheduled event in the guild with the data set, if any. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: If the event was created by the current user, requires either [Create Events] or + /// the [Manage Events] permission. Otherwise, the [Manage Events] permission is required. /// /// # Errors /// /// If the `cache` is enabled, returns a [`ModelError::InvalidPermissions`] if the current user /// lacks permission. Otherwise returns [`Error::Http`], as well as if invalid data is given. /// + /// [Create Events]: Permissions::CREATE_EVENTS /// [Manage Events]: Permissions::MANAGE_EVENTS async fn execute( self, cache_http: impl CacheHttp, ctx: Self::Context<'_>, ) -> Result { - #[cfg(feature = "cache")] - crate::utils::user_has_guild_perms(&cache_http, ctx.0, Permissions::MANAGE_EVENTS).await?; - cache_http.http().edit_scheduled_event(ctx.0, ctx.1, &self, self.audit_log_reason).await } } diff --git a/src/builder/edit_sticker.rs b/src/builder/edit_sticker.rs index 5a3a6585066..2b8af762646 100644 --- a/src/builder/edit_sticker.rs +++ b/src/builder/edit_sticker.rs @@ -76,13 +76,16 @@ impl<'a> Builder for EditSticker<'a> { /// Edits the sticker. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the sticker was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission, or if invalid data is given. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS async fn execute( self, cache_http: impl CacheHttp, diff --git a/src/http/client.rs b/src/http/client.rs index 0bd6aa0829b..6ddf3df3cb6 100644 --- a/src/http/client.rs +++ b/src/http/client.rs @@ -442,9 +442,9 @@ impl Http { /// /// View the source code for [`Guild::create_emoji`] method to see what fields this requires. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: Requires the [Create Guild Expressions] permission. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS pub async fn create_emoji( &self, guild_id: GuildId, @@ -821,9 +821,9 @@ impl Http { /// /// Refer to Discord's docs for field information. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [Create Events] permission. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [Create Events]: Permissions::CREATE_EVENTS pub async fn create_scheduled_event( &self, guild_id: GuildId, @@ -846,9 +846,9 @@ impl Http { /// Creates a sticker. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: Requires the [Create Guild Expressions] permission. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS pub async fn create_sticker<'a>( &self, guild_id: GuildId, @@ -959,6 +959,8 @@ impl Http { } /// Deletes an emoji from a server. + /// + /// See [`GuildId::edit_emoji`] for permissions requirements. pub async fn delete_emoji( &self, guild_id: GuildId, @@ -1326,9 +1328,7 @@ impl Http { /// Deletes a sticker from a server. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. - /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// See [`GuildId::delete_sticker`] for permissions requirements. pub async fn delete_sticker( &self, guild_id: GuildId, @@ -1470,6 +1470,8 @@ impl Http { } /// Changes emoji information. + /// + /// See [`GuildId::edit_emoji`] for permissions requirements. pub async fn edit_emoji( &self, guild_id: GuildId, @@ -2076,9 +2078,7 @@ impl Http { /// Changes a sticker in a guild. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. - /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// See [`GuildId::edit_sticker`] for permissions requirements. pub async fn edit_sticker( &self, guild_id: GuildId, @@ -3456,9 +3456,9 @@ impl Http { /// Gets a scheduled event by Id. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [View Channel] permission for the channel associated with the event. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [View Channel]: Permissions::VIEW_CHANNEL pub async fn get_scheduled_event( &self, guild_id: GuildId, @@ -3481,9 +3481,9 @@ impl Http { /// Gets a list of all scheduled events for the corresponding guild. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [View Channel] permission at the guild level. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [View Channel]: Permissions::VIEW_CHANNEL pub async fn get_scheduled_events( &self, guild_id: GuildId, @@ -3514,7 +3514,6 @@ impl Http { /// be populated with [`Guild Member`] information, if the interested user is a member of the /// guild the event takes place in. /// - /// [`UserId`]: crate::model::id::UserId /// [`member`]: ScheduledEventUser::member /// [`Guild Member`]: crate::model::guild::Member pub async fn get_scheduled_event_users( diff --git a/src/model/guild/emoji.rs b/src/model/guild/emoji.rs index bc4a1781dc6..2a802e146dc 100644 --- a/src/model/guild/emoji.rs +++ b/src/model/guild/emoji.rs @@ -57,8 +57,9 @@ pub struct Emoji { impl Emoji { /// Deletes the emoji. This method requires the cache to fetch the guild ID. /// - /// **Note**: The [Manage Emojis and Stickers] permission is required. - /// + /// **Note**: If the emoji was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Examples /// @@ -87,7 +88,8 @@ impl Emoji { /// Returns [`Error::Http`] if the current user lacks permission, or may return /// [`ModelError::ItemMissing`] if the emoji is not in the cache. /// - /// [Manage Emojis and Stickers]: crate::model::permissions::Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: crate::model::Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: crate::model::Permissions::MANAGE_GUILD_EXPRESSIONS #[cfg(feature = "cache")] #[inline] pub async fn delete(&self, cache_http: impl CacheHttp) -> Result<()> { @@ -98,14 +100,17 @@ impl Emoji { /// Edits the emoji by updating it with a new name. This method requires the cache to fetch the /// guild ID. /// - /// **Note**: The [Manage Emojis and Stickers] permission is required. + /// **Note**: If the emoji was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission, or if an invalid name is /// given. /// - /// [Manage Emojis and Stickers]: crate::model::permissions::Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: crate::model::Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: crate::model::Permissions::MANAGE_GUILD_EXPRESSIONS #[cfg(feature = "cache")] pub async fn edit(&mut self, cache_http: impl CacheHttp, name: &str) -> Result<()> { let guild_id = self.try_find_guild_id(&cache_http)?; diff --git a/src/model/guild/guild_id.rs b/src/model/guild/guild_id.rs index 11f1415edfc..349eb6f8414 100644 --- a/src/model/guild/guild_id.rs +++ b/src/model/guild/guild_id.rs @@ -354,7 +354,7 @@ impl GuildId { /// /// Refer to the documentation for [`Guild::create_emoji`] for more information. /// - /// Requires the [Manage Emojis and Stickers] permission. + /// Requires the [Create Guild Expressions] permission. /// /// # Examples /// @@ -368,7 +368,7 @@ impl GuildId { /// if the image is too big. /// /// [`EditProfile::avatar`]: crate::builder::EditProfile::avatar - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS #[inline] pub async fn create_emoji( self, @@ -432,14 +432,14 @@ impl GuildId { /// Creates a new scheduled event in the guild with the data set, if any. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [Create Events] permission. /// /// # Errors /// /// If the `cache` is enabled, returns a [`ModelError::InvalidPermissions`] if the current user /// lacks permission. Otherwise returns [`Error::Http`], as well as if invalid data is given. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [Manage Events]: Permissions::CREATE_EVENTS pub async fn create_scheduled_event( self, cache_http: impl CacheHttp, @@ -450,14 +450,14 @@ impl GuildId { /// Creates a new sticker in the guild with the data set, if any. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: Requires the [Create Guild Expressions] permission. /// /// # Errors /// /// If the `cache` is enabled, returns a [`ModelError::InvalidPermissions`] if the current user /// lacks permission. Otherwise returns [`Error::Http`], as well as if invalid data is given. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS #[inline] pub async fn create_sticker( self, @@ -484,14 +484,17 @@ impl GuildId { /// Deletes an [`Emoji`] from the guild. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the emoji was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// - /// Returns [`Error::Http`] if the current user lacks permission, - /// or if an Emoji with that Id does not exist. + /// Returns [`Error::Http`] if the current user lacks permission, or if an emoji with the given + /// id does not exist in the guild. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn delete_emoji( self, @@ -543,12 +546,14 @@ impl GuildId { /// Deletes a specified scheduled event in the guild. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: If the event was created by the current user, requires either [Create Events] or + /// the [Manage Events] permission. Otherwise, the [Manage Events] permission is required. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission, or if invalid data is given. /// + /// [Create Events]: Permissions::CREATE_EVENTS /// [Manage Events]: Permissions::MANAGE_EVENTS #[inline] pub async fn delete_scheduled_event( @@ -559,16 +564,19 @@ impl GuildId { http.as_ref().delete_scheduled_event(self, event_id.into()).await } - /// Deletes a [`Sticker`] by Id from the guild. + /// Deletes a [`Sticker`] by id from the guild. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the sticker was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// - /// Returns [`Error::Http`] if the current user lacks permission, or if a sticker with that Id + /// Returns [`Error::Http`] if the current user lacks permission, or if a sticker with that id /// does not exist. /// - /// [Manage Emojis and Stickers]: crate::model::permissions::Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn delete_sticker( self, @@ -601,13 +609,17 @@ impl GuildId { /// /// Also see [`Emoji::edit`] if you have the `cache` and `methods` features enabled. /// - /// Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the emoji was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// - /// Returns [`Error::Http`] if the current user lacks permission. + /// Returns [`Error::Http`] if the current user lacks permission, or if an Emoji with the given + /// id does not exist. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn edit_emoji( self, @@ -743,13 +755,15 @@ impl GuildId { /// Modifies a scheduled event in the guild with the data set, if any. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: If the event was created by the current user, requires either [Create Events] or + /// the [Manage Events] permission. Otherwise, the [Manage Events] permission is required. /// /// # Errors /// /// If the `cache` is enabled, returns a [`ModelError::InvalidPermissions`] if the current user /// lacks permission. Otherwise returns [`Error::Http`], as well as if invalid data is given. /// + /// [Create Events]: Permissions::CREATE_EVENTS /// [Manage Events]: Permissions::MANAGE_EVENTS pub async fn edit_scheduled_event( self, @@ -762,7 +776,9 @@ impl GuildId { /// Edits a sticker. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the sticker was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Examples /// @@ -785,7 +801,8 @@ impl GuildId { /// /// Returns [`Error::Http`] if the current user lacks permission, or if invalid data is given. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn edit_sticker( self, @@ -1241,14 +1258,14 @@ impl GuildId { /// `true`, then the `user_count` field will be populated, indicating the number of users /// interested in the event. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [View Channel] permission for the channel associated with the event. /// /// # Errors /// - /// Returns [`Error::Http`] if the current user lacks permission, or if the provided Id is + /// Returns [`Error::Http`] if the current user lacks permission, or if the provided id is /// invalid. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [View Channel]: Permissions::VIEW_CHANNEL pub async fn scheduled_event( self, http: impl AsRef, @@ -1261,13 +1278,13 @@ impl GuildId { /// Fetches a list of all scheduled events in the guild. If `with_user_count` is set to `true`, /// then each event returned will have its `user_count` field populated. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [View Channel] permission at the guild level. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [View Channel]: Permissions::VIEW_CHANNEL pub async fn scheduled_events( self, http: impl AsRef, @@ -1280,14 +1297,14 @@ impl GuildId { /// /// If `limit` is left unset, by default at most 100 users are returned. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [View Channel] permission for the channel associated with the event. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission, or if the provided Id is /// invalid. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [View Channel]: Permissions::VIEW_CHANNEL pub async fn scheduled_event_users( self, http: impl AsRef, @@ -1300,14 +1317,14 @@ impl GuildId { /// Fetches a list of interested users for the specified event, with additional options and /// filtering. See [`Http::get_scheduled_event_users`] for details. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [View Channel] permission for the channel associated with the event. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission, or if the provided Id is /// invalid. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [View Channel]: Permissions::VIEW_CHANNEL pub async fn scheduled_event_users_optioned( self, http: impl AsRef, diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs index 3bc428932a4..a30c82eebac 100644 --- a/src/model/guild/mod.rs +++ b/src/model/guild/mod.rs @@ -694,7 +694,7 @@ impl Guild { /// The name of the emoji must be at least 2 characters long and can only contain alphanumeric /// characters and underscores. /// - /// Requires the [Manage Emojis and Stickers] permission. + /// Requires the [Create Guild Expressions] permission. /// /// # Examples /// @@ -708,7 +708,7 @@ impl Guild { /// /// [`EditProfile::avatar`]: crate::builder::EditProfile::avatar /// [`CreateAttachment`]: crate::builder::CreateAttachment - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS #[inline] pub async fn create_emoji( &self, @@ -899,14 +899,14 @@ impl Guild { /// Creates a new scheduled event in the guild with the data set, if any. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [Create Events] permission. /// /// # Errors /// /// If the `cache` is enabled, returns a [`ModelError::InvalidPermissions`] if the current user /// lacks permission. Otherwise returns [`Error::Http`], as well as if invalid data is given. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [Create Events]: Permissions::CREATE_EVENTS pub async fn create_scheduled_event( &self, cache_http: impl CacheHttp, @@ -917,14 +917,14 @@ impl Guild { /// Creates a new sticker in the guild with the data set, if any. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: Requires the [Create Guild Expressions] permission. /// /// # Errors /// /// If the `cache` is enabled, returns a [`ModelError::InvalidPermissions`] if the current user /// lacks permission. Otherwise returns [`Error::Http`], as well as if invalid data is given. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS pub async fn create_sticker<'a>( &self, cache_http: impl CacheHttp, @@ -959,13 +959,17 @@ impl Guild { /// Deletes an [`Emoji`] from the guild. /// - /// Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the emoji was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// - /// Returns [`Error::Http`] if the current user lacks permission. + /// Returns [`Error::Http`] if the current user lacks permission, or if an emoji with the given + /// id does not exist in the guild. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn delete_emoji( &self, @@ -1014,15 +1018,16 @@ impl Guild { self.id.delete_role(http, role_id).await } - /// Deletes a [Scheduled Event] by Id from the guild. + /// Deletes a [`ScheduledEvent`] by id from the guild. /// - /// Requires the [Manage Events] permission. + /// **Note**: If the event was created by the current user, requires either [Create Events] or + /// the [Manage Events] permission. Otherwise, the [Manage Events] permission is required. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission to delete the scheduled event. /// - /// [Scheduled Event]: ScheduledEvent + /// [Create Events]: Permissions::CREATE_EVENTS /// [Manage Events]: Permissions::MANAGE_EVENTS #[inline] pub async fn delete_scheduled_event( @@ -1035,13 +1040,17 @@ impl Guild { /// Deletes a [`Sticker`] by Id from the guild. /// - /// Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the sticker was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// - /// Returns [`Error::Http`] if the current user lacks permission to delete the sticker. + /// Returns [`Error::Http`] if the current user lacks permission, or if a sticker with that id + /// does not exist. /// - /// [Manage Emojis and Stickers]: crate::model::permissions::Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn delete_sticker( &self, @@ -1103,13 +1112,17 @@ impl Guild { /// /// Also see [`Emoji::edit`] if you have the `cache` and `model` features enabled. /// - /// Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the emoji was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// - /// Returns [`Error::Http`] if the current user lacks permission. + /// Returns [`Error::Http`] if the current user lacks permission, or if an Emoji with the given + /// id does not exist. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn edit_emoji( &self, @@ -1240,13 +1253,15 @@ impl Guild { /// Modifies a scheduled event in the guild with the data set, if any. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: If the event was created by the current user, requires either [Create Events] or + /// the [Manage Events] permission. Otherwise, the [Manage Events] permission is required. /// /// # Errors /// /// If the `cache` is enabled, returns a [`ModelError::InvalidPermissions`] if the current user /// lacks permission. Otherwise returns [`Error::Http`], as well as if invalid data is given. /// + /// [Create Events]: Permissions::CREATE_EVENTS /// [Manage Events]: Permissions::MANAGE_EVENTS pub async fn edit_scheduled_event( &self, @@ -1259,7 +1274,9 @@ impl Guild { /// Edits a sticker. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the sticker was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Examples /// @@ -1285,7 +1302,8 @@ impl Guild { /// /// Returns [`Error::Http`] if the current user lacks permission, or if invalid data is given. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn edit_sticker( &self, @@ -2139,14 +2157,14 @@ impl Guild { /// `true`, then the `user_count` field will be populated, indicating the number of users /// interested in the event. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [View Channel] permission for the channel associated with the event. /// /// # Errors /// - /// Returns [`Error::Http`] if the current user lacks permission, or if the provided Id is + /// Returns [`Error::Http`] if the current user lacks permission, or if the provided id is /// invalid. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [View Channel]: Permissions::VIEW_CHANNEL pub async fn scheduled_event( &self, http: impl AsRef, @@ -2159,13 +2177,13 @@ impl Guild { /// Fetches a list of all scheduled events in the guild. If `with_user_count` is set to `true`, /// then each event returned will have its `user_count` field populated. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [View Channel] permission at the guild level. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [View Channel]: Permissions::VIEW_CHANNEL pub async fn scheduled_events( &self, http: impl AsRef, @@ -2178,14 +2196,14 @@ impl Guild { /// /// If `limit` is left unset, by default at most 100 users are returned. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [View Channel] permission for the channel associated with the event. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission, or if the provided Id is /// invalid. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [View Channel]: Permissions::VIEW_CHANNEL pub async fn scheduled_event_users( &self, http: impl AsRef, @@ -2198,14 +2216,14 @@ impl Guild { /// Fetches a list of interested users for the specified event, with additional options and /// filtering. See [`Http::get_scheduled_event_users`] for details. /// - /// **Note**: Requires the [Manage Events] permission. + /// **Note**: Requires the [View Channel] permission for the channel associated with the event. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission, or if the provided Id is /// invalid. /// - /// [Manage Events]: Permissions::MANAGE_EVENTS + /// [View Channel]: Permissions::VIEW_CHANNEL pub async fn scheduled_event_users_optioned( &self, http: impl AsRef, diff --git a/src/model/guild/partial_guild.rs b/src/model/guild/partial_guild.rs index 185ef03b26b..35741f745a7 100644 --- a/src/model/guild/partial_guild.rs +++ b/src/model/guild/partial_guild.rs @@ -445,7 +445,7 @@ impl PartialGuild { /// /// Refer to the documentation for [`Guild::create_emoji`] for more information. /// - /// Requires the [Manage Emojis and Stickers] permission. + /// Requires the [Create Guild Expressions] permission. /// /// # Examples /// @@ -460,7 +460,7 @@ impl PartialGuild { /// /// [`EditProfile::avatar`]: crate::builder::EditProfile::avatar /// [`utils::read_image`]: crate::utils::read_image - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS #[inline] pub async fn create_emoji( &self, @@ -650,14 +650,14 @@ impl PartialGuild { /// Creates a new sticker in the guild with the data set, if any. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: Requires the [Create Guild Expressions] permission. /// /// # Errors /// /// If the `cache` is enabled, returns a [`ModelError::InvalidPermissions`] if the current user /// lacks permission. Otherwise returns [`Error::Http`], as well as if invalid data is given. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS pub async fn create_sticker<'a>( &self, cache_http: impl CacheHttp, @@ -682,14 +682,17 @@ impl PartialGuild { /// Deletes an [`Emoji`] from the guild. /// - /// Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the emoji was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// - /// Returns [`Error::Http`] if the current user lacks permission, or if an emoji with that Id - /// does not exist in the guild. + /// Returns [`Error::Http`] if the current user lacks permission, or if an emoji with the given + /// id does not exist in the guild. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn delete_emoji( &self, @@ -741,13 +744,17 @@ impl PartialGuild { /// Deletes a [`Sticker`] by Id from the guild. /// - /// Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the sticker was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// - /// Returns [`Error::Http`] if the current user lacks permission to delete the sticker. + /// Returns [`Error::Http`] if the current user lacks permission, or if a sticker with that id + /// does not exist. /// - /// [Manage Emojis and Stickers]: crate::model::permissions::Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn delete_sticker( &self, @@ -789,14 +796,17 @@ impl PartialGuild { /// /// Also see [`Emoji::edit`] if you have the `cache` and `methods` features enabled. /// - /// Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the emoji was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// - /// Returns [`Error::Http`] if the current user lacks permission, or if an emoji with that Id - /// does not exist in the guild. + /// Returns [`Error::Http`] if the current user lacks permission, or if an Emoji with the given + /// id does not exist. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn edit_emoji( &self, @@ -918,7 +928,9 @@ impl PartialGuild { /// Edits a sticker. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the sticker was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Examples /// @@ -944,7 +956,8 @@ impl PartialGuild { /// /// Returns [`Error::Http`] if the current user lacks permission, or if invalid data is given. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn edit_sticker( &self, diff --git a/src/model/permissions.rs b/src/model/permissions.rs index 64544682ec3..e94d8c9d6cd 100644 --- a/src/model/permissions.rs +++ b/src/model/permissions.rs @@ -313,16 +313,17 @@ bitflags::bitflags! { const MANAGE_ROLES = 1 << 28; /// Allows management of webhooks. const MANAGE_WEBHOOKS = 1 << 29; - /// Allows management of emojis and stickers created without the use of an [`Integration`]. - /// - /// [`Integration`]: super::guild::Integration + /// Allows for editing and deleting emojis, stickers, and soundboard sounds created by all + /// users. + const MANAGE_GUILD_EXPRESSIONS = 1 << 30; + #[deprecated = "use `Permissions::MANAGE_GUILD_EXPRESSIONS` instead"] const MANAGE_EMOJIS_AND_STICKERS = 1 << 30; /// Allows members to use application commands, including slash commands and context menu /// commands. const USE_APPLICATION_COMMANDS = 1 << 31; /// Allows for requesting to speak in stage channels. const REQUEST_TO_SPEAK = 1 << 32; - /// Allows for creating, editing, and deleting scheduled events + /// Allows for editing, and deleting scheduled events created by all users. const MANAGE_EVENTS = 1 << 33; /// Allows for deleting and archiving threads, and viewing all private threads. const MANAGE_THREADS = 1 << 34; @@ -343,6 +344,12 @@ bitflags::bitflags! { const VIEW_CREATOR_MONETIZATION_ANALYTICS = 1 << 41; /// Allows for using soundboard in a voice channel. const USE_SOUNDBOARD = 1 << 42; + /// Allows for creating emojis, stickers, and soundboard sounds, and editing and deleting + /// those created by the current user. + const CREATE_GUILD_EXPRESSIONS = 1 << 43; + /// Allows for creating scheduled events, and editing and deleting those created by the + /// current user. + const CREATE_EVENTS = 1 << 44; /// Allows the usage of custom soundboard sounds from other servers. const USE_EXTERNAL_SOUNDS = 1 << 45; /// Allows sending voice messages. @@ -361,6 +368,8 @@ generate_get_permission_names! { ban_members: "Ban Members", change_nickname: "Change Nickname", connect: "Connect", + create_events: "Create Events", + create_guild_expressions: "Create Guild Expressions", create_instant_invite: "Create Instant Invite", create_private_threads: "Create Private Threads", create_public_threads: "Create Public Threads", @@ -369,9 +378,9 @@ generate_get_permission_names! { external_emojis: "Use External Emojis", kick_members: "Kick Members", manage_channels: "Manage Channels", - manage_emojis_and_stickers: "Manage Emojis and Stickers", manage_events: "Manage Events", manage_guild: "Manage Guilds", + manage_guild_expressions: "Manage Guild Expressions", manage_messages: "Manage Messages", manage_nicknames: "Manage Nicknames", manage_roles: "Manage Roles", @@ -451,6 +460,23 @@ impl Permissions { self.contains(Self::CONNECT) } + /// Shorthand for checking that the set of permissions contains the [Create Events] permission. + /// + /// [Create Events]: Self::CREATE_EVENTS + #[must_use] + pub const fn create_events(self) -> bool { + self.contains(Self::CREATE_EVENTS) + } + + /// Shorthand for checking that the set of permissions contains the [Create Guild Expressions] + /// permission. + /// + /// [Create Guild Expressions]: Self::CREATE_GUILD_EXPRESSIONS + #[must_use] + pub const fn create_guild_expressions(self) -> bool { + self.contains(Self::CREATE_GUILD_EXPRESSIONS) + } + /// Shorthand for checking that the set of permissions contains the [View Audit Log] /// permission. /// @@ -564,12 +590,10 @@ impl Permissions { self.contains(Self::MANAGE_CHANNELS) } - /// Shorthand for checking that the set of permissions contains the [Manage Emojis and - /// Stickers] permission. - /// - /// [Manage Emojis and Stickers]: Self::MANAGE_EMOJIS_AND_STICKERS + #[deprecated = "use `manage_guild_expressions` instead"] #[must_use] pub const fn manage_emojis_and_stickers(self) -> bool { + #[allow(deprecated)] self.contains(Self::MANAGE_EMOJIS_AND_STICKERS) } @@ -589,6 +613,14 @@ impl Permissions { self.contains(Self::MANAGE_GUILD) } + /// Shorthand for checking that the set of permissions contains the [Manage Guild Expressions] + /// permission. + /// + /// [Manage Guild Expressions]: Self::MANAGE_GUILD_EXPRESSIONS + pub const fn manage_guild_expressions(self) -> bool { + self.contains(Self::MANAGE_GUILD_EXPRESSIONS) + } + /// Shorthand for checking that the set of permissions contains the [Manage Messages] /// permission. /// diff --git a/src/model/sticker.rs b/src/model/sticker.rs index 0be9dbe0486..9ca7a4b6228 100644 --- a/src/model/sticker.rs +++ b/src/model/sticker.rs @@ -11,13 +11,17 @@ use crate::model::utils::comma_separated_string; impl StickerId { /// Delete a guild sticker. /// - /// **Note**: The [Manage Emojis and Stickers] permission is required. + /// **Note**: If the sticker was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission. /// - /// [Manage Emojis and Stickers]: crate::model::permissions::Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS + #[deprecated = "use `GuildId::delete_sticker` instead"] pub async fn delete(self, http: impl AsRef, guild_id: impl Into) -> Result<()> { guild_id.into().delete_sticker(http, self).await } @@ -34,13 +38,17 @@ impl StickerId { /// Edits the sticker. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the sticker was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission, or if invalid data is given. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS + #[deprecated = "use `GuildId::edit_sticker` instead"] pub async fn edit( self, cache_http: impl CacheHttp, @@ -161,10 +169,11 @@ pub struct Sticker { pub available: bool, /// Id of the guild that owns this sticker. pub guild_id: Option, - /// User that uploaded the sticker. This will be `None` if the current user does not have the - /// [Manage Emojis and Stickers] permission. + /// User that uploaded the sticker. This will be `None` if the current user does not have + /// either the [Create Guild Expressions] nor the [Manage Guild Expressions] permission. /// - /// [Manage Emojis and Stickers]: crate::model::permissions::Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS pub user: Option, /// A sticker's sort order within a pack. pub sort_value: Option, @@ -172,15 +181,18 @@ pub struct Sticker { #[cfg(feature = "model")] impl Sticker { - /// Deletes a [`Sticker`] by Id from the guild. + /// Deletes the [`Sticker`] from its guild. /// - /// Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the sticker was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Errors /// /// Returns [`Error::Http`] if the current user lacks permission to delete the sticker. /// - /// [Manage Emojis and Stickers]: crate::model::permissions::Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn delete(&self, http: impl AsRef) -> Result<()> { if let Some(guild_id) = self.guild_id { @@ -192,7 +204,9 @@ impl Sticker { /// Edits the sticker. /// - /// **Note**: Requires the [Manage Emojis and Stickers] permission. + /// **Note**: If the sticker was created by the current user, requires either the [Create Guild + /// Expressions] or the [Manage Guild Expressions] permission. Otherwise, the [Manage Guild + /// Expressions] permission is required. /// /// # Examples /// @@ -217,7 +231,8 @@ impl Sticker { /// /// Returns [`Error::Http`] if the current user lacks permission. /// - /// [Manage Emojis and Stickers]: Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS + /// [Manage Guild Expressions]: Permissions::MANAGE_GUILD_EXPRESSIONS #[inline] pub async fn edit( &mut self, @@ -225,7 +240,7 @@ impl Sticker { builder: EditSticker<'_>, ) -> Result<()> { if let Some(guild_id) = self.guild_id { - *self = self.id.edit(cache_http, guild_id, builder).await?; + *self = guild_id.edit_sticker(cache_http, self.id, builder).await?; Ok(()) } else { Err(Error::Model(ModelError::DeleteNitroSticker))