Skip to main content

You are looking at documentation for CommandKit version 0.1.10 which is no longer actively maintained. We highly recommend you to upgrade to CommandKit v1.

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
handlerCommandKitButtonBuilderInteractionCollectorDispatch❌The handler to run when the button is clicked
dataCommandKitButtonBuilderInteractionCollectorDispatchContextData✅The 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
customIdstring❌The custom id to use

public setDisabled(disabled?): this​

Sets whether this button is disabled.

ParameterTypeOptionalDescription
disabledboolean✅Whether to disable this button

public setEmoji(emoji): this​

Sets the emoji to display on this button.

ParameterTypeOptionalDescription
emojiComponentEmojiResolvable❌The emoji to use

public setLabel(label): this​

Sets the label for this button.

ParameterTypeOptionalDescription
labelstring❌The label to use

public setSKUId(skuId): this​

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

ParameterTypeOptionalDescription
skuIdstring❌The SKU id to use

public setStyle(style): this​

Sets the style of this button.

ParameterTypeOptionalDescription
styleButtonStyle❌The style to use

public setURL(url): this​

Sets the URL for this button.

ParameterTypeOptionalDescription
urlstring❌The URL to use

public toJSON(): APIButtonComponent​

ComponentBuilder.toJSON

public static from(other): ButtonBuilder​

ParameterTypeOptional
otherAPIButtonComponentJSONEncodable<APIButtonComponent>