Skip to content

Commit

Permalink
[message_create] Document new enforce_nonce param (#6647)
Browse files Browse the repository at this point in the history
Recently I added a new enforce_nonce on POST channel/messages parameter that will allow bots to opt in to having their messages deduped on the nonce parameter in a short duration.
  • Loading branch information
ypisetsky authored Feb 12, 2024
1 parent 4efb710 commit d8effe1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
6 changes: 6 additions & 0 deletions docs/Change_Log.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## Enforced Nonces on Create Message Endpoint

#### February 12, 2024

The [Create message](#DOCS_RESOURCES_CHANNEL/create-message) endpoint now supports an `enforce_nonce` parameter. When set to true, the message will be deduped for the same sender within a few minutes. If a message was created with the same nonce, no new message will be created and the previous message will be returned instead. This behavior will become the default for this endpoint in a future API version.

## Limit Number of Fields in Embeds

#### December 19, 2023
Expand Down
29 changes: 15 additions & 14 deletions docs/resources/Channel.md
Original file line number Diff line number Diff line change
Expand Up @@ -1053,20 +1053,21 @@ Files must be attached using a `multipart/form-data` body as described in [Uploa
> info
> When creating a message, apps must provide a value for **at least one of** `content`, `embeds`, `sticker_ids`, `components`, or `files[n]`.
| Field | Type | Description |
|--------------------|---------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| content?\* | string | Message contents (up to 2000 characters) |
| nonce? | integer or string | Can be used to verify a message was sent (up to 25 characters). Value will appear in the [Message Create event](#DOCS_TOPICS_GATEWAY_EVENTS/message-create). |
| tts? | boolean | `true` if this is a TTS message |
| embeds?\* | array of [embed](#DOCS_RESOURCES_CHANNEL/embed-object) objects | Up to 10 `rich` embeds (up to 6000 characters) |
| allowed_mentions? | [allowed mention object](#DOCS_RESOURCES_CHANNEL/allowed-mentions-object) | Allowed mentions for the message |
| message_reference? | [message reference](#DOCS_RESOURCES_CHANNEL/message-reference-object-message-reference-structure) | Include to make your message a reply |
| components?\* | array of [message component](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/component-object) objects | Components to include with the message |
| sticker_ids?\* | array of snowflakes | IDs of up to 3 [stickers](#DOCS_RESOURCES_STICKER/sticker-object) in the server to send in the message |
| files[n]?\* | file contents | Contents of the file being sent. See [Uploading Files](#DOCS_REFERENCE/uploading-files) |
| payload_json? | string | JSON-encoded body of non-file params, only for `multipart/form-data` requests. See [Uploading Files](#DOCS_REFERENCE/uploading-files) |
| attachments? | array of partial [attachment](#DOCS_RESOURCES_CHANNEL/attachment-object) objects | Attachment objects with filename and description. See [Uploading Files](#DOCS_REFERENCE/uploading-files) |
| flags? | integer | [Message flags](#DOCS_RESOURCES_CHANNEL/message-object-message-flags) combined as a [bitfield](https://en.wikipedia.org/wiki/Bit_field) (only `SUPPRESS_EMBEDS` and `SUPPRESS_NOTIFICATIONS` can be set) |
| Field | Type | Description |
|--------------------|---------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| content?\* | string | Message contents (up to 2000 characters) |
| nonce? | integer or string | Can be used to verify a message was sent (up to 25 characters). Value will appear in the [Message Create event](#DOCS_TOPICS_GATEWAY_EVENTS/message-create). |
| tts? | boolean | `true` if this is a TTS message |
| embeds?\* | array of [embed](#DOCS_RESOURCES_CHANNEL/embed-object) objects | Up to 10 `rich` embeds (up to 6000 characters) |
| allowed_mentions? | [allowed mention object](#DOCS_RESOURCES_CHANNEL/allowed-mentions-object) | Allowed mentions for the message |
| message_reference? | [message reference](#DOCS_RESOURCES_CHANNEL/message-reference-object-message-reference-structure) | Include to make your message a reply |
| components?\* | array of [message component](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/component-object) objects | Components to include with the message |
| sticker_ids?\* | array of snowflakes | IDs of up to 3 [stickers](#DOCS_RESOURCES_STICKER/sticker-object) in the server to send in the message |
| files[n]?\* | file contents | Contents of the file being sent. See [Uploading Files](#DOCS_REFERENCE/uploading-files) |
| payload_json? | string | JSON-encoded body of non-file params, only for `multipart/form-data` requests. See [Uploading Files](#DOCS_REFERENCE/uploading-files) |
| attachments? | array of partial [attachment](#DOCS_RESOURCES_CHANNEL/attachment-object) objects | Attachment objects with filename and description. See [Uploading Files](#DOCS_REFERENCE/uploading-files |
| flags? | integer | [Message flags](#DOCS_RESOURCES_CHANNEL/message-object-message-flags) combined as a [bitfield](https://en.wikipedia.org/wiki/Bit_field) (only `SUPPRESS_EMBEDS` and `SUPPRESS_NOTIFICATIONS` can be set) |
| enforce_nonce? | boolean | If true and nonce is present, it will be checked for uniqueness in the past few minutes. If another message was created by the same author with the same nonce, that message will be returned and no new message will be created. |

\* At least one of `content`, `embeds`, `sticker_ids`, `components`, or `files[n]` is required.

Expand Down

1 comment on commit d8effe1

@amaristarks
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi

Please sign in to comment.