From d1ee25de7733261cc1cf11775d85fb59c5d1fc23 Mon Sep 17 00:00:00 2001 From: suneettipirneni Date: Sat, 25 Mar 2023 16:47:49 -0400 Subject: [PATCH 1/3] feat(model): Add new `USE_SOUNDBOARD`, `MANAGE_GUILD_EXPRESSIONS` and `VIEW_CREATOR_MONETIZATION_ANALYTICS` permissions --- twilight-model/src/guild/permissions.rs | 14 ++++++++++++-- twilight-util/src/permission_calculator/preset.rs | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/twilight-model/src/guild/permissions.rs b/twilight-model/src/guild/permissions.rs index 39b383da147..c05e9901d91 100644 --- a/twilight-model/src/guild/permissions.rs +++ b/twilight-model/src/guild/permissions.rs @@ -39,7 +39,8 @@ bitflags! { const MANAGE_NICKNAMES = 1 << 27; const MANAGE_ROLES = 1 << 28; const MANAGE_WEBHOOKS = 1 << 29; - const MANAGE_EMOJIS_AND_STICKERS = 1 << 30; + /// Allows management and editing of emojis, stickers, and soundboard sounds. + const MANAGE_GUILD_EXPRESSIONS = 1 << 30; const USE_SLASH_COMMANDS = 1 << 31; const REQUEST_TO_SPEAK = 1 << 32; /// Allows for creating, editing, and deleting scheduled events. @@ -65,6 +66,10 @@ bitflags! { /// /// [Guild Timeouts]: https://support.discord.com/hc/en-us/articles/4413305239191-Time-Out-FAQ const MODERATE_MEMBERS = 1 << 40; + /// Allows for viewing role subscription insights. + const VIEW_CREATOR_MONETIZATION_ANALYTICS = 1 << 41; + /// Allows for using the soundboard in a voice channel + const USE_SOUNDBOARD = 1 << 42; } } @@ -176,7 +181,7 @@ mod tests { const_assert_eq!(Permissions::MANAGE_NICKNAMES.bits(), 1 << 27); const_assert_eq!(Permissions::MANAGE_ROLES.bits(), 1 << 28); const_assert_eq!(Permissions::MANAGE_WEBHOOKS.bits(), 1 << 29); - const_assert_eq!(Permissions::MANAGE_EMOJIS_AND_STICKERS.bits(), 1 << 30); + const_assert_eq!(Permissions::MANAGE_GUILD_EXPRESSIONS.bits(), 1 << 30); const_assert_eq!(Permissions::USE_SLASH_COMMANDS.bits(), 1 << 31); const_assert_eq!(Permissions::REQUEST_TO_SPEAK.bits(), 1 << 32); const_assert_eq!(Permissions::MANAGE_EVENTS.bits(), 1 << 33); @@ -187,6 +192,11 @@ mod tests { const_assert_eq!(Permissions::SEND_MESSAGES_IN_THREADS.bits(), 1 << 38); const_assert_eq!(Permissions::USE_EMBEDDED_ACTIVITIES.bits(), 1 << 39); const_assert_eq!(Permissions::MODERATE_MEMBERS.bits(), 1 << 40); + const_assert_eq!( + Permissions::VIEW_CREATOR_MONETIZATION_ANALYTICS.bits(), + 1 << 41 + ); + const_assert_eq!(Permissions::USE_SOUNDBOARD.bits(), 1 << 42); #[test] fn serde() { diff --git a/twilight-util/src/permission_calculator/preset.rs b/twilight-util/src/permission_calculator/preset.rs index 87d8cffbdc4..51641acfc8b 100644 --- a/twilight-util/src/permission_calculator/preset.rs +++ b/twilight-util/src/permission_calculator/preset.rs @@ -19,7 +19,7 @@ pub const PERMISSIONS_ROOT_ONLY: Permissions = Permissions::from_bits_truncate( | Permissions::BAN_MEMBERS.bits() | Permissions::CHANGE_NICKNAME.bits() | Permissions::KICK_MEMBERS.bits() - | Permissions::MANAGE_EMOJIS_AND_STICKERS.bits() + | Permissions::MANAGE_GUILD_EXPRESSIONS.bits() | Permissions::MANAGE_GUILD.bits() | Permissions::MANAGE_NICKNAMES.bits() | Permissions::VIEW_AUDIT_LOG.bits() From ce4b77d33b95492ea5d7f3b77abf831cf8c7c5c5 Mon Sep 17 00:00:00 2001 From: Zeyla Hellyer <57759500+zeylahellyer@users.noreply.github.com> Date: Sat, 25 Mar 2023 16:10:19 -0700 Subject: [PATCH 2/3] keep around the old one because why not --- twilight-model/src/guild/permissions.rs | 2 ++ twilight-util/src/permission_calculator/mod.rs | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/twilight-model/src/guild/permissions.rs b/twilight-model/src/guild/permissions.rs index c05e9901d91..87407b7d5bc 100644 --- a/twilight-model/src/guild/permissions.rs +++ b/twilight-model/src/guild/permissions.rs @@ -39,6 +39,8 @@ bitflags! { const MANAGE_NICKNAMES = 1 << 27; const MANAGE_ROLES = 1 << 28; const MANAGE_WEBHOOKS = 1 << 29; + #[deprecated(since = "0.15.2", note = "use `MANAGE_GUILD_EXPRESSIONS` instead")] + const MANAGE_EMOJIS_AND_STICKERS = 1 << 30; /// Allows management and editing of emojis, stickers, and soundboard sounds. const MANAGE_GUILD_EXPRESSIONS = 1 << 30; const USE_SLASH_COMMANDS = 1 << 31; diff --git a/twilight-util/src/permission_calculator/mod.rs b/twilight-util/src/permission_calculator/mod.rs index 74405f0bd35..b1a824dddb9 100644 --- a/twilight-util/src/permission_calculator/mod.rs +++ b/twilight-util/src/permission_calculator/mod.rs @@ -220,7 +220,7 @@ impl<'a> PermissionCalculator<'a> { /// permissions. /// /// **Note** that this method will not return guild-level permissions such - /// as [Manage Emojis and Stickers]; if you need the guild-level permissions + /// as [Manage Guild Expressions]; if you need the guild-level permissions /// use [`root`]. /// /// # Conditional exclusions @@ -310,7 +310,7 @@ impl<'a> PermissionCalculator<'a> { /// - [Ban Members] /// - [Change Nickname] /// - [Kick Members] - /// - [Manage Emojis and Stickers] + /// - [Manage Guild Expressions] /// - [Manage Guild] /// - [Manage Nicknames] /// - [View Audit Log] @@ -333,7 +333,7 @@ impl<'a> PermissionCalculator<'a> { /// [Deafen Members]: twilight_model::guild::Permissions::DEAFEN_MEMBERS /// [Embed Links]: twilight_model::guild::Permissions::EMBED_LINKS /// [Kick Members]: twilight_model::guild::Permissions::KICK_MEMBERS - /// [Manage Emojis and Stickers]: twilight_model::guild::Permissions::MANAGE_EMOJIS_AND_STICKERS + /// [Manage Guild Expressions]: twilight_model::guild::Permissions::MANAGE_GUILD_EXPRESSIONS /// [Manage Guild]: twilight_model::guild::Permissions::MANAGE_GUILD /// [Manage Messages]: twilight_model::guild::Permissions::MANAGE_MESSAGES /// [Manage Nicknames]: twilight_model::guild::Permissions::MANAGE_NICKNAMES From 41b379dcf1a0a20b8ada898e29e1a39c1d0622df Mon Sep 17 00:00:00 2001 From: Zeyla <57759500+zeylahellyer@users.noreply.github.com> Date: Sun, 2 Apr 2023 11:50:45 -0400 Subject: [PATCH 3/3] Update twilight-model/src/guild/permissions.rs --- twilight-model/src/guild/permissions.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/twilight-model/src/guild/permissions.rs b/twilight-model/src/guild/permissions.rs index 87407b7d5bc..7bf348baf15 100644 --- a/twilight-model/src/guild/permissions.rs +++ b/twilight-model/src/guild/permissions.rs @@ -70,7 +70,7 @@ bitflags! { const MODERATE_MEMBERS = 1 << 40; /// Allows for viewing role subscription insights. const VIEW_CREATOR_MONETIZATION_ANALYTICS = 1 << 41; - /// Allows for using the soundboard in a voice channel + /// Allows for using soundboard in a voice channel const USE_SOUNDBOARD = 1 << 42; } }