-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Slash Commands and Interactions #2295
Conversation
Co-authored-by: Advaith <[email protected]>
This is my final draft now. All the information should be correct, even if some could be better. I'll be merging and deploying this tonight so after that any changes can be PR'd against master. |
|
||
Fetch all of the global commands for your application. Returns an array of [ApplicationCommand](#DOCS_INTERACTIONS_SLASH_COMMANDS/applicationcommand) objects. | ||
|
||
## Create Global Application Command % POST /applications/{application.id#DOCS_TOPICS_OAUTH2/application-object}/commands |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a limit to the payload size for this endpoint? (Hopefully it's large enough, the previous permission example was 1kb minified 😰)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A limit to the payload size for creating commands?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like how there's limits to embeds and whatnot, I guess. I was mostly just asking for the sake of asking, though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those limits are mostly just because our send_message
has a max filesize on it I believe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Docs are missing out on talking about message flags or using the EPHEMERAL
flag.
| tts? | bool | is the response TTS | | ||
| content | string | message content | | ||
| embeds? | array of embeds | supports up to 10 embeds | | ||
| allowed_mentions? | allowed mentions | [allowed mentions](#DOCS_RESOURCES_CHANNEL/allowed-mentions-object) object | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what i've seen, flags
would be here too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've intentionally left flags
off for now because ephemeral messages aren't quite done (UI-wise) on all platforms.
|
||
## Edit Followup Message % PATCH /webhooks/application.id/{interaction.token#DOCS_INTERACTIONS_SLASH_COMMANDS/interaction}/messages/{message.id#DOCS_RESOURCES_CHANNEL/message-object} | ||
|
||
Edits a followup message for an Interaction. Functions the same as [Edit Webhook Message](#DOCS_RESOURCES_WEBHOOK/edit-webhook-message). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this do the same behavior as setting wait
to true
in executing commands?
(meant to put this in creating a follow-up message)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not entirely sure what you mean. Do you mean will it return the message object when creating a followup message?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, that was my question. Meant to say executing webhooks not commands.
| data?\* | ApplicationCommandInteractionData | the command data payload | | ||
| guild_id | snowflake | the guild it was sent from | | ||
| channel_id | snowflake | the channel it was sent from | | ||
| member | GuildMember | guild member data for the invoking user | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this guaranteed to have the User
attached, unlike CREATE_MESSAGE
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the user object is guaranteed
|
||
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. | ||
|
||
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel "swallow" is the more widely used term here, but "eat" is a fun word.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yknow, I knew "eat" wasn't quite it but I knew it was some sort of eating-based word. I'm keeping it now though I've become attached :p
@@ -39,6 +39,13 @@ Many of these libraries are represented in the [unofficial, community-driven Dis | |||
| [Sword](https://github.com/Azoy/Sword) | Swift | | |||
| [Discordeno](https://github.com/Skillz4Killz/Discordeno) | TypeScript | | |||
|
|||
## Interactions | |||
|
|||
[Interactions and Slash Commands](#DOCS_INTERACTIONS_SLASH_COMMANDS/) are the great, new way of making a Discord bot. The following open-source libraries provide help for the security and authentication checks that are mandatory if you are receiving Interactions via outgoing webhook. They also include some types for the Interactions data models. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comma after great
feels weird.
|
||
## Create Followup Message % POST /webhooks/application.id/{interaction.token#DOCS_INTERACTIONS_SLASH_COMMANDS/interaction} | ||
|
||
Create a followup message for an Interaction. Functions the same as [Execute Webhook](#DOCS_RESOURCES_WEBHOOK/execute-webhook) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this use different interaction types (like ChannelMessageWithSource
) or is it completely restricted to the parameters from webhooks? If it is restricted, will we be able to use file
in interaction responses or would it only be here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Followups are only webhook messages, types are only for the initial response
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Advaith is correct that only the original response supports the different types since any followup message is just like sending a normal message.
I don't believe we support file
yet, but we should. Had to make some tradeoffs in the architecture to start but definitely noted :)
| INTEGER | 4 | | ||
| BOOLEAN | 5 | | ||
| USER | 6 | | ||
| CHANNEL | 7 | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is type 7 here any channel, only text channels or voice channels as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any channel - from text channels to channel categories.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any channel within the guild, yes. So no DM channels but everything else including categories, store channels, etc.
@@ -386,6 +387,7 @@ Returns the bot's OAuth2 application info. | |||
| primary_sku_id? | snowflake | if this application is a game sold on Discord, this field will be the id of the "Game SKU" that is created, if exists | | |||
| slug? | string | if this application is a game sold on Discord, this field will be the URL slug that links to the store page | | |||
| cover_image? | string | if this application is a game sold on Discord, this field will be the hash of the image on store embeds | | |||
| flags | int | the application's public flags | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any specific reason why this isn't called public_flags
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that all the flags on an application actually are public, as opposed to users where we specifically differentiate. Calling them the public flags covers my butt for now but I can confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be useful for future-proofing for a future where bots could be boosted.
Thanks everyone for your help in getting this PR into a good state! As always if we find more things that need clarifying or changing, PRs or pings are always welcome. There's also two new issue templates here for slash command bugs and feature requests, so we'll keep an eye on those! |
Mason, could you tell us what the rollout plans are for this feature? Now this is merged and we have feature/bug templates, are we going to see the rollout starting today? |
Opening the PR now because the "meat" of the docs are done. Just a quick note:
Comments on this PR should be solely about the documentation. When this launches, we will have specific repo templates for feedback on the feature itself. I will pretty aggressively prune the convo here to be documentation-only so that we can get this out
This documentation page is a bit of a monolith, and should probably be split up into smaller sections. The same can be said of most of our documentation, to be honest. I'm prioritizing having the documentation ready over having it look pretty, and we can revisit later.
TODO:
INTERACTION_CREATE
gateway event