Skip to main content
Version: 0.1.10

ButtonKit

ButtonKit extends ButtonBuilder

new ButtonKit(data)
ParameterTypeOptional
dataPartial<ButtonComponentData> | Partial<APIButtonComponent>

Properties

public data: any

The API data associated with this component.

Methods

public dispose(): ButtonKit

public onClick(handler, data?): this

Sets up an inline interaction collector for this button. This collector by default allows as many interactions as possible if it is actively used. If unused, this expires after 24 hours or custom time if specified.

const button = new ButtonKit()
.setLabel('Click me')
.setStyle(ButtonStyle.Primary)
.setCustomId('click_me');

const row = new ActionRowBuilder().addComponents(button);

const message = await channel.send({ content: 'Click the button', components: [row] });

button.onClick(async (interaction) => {
await interaction.reply('You clicked me!');
}, { message });

// Remove onClick handler and destroy the interaction collector
button.onClick(null);
ParameterTypeOptionalDescription
handlerCommandKitButtonBuilderInteractionCollectorDispatchThe handler to run when the button is clicked
dataCommandKitButtonBuilderInteractionCollectorDispatchContextDataThe context data to use for the interaction collector

public onEnd(handler): this

ParameterTypeOptional
handlerCommandKitButtonBuilderOnEnd

public setCustomId(customId): this

Sets the custom id for this button.

ParameterTypeOptionalDescription
customIdstringThe custom id to use

public setDisabled(disabled?): this

Sets whether this button is disabled.

ParameterTypeOptionalDescription
disabledbooleanWhether to disable this button

public setEmoji(emoji): this

Sets the emoji to display on this button.

ParameterTypeOptionalDescription
emojiComponentEmojiResolvableThe emoji to use

public setLabel(label): this

Sets the label for this button.

ParameterTypeOptionalDescription
labelstringThe label to use

public setSKUId(skuId): this

Sets the SKU id that represents a purchasable SKU for this button.

ParameterTypeOptionalDescription
skuIdstringThe SKU id to use

public setStyle(style): this

Sets the style of this button.

ParameterTypeOptionalDescription
styleButtonStyleThe style to use

public setURL(url): this

Sets the URL for this button.

ParameterTypeOptionalDescription
urlstringThe URL to use

public toJSON(): APIButtonComponent

ComponentBuilder.toJSON

public static from(other): ButtonBuilder

ParameterTypeOptional
otherAPIButtonComponentJSONEncodable<APIButtonComponent>