Skip to content

Commit d4143a6

Browse files
authored
feat(Message): Message create nonce enforcement (#1553)
1 parent 877ba86 commit d4143a6

File tree

4 files changed

+6
-1
lines changed

4 files changed

+6
-1
lines changed

index.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,15 +1449,16 @@ declare namespace Eris {
14491449
tts?: boolean;
14501450
}
14511451
interface AdvancedMessageContentEdit {
1452-
flags?: number;
14531452
allowedMentions?: AllowedMentions;
14541453
attachments?: PartialAttachment[];
14551454
components?: ActionRow[];
14561455
content?: string;
14571456
/** @deprecated */
14581457
embed?: EmbedOptions;
14591458
embeds?: EmbedOptions[];
1459+
enforceNonce?: boolean;
14601460
file?: FileContent | FileContent[];
1461+
flags?: number;
14611462
}
14621463
interface AllowedMentions {
14631464
everyone?: boolean;

lib/Client.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -921,6 +921,7 @@ class Client extends EventEmitter {
921921
* @arg {String} [content.content] A content string
922922
* @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
923923
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
924+
* @arg {Boolean} [content.enforceNonce] If true and `content.nonce` is present, if multiple messages are sent with the same nonce within a few minutes of each other, that message will be returned and no new message created
924925
* @arg {Object} [content.messageReference] The message reference, used when replying to or forwarding messages
925926
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message. Required when forwarding messages
926927
* @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message
@@ -952,6 +953,7 @@ class Client extends EventEmitter {
952953
content.embeds.push(content.embed);
953954
}
954955
content.allowed_mentions = this._formatAllowedMentions(content.allowedMentions);
956+
content.enforce_nonce = content.enforceNonce;
955957
content.sticker_ids = content.stickerIDs;
956958
if (content.messageReference) {
957959
content.message_reference = content.messageReference;

lib/structures/DMChannel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class DMChannel extends Channel {
7575
* @arg {String} [content.content] A content string
7676
* @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
7777
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
78+
* @arg {Boolean} [content.enforceNonce] If true and `content.nonce` is present, if multiple messages are sent with the same nonce within a few minutes of each other, that message will be returned and no new message created
7879
* @arg {Object} [content.messageReference] The message reference, used when replying to or forwarding messages
7980
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message. Required when forwarding messages
8081
* @arg {Boolean} [content.messageReference.failIfNotExists=true] Whether to throw an error if the message reference doesn't exist. If false, and the referenced message doesn't exist, the message is created without a referenced message

lib/structures/GuildTextableChannel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class GuildTextableChannel extends GuildChannel {
5151
* @arg {String} [content.content] A content string
5252
* @arg {Object} [content.embed] [DEPRECATED] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
5353
* @arg {Array<Object>} [content.embeds] An array of embed objects. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
54+
* @arg {Boolean} [content.enforceNonce] If true and `content.nonce` is present, if multiple messages are sent with the same nonce within a few minutes of each other, that message will be returned and no new message created
5455
* @arg {Number} [content.flags] A number representing the [flags](https://discord.dev/resources/channel#message-object-message-flags) to apply to the message (only SUPPRESS_EMBEDS and SUPPRESS_NOTIFICATIONS)
5556
* @arg {Object} [content.messageReference] The message reference, used when replying to or forwarding messages
5657
* @arg {String} [content.messageReference.channelID] The channel ID of the referenced message. Required when forwarding messages

0 commit comments

Comments
 (0)