From ea5e523caa6ecccee4f499b193cba00bac454715 Mon Sep 17 00:00:00 2001 From: Suneet Tipirneni <77477100+suneettipirneni@users.noreply.github.com> Date: Sat, 11 Feb 2023 14:26:12 -0500 Subject: [PATCH] feat(model): add `MessageFlags::SUPPRESS_NOTIFICATIONS` (#2129) Adds support for messages with suppressed notifications via a new `SUPPRESS_NOTIFICATIONS` message flag. This can be set when creating new messages and creating new threads in forum channels. Closes #2137. --- twilight-http/src/request/channel/message/create_message.rs | 4 +++- .../src/request/channel/thread/create_forum_thread/message.rs | 4 +++- twilight-model/src/channel/message/flags.rs | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/twilight-http/src/request/channel/message/create_message.rs b/twilight-http/src/request/channel/message/create_message.rs index 811f2b8cfd8..1bf86040e5a 100644 --- a/twilight-http/src/request/channel/message/create_message.rs +++ b/twilight-http/src/request/channel/message/create_message.rs @@ -238,9 +238,11 @@ impl<'a> CreateMessage<'a> { /// Set the message's flags. /// - /// The only supported flag is [`SUPPRESS_EMBEDS`]. + /// The only supported flags are [`SUPPRESS_EMBEDS`] and + /// [`SUPPRESS_NOTIFICATIONS`]. /// /// [`SUPPRESS_EMBEDS`]: MessageFlags::SUPPRESS_EMBEDS + /// [`SUPPRESS_NOTIFICATIONS`]: MessageFlags::SUPPRESS_NOTIFICATIONS pub const fn flags(mut self, flags: MessageFlags) -> Self { self.fields.flags = Some(flags); diff --git a/twilight-http/src/request/channel/thread/create_forum_thread/message.rs b/twilight-http/src/request/channel/thread/create_forum_thread/message.rs index 086deaa8eb3..d0d4cfaba81 100644 --- a/twilight-http/src/request/channel/thread/create_forum_thread/message.rs +++ b/twilight-http/src/request/channel/thread/create_forum_thread/message.rs @@ -152,9 +152,11 @@ impl<'a> CreateForumThreadMessage<'a> { /// Set the message's flags. /// - /// The only supported flag is [`SUPPRESS_EMBEDS`]. + /// The only supported flags are [`SUPPRESS_EMBEDS`] and + /// [`SUPPRESS_NOTIFICATIONS`]. /// /// [`SUPPRESS_EMBEDS`]: MessageFlags::SUPPRESS_EMBEDS + /// [`SUPPRESS_NOTIFICATIONS`]: MessageFlags::SUPPRESS_NOTIFICATIONS pub const fn flags(mut self, flags: MessageFlags) -> Self { self.0.fields.message.flags = Some(flags); diff --git a/twilight-model/src/channel/message/flags.rs b/twilight-model/src/channel/message/flags.rs index 070f7da5bdd..7c3167d3fb0 100644 --- a/twilight-model/src/channel/message/flags.rs +++ b/twilight-model/src/channel/message/flags.rs @@ -31,6 +31,8 @@ bitflags! { /// This message failed to mention some roles in a thread, which /// subsequently failed to add the role's members to the thread. const FAILED_TO_MENTION_SOME_ROLES_IN_THREAD = 1 << 8; + /// This message will not trigger push and desktop notifications. + const SUPPRESS_NOTIFICATIONS = 1 << 12; } } @@ -104,6 +106,7 @@ mod tests { MessageFlags::FAILED_TO_MENTION_SOME_ROLES_IN_THREAD.bits(), 1 << 8 ); + const_assert_eq!(MessageFlags::SUPPRESS_NOTIFICATIONS.bits(), 1 << 12); #[test] fn serde() {