Skip to content

Instantly share code, notes, and snippets.

@Rapptz
Forked from Zomatree/docs.md
Last active October 28, 2022 14:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rapptz/2d011fc3051a3456cb64008f23b79758 to your computer and use it in GitHub Desktop.
Save Rapptz/2d011fc3051a3456cb64008f23b79758 to your computer and use it in GitHub Desktop.

Overview

messages can be sent with the components key to add buttons and other components (when discord brings them out), you can edit and add new buttons via editing the message, this is useful for the disabled key to stop people from clicking it.

Example Payload

{
    "content": "this is an example message for components",
    "components": [
        {"type": 1, "components": [
            {"type": 2, "style": 2, "label": "Button 1", "custom_id": "1"},
            {"type": 2, "style": 2, "label": "Button 2", "custom_id": "2"}
        ]}
    ]
}

Message

extending message payload.

Key Value
components? list of Component

Component

Key Value Description
type ComponentType the type of component
style? ComponentStyle the style of button
custom_id? string the internal id of the button, set this yourself, mutually exclusive with url
label? string the text on the button
url? string used to set the url for hyperlinks
emoji? PartialEmoji used for an emoji in the button text
disabled? boolean used to enabled and disable the button - defaults to false
components? list of Component children components

Component Limits

Key Limit (number of characters)
custom_id 100
label 80
url 500

ComponentType

Key ID Description
action_row 1 used as the parent of buttons, takes a list of components with the components key with the type of 2
button 2 an actual button

ComponentStyle

Key ID Description
primary 1 a blurple coloured button
secondary 2 a grey coloured button
success 3 a green coloured button
danger 4 a red coloured button
link 5 a grey hyperlink button, set the link in the url key

If a url is given to a button, they must have a style set to 5. You can't have custom_id and url. url based buttons do not dispatch INTERACTION_CREATE.

PartialEmoji

Key Value
name? string
id? snowflake

InteractionData

extending interaction data payload.

Key Value
custom_id? string
component_type? ComponentType

InteractionResponseType

Key ID Description
DeferredMessageUpdate 6 Signals that a message update will appear later (not required, basically an ACK). No body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment