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

Slash Commands and Interactions #2295

Merged
merged 37 commits into from
Dec 15, 2020
Merged

Slash Commands and Interactions #2295

merged 37 commits into from
Dec 15, 2020

Conversation

msciotti
Copy link
Contributor

@msciotti msciotti commented Dec 9, 2020

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:

  • Write a better intro
  • Document INTERACTION_CREATE gateway event
  • Document subcommands and groups
  • How does the security check actually work
  • Make sure all the links work
  • Put a resources section since we have a nice node and python library to help with cryptography and some data models
  • Check styling in local dev for 🌟 aesthetics 🌟
  • Make sure the code examples actually work
  • Document limits

@discord discord locked and limited conversation to collaborators Dec 9, 2020
docs/Change_Log.md Outdated Show resolved Hide resolved
@msciotti msciotti changed the title [WIP] Slash Commands and Interactions Slash Commands and Interactions Dec 15, 2020
@msciotti
Copy link
Contributor Author

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.

docs/interactions/Slash_Commands.md Show resolved Hide resolved
docs/interactions/Slash_Commands.md Outdated Show resolved Hide resolved
docs/interactions/Slash_Commands.md Show resolved Hide resolved
docs/interactions/Slash_Commands.md Outdated Show resolved Hide resolved
docs/interactions/Slash_Commands.md Outdated Show resolved Hide resolved
docs/interactions/Slash_Commands.md Show resolved Hide resolved
docs/interactions/Slash_Commands.md Outdated Show resolved Hide resolved
docs/interactions/Slash_Commands.md Outdated Show resolved Hide resolved
docs/interactions/Slash_Commands.md Outdated Show resolved Hide resolved

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
Copy link
Contributor

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 😰)

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

@Snazzah Snazzah left a 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.

docs/interactions/Slash_Commands.md Show resolved Hide resolved
| 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 |
Copy link
Contributor

@Snazzah Snazzah Dec 15, 2020

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.

Copy link
Contributor Author

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).
Copy link
Contributor

@Snazzah Snazzah Dec 15, 2020

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)

Copy link
Contributor Author

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?

Copy link
Contributor

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 |
Copy link
Contributor

@A5rocks A5rocks Dec 15, 2020

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?

Copy link
Contributor Author

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

docs/interactions/Slash_Commands.md Outdated Show resolved Hide resolved

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.
Copy link
Contributor

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.

Copy link
Contributor Author

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

docs/interactions/Slash_Commands.md Show resolved Hide resolved
@@ -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.
Copy link
Contributor

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)
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor Author

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 |

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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 |
Copy link
Contributor

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?

Copy link
Contributor Author

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.

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.

@msciotti
Copy link
Contributor Author

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!

@msciotti msciotti merged commit aa200b5 into master Dec 15, 2020
@msciotti msciotti deleted the feature/interactions branch December 15, 2020 16:47
@WalshyDev
Copy link

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?

@Skye-31
Copy link

Skye-31 commented Dec 15, 2020

broken link?
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.