Skip to content

Commit

Permalink
feat(model): add MessageFlags::SUPPRESS_NOTIFICATIONS (#2129)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
suneettipirneni committed Feb 11, 2023
1 parent 8d2a085 commit ea5e523
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion twilight-http/src/request/channel/message/create_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 3 additions & 0 deletions twilight-model/src/channel/message/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit ea5e523

Please sign in to comment.