ButtonKit
ButtonKit extends the
ButtonBuilder
(opens in a new tab)
class, provided by discord.js.
onClick
- Return type:
ButtonKit
- Arguments:
- handler:
CommandKitButtonBuilderInteractionCollectorDispatch
- data?:
CommandKitButtonBuilderInteractionCollectorDispatchContextData
|undefined
- handler:
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.
Example
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.dispose();
onEnd
- Return type:
ButtonKit
- Props type:
CommandKitButtonBuilderOnEnd
dispose
- Return type:
void