Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to interaction responses and flags #2615

Merged
merged 6 commits into from
Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/Change_Log.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Change Log

## Changes to Slash Command Response Types and Flags

## February XX, 2021

Changes to interaction response types have been made to support better designs for Slash Commands:

- Type `2` `Acknowledge` has been deprecated
- Type `3` `ChannelMessage` has been deprecated
- Type `5` `AcknowledgeWithSource` has been renamed to `DeferredChannelMessageWithSource`
msciotti marked this conversation as resolved.
Show resolved Hide resolved

Additionally, `flags` has been documented on [InteractionApplicationCommandCallbackData](#DOCS_INTERACTIONS_SLASH_COMMANDS/InteractionApplicationCommandCallbackData). Setting `flags` to `64` will make the interaction response ephemeral.

## Slash Commands in DMs

#### February 9, 2021
Expand Down
18 changes: 12 additions & 6 deletions docs/interactions/Slash_Commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -842,24 +842,29 @@ All options have names, and an option can either be a parameter and input value-

## Interaction Response

After receiving an interaction, you must respond to acknowledge it. This may be a `pong` for a `ping`, a message, or simply an acknowledgement that you have received it and will handle the command async.
After receiving an interaction, you must respond to acknowledge it. You can choose to respond with a message immediately using type `4`, or you can choose to send a deferred response with type `5`. If choosing a deferred response, the user will see a loading state for the interaction, and you'll have up to 15 minutes to edit the original deferred response using [Edit Original Interaction Response](#DOCS_INTERACTIONS_SLASH_COMMANDS/edit-original-interaction-response).
msciotti marked this conversation as resolved.
Show resolved Hide resolved

Interaction responses may choose to "eat" the user's command input if you do not wish to have their slash command show up as message in chat. This may be helpful for slash commands, or commands whose responses are asynchronous or ephemeral messages.
![A deferred response tells the user "Bot name is thinking"](ephemeral-example.png)
msciotti marked this conversation as resolved.
Show resolved Hide resolved

Interaction responses can also be public—everyone can see it—or "ephemeral"—only the invoking user can see it. That is determined by setting `flags` to `64` on the [InteractionApplicationCommandCallbackData](#DOCS_INTERACTIONS_SLASH_COMMANDS/InteractionApplicationCommandCallbackData).

| Field | Type | Description |
|-------|-------------------------------------------|------------------------------|
| type | InteractionResponseType | the type of response |
| data? | InteractionApplicationCommandCallbackData | an optional response message |

> warn
> Interaction response types `2` and `3` have been deprecated

###### InteractionResponseType

| Name | Value | Description |
|--------------------------|-------|-------------------------------------------------------------------|
| Pong | 1 | ACK a `Ping` |
| Acknowledge | 2 | ACK a command without sending a message, eating the user's input |
| ChannelMessage | 3 | respond with a message, eating the user's input |
| ChannelMessageWithSource | 4 | respond with a message, showing the user's input |
| AcknowledgeWithSource | 5 | ACK a command without sending a message, showing the user's input |
| Acknowledge | 2 | **DEPRECATED** ACK a command without sending a message, eating the user's input |
| ChannelMessage | 3 | **DEPRECATED** respond with a message, eating the user's input |
| ChannelMessageWithSource | 4 | respond to an interaction with a message |
| DeferredChannelMessageWithSource | 5 | ACK an interaction and send a response later, the user sees a loading state |
msciotti marked this conversation as resolved.
Show resolved Hide resolved
msciotti marked this conversation as resolved.
Show resolved Hide resolved

###### InteractionApplicationCommandCallbackData

Expand All @@ -871,3 +876,4 @@ Not all message fields are currently supported.
| content | string | message content |
| embeds? | array of [embeds](#DOCS_RESOURCES_CHANNEL/embed-object) | supports up to 10 embeds |
| allowed_mentions? | allowed mentions | [allowed mentions](#DOCS_RESOURCES_CHANNEL/allowed-mentions-object) object |
| flags | int | set to `64` to make your response ephemeral |
msciotti marked this conversation as resolved.
Show resolved Hide resolved
msciotti marked this conversation as resolved.
Show resolved Hide resolved

Choose a reason for hiding this comment

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

Is there anything else that can be done with flags?

Copy link
Contributor

Choose a reason for hiding this comment

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

you can see the other message flags in the docs but they are all only set by Discord aside from SUPPRESS_EMBEDS which can currently only be set while editing

Binary file added images/deferred-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.