Skip to content

MessageButton

classe · Source

Represents a button message component.

Extends: BaseMessageComponent

Constructor

new MessageButton(data?: MessageButton | MessageButtonOptions)

Parameters

NameTypeDescription
data?MessageButton | MessageButtonOptionsMessageButton to clone or raw data Default: {}.

Properties

label

nullable

label: string

The text to be displayed on this button Source

customId

nullable

customId: string

A unique string to be sent in the interaction when clicked Source

style

nullable

style: MessageButtonStyle

The style of this button Source

emoji

nullable

emoji: RawEmoji

Emoji for this button Source

url

nullable

url: string

The URL this button links to, if it is a Link style button Source

disabled

disabled: boolean

Whether this button is currently disabled Source

type

nullable

type: MessageComponentType

The type of this component Source

data

data: MessageComponentOptions

The data for this component Source

id

readonly

id: number

The id of this component Source

Methods

setCustomId

setCustomId(customId: string): MessageButton

Sets the custom id for this button Parameters

NameTypeDescription
customIdstringA unique string to be sent in the interaction when clicked

Returns: MessageButtonSource

setDisabled

setDisabled(disabled?: boolean): MessageButton

Sets the interactive status of the button Parameters

NameTypeDescription
disabled?booleanWhether this button should be disabled Default: true.

Returns: MessageButtonSource

setEmoji

setEmoji(emoji: EmojiIdentifierResolvable): MessageButton

Set the emoji of this button Parameters

NameTypeDescription
emojiEmojiIdentifierResolvableThe emoji to be displayed on this button

Returns: MessageButtonSource

setLabel

setLabel(label: string): MessageButton

Sets the label of this button Parameters

NameTypeDescription
labelstringThe text to be displayed on this button

Returns: MessageButtonSource

setStyle

setStyle(style: MessageButtonStyleResolvable): MessageButton

Sets the style of this button Parameters

NameTypeDescription
styleMessageButtonStyleResolvableThe style of this button

Returns: MessageButtonSource

setURL

setURL(url: string): MessageButton

Sets the URL of this button. MessageButton#style must be LINK when setting a URL Parameters

NameTypeDescription
urlstringThe URL of this button

Returns: MessageButtonSource

toJSON

toJSON(): APIMessageButton

Transforms the button to a plain object. Returns: APIMessageButton — The raw data of this button Source

resolveStyle

static · private

resolveStyle(style: MessageButtonStyleResolvable): MessageButtonStyle

Resolves the style of a button Parameters

NameTypeDescription
styleMessageButtonStyleResolvableThe style to resolve

Returns: MessageButtonStyleSource

Unofficial software. Not affiliated with or supported by Discord.