From 67a6982b6a61abb7c8858a488792a5856d0b4a18 Mon Sep 17 00:00:00 2001 From: Harry Nim Date: Thu, 26 Sep 2024 00:16:11 +0800 Subject: [PATCH 1/2] Enforce nonce --- index.d.ts | 3 ++- lib/Client.js | 4 +++- lib/structures/DMChannel.js | 1 + lib/structures/GuildTextableChannel.js | 1 + 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 72c76a272..de2918702 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1449,7 +1449,6 @@ declare namespace Eris { tts?: boolean; } interface AdvancedMessageContentEdit { - flags?: number; allowedMentions?: AllowedMentions; attachments?: PartialAttachment[]; components?: ActionRow[]; @@ -1457,7 +1456,9 @@ declare namespace Eris { /** @deprecated */ embed?: EmbedOptions; embeds?: EmbedOptions[]; + enforceNonce?: boolean; file?: FileContent | FileContent[]; + flags?: number; } interface AllowedMentions { everyone?: boolean; diff --git a/lib/Client.js b/lib/Client.js index 9589442d6..3689cc7bc 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -921,6 +921,7 @@ class Client extends EventEmitter { * @arg {String} [content.content] A content string * @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 * @arg {Array} [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 + * @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 * @arg {Object} [content.messageReference] The message reference, used when replying to or forwarding messages * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message. Required when forwarding messages * @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 { content.embeds.push(content.embed); } content.allowed_mentions = this._formatAllowedMentions(content.allowedMentions); + content.enforce_nonce = content.enforceNonce; content.sticker_ids = content.stickerIDs; if (content.messageReference) { content.message_reference = content.messageReference; @@ -1076,7 +1078,7 @@ class Client extends EventEmitter { * @arg {String} options.name The thread channel name * @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (0-21600) (does not affect bots or users with manageMessages/manageChannel permissions) * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {Number} [options.type] The channel type of the thread to create. Either `10` (announcement thread, announcement channels only), `11` (public thread) or `12` (private thread). Note: Not required when creating a thread inside of a forum/media channel, it will always be public + * @arg {Number} [options.type] The channel type of the thread to creatfcreaete. Either `10` (announcement thread, announcement channels only), `11` (public thread) or `12` (private thread). Note: Not required when creating a thread inside of a forum/media channel, it will always be public * @arg {Object | Array} [file] A file object (or an Array of them). Only use when creating a thread inside of a forum/media channel * @arg {Buffer} file.file A buffer containing file data * @arg {String} file.name What to name the file diff --git a/lib/structures/DMChannel.js b/lib/structures/DMChannel.js index c471756a9..1dd78dedf 100644 --- a/lib/structures/DMChannel.js +++ b/lib/structures/DMChannel.js @@ -75,6 +75,7 @@ class DMChannel extends Channel { * @arg {String} [content.content] A content string * @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 * @arg {Array} [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 + * @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 * @arg {Object} [content.messageReference] The message reference, used when replying to or forwarding messages * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message. Required when forwarding messages * @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 diff --git a/lib/structures/GuildTextableChannel.js b/lib/structures/GuildTextableChannel.js index 5778a663d..7473e78d0 100644 --- a/lib/structures/GuildTextableChannel.js +++ b/lib/structures/GuildTextableChannel.js @@ -51,6 +51,7 @@ class GuildTextableChannel extends GuildChannel { * @arg {String} [content.content] A content string * @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 * @arg {Array} [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 + * @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 * @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) * @arg {Object} [content.messageReference] The message reference, used when replying to or forwarding messages * @arg {String} [content.messageReference.channelID] The channel ID of the referenced message. Required when forwarding messages From d98e9b482f841c8d836b4f5bec5ec4b1f3f99202 Mon Sep 17 00:00:00 2001 From: Harry Nim Date: Thu, 26 Sep 2024 00:19:12 +0800 Subject: [PATCH 2/2] No idea what happened here --- lib/Client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Client.js b/lib/Client.js index 3689cc7bc..57c00b955 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1078,7 +1078,7 @@ class Client extends EventEmitter { * @arg {String} options.name The thread channel name * @arg {Number} [options.rateLimitPerUser] The time in seconds a user has to wait before sending another message (0-21600) (does not affect bots or users with manageMessages/manageChannel permissions) * @arg {String} [options.reason] The reason to be displayed in audit logs - * @arg {Number} [options.type] The channel type of the thread to creatfcreaete. Either `10` (announcement thread, announcement channels only), `11` (public thread) or `12` (private thread). Note: Not required when creating a thread inside of a forum/media channel, it will always be public + * @arg {Number} [options.type] The channel type of the thread to create. Either `10` (announcement thread, announcement channels only), `11` (public thread) or `12` (private thread). Note: Not required when creating a thread inside of a forum/media channel, it will always be public * @arg {Object | Array} [file] A file object (or an Array of them). Only use when creating a thread inside of a forum/media channel * @arg {Buffer} file.file A buffer containing file data * @arg {String} file.name What to name the file