diff --git a/src/main/java/club/minnced/discord/webhook/MessageFlags.java b/src/main/java/club/minnced/discord/webhook/MessageFlags.java
index d9a0ffc..5d46098 100644
--- a/src/main/java/club/minnced/discord/webhook/MessageFlags.java
+++ b/src/main/java/club/minnced/discord/webhook/MessageFlags.java
@@ -21,12 +21,15 @@
*/
@SuppressWarnings("PointlessBitwiseExpression")
public class MessageFlags {
- public static final int CROSSPOSTED = 1 << 0;
- public static final int IS_CROSSPOSTED = 1 << 1;
- public static final int SUPPRESS_EMBEDS = 1 << 2;
- public static final int SOURCE_MESSAGE_DELETED = 1 << 3;
- public static final int URGENT = 1 << 4;
- public static final int HAS_THREAD = 1 << 5;
- public static final int EPHEMERAL = 1 << 6;
- public static final int LOADING = 1 << 7;
-}
+ public static final int CROSSPOSTED = 1 << 0;
+ public static final int IS_CROSSPOSTED = 1 << 1;
+ public static final int SUPPRESS_EMBEDS = 1 << 2;
+ public static final int SOURCE_MESSAGE_DELETED = 1 << 3;
+ public static final int URGENT = 1 << 4;
+ public static final int HAS_THREAD = 1 << 5;
+ public static final int EPHEMERAL = 1 << 6;
+ public static final int LOADING = 1 << 7;
+ public static final int FAILED_TO_MENTION_SOME_ROLES_IN_THREAD = 1 << 8;
+ public static final int SUPPRESS_NOTIFICATIONS = 1 << 12;
+ public static final int IS_VOICE_MESSAGE = 1 << 13;
+}
\ No newline at end of file
diff --git a/src/main/java/club/minnced/discord/webhook/send/WebhookMessage.java b/src/main/java/club/minnced/discord/webhook/send/WebhookMessage.java
index 78ce7c8..033b975 100644
--- a/src/main/java/club/minnced/discord/webhook/send/WebhookMessage.java
+++ b/src/main/java/club/minnced/discord/webhook/send/WebhookMessage.java
@@ -154,6 +154,25 @@ public WebhookMessage asEphemeral(boolean ephemeral) {
return new WebhookMessage(username, avatarUrl, content, embeds, isTTS, attachments, allowedMentions, flags, threadName);
}
+ /**
+ * Returns a new WebhookMessage instance with the silent flag turned on/off (true/false).
+ *
This instance remains unchanged and a new instance is returned.
+ *
+ * @param silent
+ * Whether to make this message silent
+ *
+ * @return New WebhookMessage instance
+ */
+ @NotNull
+ public WebhookMessage asSilent(boolean silent) {
+ int flags = this.flags;
+ if (silent)
+ flags |= MessageFlags.SUPPRESS_NOTIFICATIONS;
+ else
+ flags &= ~MessageFlags.SUPPRESS_NOTIFICATIONS;
+ return new WebhookMessage(username, avatarUrl, content, embeds, isTTS, attachments, allowedMentions, flags, threadName);
+ }
+
/**
* Converts a {@link club.minnced.discord.webhook.receive.ReadonlyMessage} to a
* WebhookMessage.
@@ -176,6 +195,7 @@ public static WebhookMessage from(@NotNull ReadonlyMessage message) {
builder.setContent(message.getContent());
builder.setTTS(message.isTTS());
builder.setEphemeral((message.getFlags() & MessageFlags.EPHEMERAL) != 0);
+ builder.setSilent((message.getFlags() & MessageFlags.SUPPRESS_NOTIFICATIONS) != 0);
builder.addEmbeds(message.getEmbeds());
return builder.build();
}
diff --git a/src/main/java/club/minnced/discord/webhook/send/WebhookMessageBuilder.java b/src/main/java/club/minnced/discord/webhook/send/WebhookMessageBuilder.java
index b3d7cdd..e7d6ef8 100644
--- a/src/main/java/club/minnced/discord/webhook/send/WebhookMessageBuilder.java
+++ b/src/main/java/club/minnced/discord/webhook/send/WebhookMessageBuilder.java
@@ -290,6 +290,23 @@ public WebhookMessageBuilder setEphemeral(boolean ephemeral) {
return this;
}
+ /**
+ * Whether the message should be silent
+ *
+ * @param silent
+ * True if the message should be silent, false otherwise
+ *
+ * @return This builder for chaining convenience
+ */
+ @NotNull
+ public WebhookMessageBuilder setSilent(boolean silent) {
+ if (silent)
+ flags |= MessageFlags.SUPPRESS_NOTIFICATIONS;
+ else
+ flags &= ~MessageFlags.SUPPRESS_NOTIFICATIONS;
+ return this;
+ }
+
/**
* Adds the provided file as an attachment to this message.
*
A single message can have up to {@value WebhookMessage#MAX_FILES} attachments.