Skip to content

Commit

Permalink
Merge pull request #269 from Phoenix-Starlight/feature/enforce-msg-nonce
Browse files Browse the repository at this point in the history
feat(MessageCreateAction): add `enforceNonce` parameter
  • Loading branch information
seailz authored Feb 24, 2024
2 parents cc4b8ff + da908b3 commit af0b9a8
Showing 1 changed file with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class MessageCreateAction {

private String text;
private String nonce;
private boolean enforceNonce;
private boolean tts;
private List<Embeder> embeds;
private MessageReference messageReference;
Expand Down Expand Up @@ -78,9 +79,10 @@ public MessageCreateAction(LinkedList<Attachment> attachments, @NotNull String c
this.stickerIds = new ArrayList<>();
}

public MessageCreateAction(@Nullable String text, @Nullable String nonce, boolean tts, @Nullable MessageReference messageReference, @Nullable List<DisplayComponent> components, @Nullable List<String> stickerIds, @Nullable List<Attachment> attachments, boolean supressEmbeds, @NotNull String channelId, @NotNull DiscordJar discordJar) {
public MessageCreateAction(@Nullable String text, @Nullable String nonce, boolean enforceNonce, boolean tts, @Nullable MessageReference messageReference, @Nullable List<DisplayComponent> components, @Nullable List<String> stickerIds, @Nullable List<Attachment> attachments, boolean supressEmbeds, @NotNull String channelId, @NotNull DiscordJar discordJar) {
this.text = text;
this.nonce = nonce;
this.enforceNonce = enforceNonce;
this.tts = tts;
this.messageReference = messageReference;
this.components = components;
Expand All @@ -99,6 +101,10 @@ public String nonce() {
return nonce;
}

public boolean enforceNonce() {
return enforceNonce;
}

public boolean tts() {
return tts;
}
Expand Down Expand Up @@ -158,6 +164,11 @@ public MessageCreateAction setNonce(@Nullable String nonce) {
return this;
}

public MessageCreateAction setEnforceNonce(boolean enforceNonce) {
this.enforceNonce = enforceNonce;
return this;
}

public MessageCreateAction setTts(boolean tts) {
this.tts = tts;
return this;
Expand Down Expand Up @@ -270,6 +281,7 @@ public Response<Message> run() {
JSONObject payload = new JSONObject();
if (this.text != null) payload.put("content", this.text);
if (this.nonce != null) payload.put("nonce", this.nonce);
if (this.enforceNonce) payload.put("enforce_nonce", true);
if (this.tts) payload.put("tts", true);
if (this.messageReference != null) payload.put("message_reference", this.messageReference.compile());
if (this.waveform != null) {
Expand Down

0 comments on commit af0b9a8

Please sign in to comment.