Skip to content

Instantly share code, notes, and snippets.

@Zomatree
Last active May 19, 2021 19:35
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Zomatree/4aac9733bfa65c86e700ff5c8023787f to your computer and use it in GitHub Desktop.
Save Zomatree/4aac9733bfa65c86e700ff5c8023787f 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

ComponentType

Key ID Description
buttons 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
blurple 1 a blurple coloured button
grey 2 a grey coloured button
green 3 a green coloured button
red 4 a red coloured button
hyperlink 5 a grey hyperlink button, set the link in the url key

PartialEmoji

Key Value
name? string
id? snowflake

InteractionData

extending interaction data payload.

Key Value
custom_id? string
component_type? ComponentType
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment