Skip to content

Button

Implementation of discords Button object as a Luau builder.

https://discord.com/developers/docs/interactions/message-components#buttons

Button.style  :: ButtonStyle

The style of the button that determines its appearance and behavior.

Button.label  :: string?

The text that appears on the button.

Button.emoji  :: Emoji?

The emoji that appears on the button.

Button.customId  :: string?

A developer-defined identifier for the button.

Button.skuId  :: string?

The SKU ID for purchase buttons.

Button.url  :: string?

The URL that the button will navigate to when clicked.

Button.disabled  :: boolean?

Whether the button is disabled and cannot be clicked.

Button : setStyle ( buttonStyle )  -> Button

Sets the style of the button. This determines the button’s appearance and behavior.

Parameters

buttonStyle: ButtonStyle

Returns

Button
Button : setLabel ( label )  -> Button

Sets the text that appears on the button. Must be between 1-80 characters.

Parameters

label: string

Returns

Button
Button : setEmoji ( emoji )  -> Button

Sets the emoji that appears on the button.

Parameters

emoji: JSON

Returns

Button
Button : setCustomId ( customId )  -> Button

Sets a developer-defined identifier for the button that will be sent when the button is clicked.

Parameters

customId: string

Returns

Button
Button : setSkuId ( skuId )  -> Button

Sets the SKU ID for the button, used for purchase buttons.

Parameters

skuId: string

Returns

Button
Button : setUrl ( url )  -> Button

Sets the URL that the button will navigate to when clicked.

Parameters

url: string

Returns

Button
Button : setDisabled ( disabled )  -> Button

Sets whether the button is disabled and cannot be clicked.

Parameters

disabled: boolean

Returns

Button
Button : build ( )  -> JSON

Responsible for building the Button JSON that can be parsed by the Discord API.

Returns

JSON
Button . new ( resource )  -> Button

Responsible for creating a new Button.

local button = Button.new({
style = "Primary",
label = "Click me!",
customId = "my_button"
})

Parameters

resource: {
style: apiTypes.ButtonStyle,
label: string?,
emoji: emoji.JSON?,
customId: string?,
skuId: string?,
url: string?,
disabled: boolean?,
}

Returns

Button