Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions apps/docs/pages/docs/_meta.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"typedef": "Type Definitions",
"enums": "Enums"
"classes": "Classes",
"enums": "Enums",
"typedef": "Types"
}
4 changes: 4 additions & 0 deletions apps/docs/pages/docs/classes/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"CommandKit": "CommandKit",
"components": "Components"
}
49 changes: 49 additions & 0 deletions apps/docs/pages/docs/classes/components/ButtonKit.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { Callout } from 'nextra/components';

# ButtonKit

<Callout type="info">
ButtonKit extends the
[ButtonBuilder](https://discord.js.org/docs/packages/discord.js/main/ButtonBuilder:Class) class,
provided by discord.js.
</Callout>

### `onClick`

- Return type: `ButtonKit`
- Arguments:
- handler: [`CommandKitButtonBuilderInteractionCollectorDispatch`](/docs/typedef/CommandKitButtonBuilderInteractionCollectorDispatch)
- data?: [`CommandKitButtonBuilderInteractionCollectorDispatchContextData`](/docs/typedef/CommandKitButtonBuilderInteractionCollectorDispatch) | `undefined`

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

```ts
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);
```

### onEnd

- Return type: `ButtonKit`
- Props type: [`CommandKitButtonBuilderOnEnd`](/docs/typedef/CommandKitButtonBuilderOnEnd)
3 changes: 3 additions & 0 deletions apps/docs/pages/docs/classes/components/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ButtonKit": "ButtonKit"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# CommandKitButtonBuilderInteractionCollectorDispatch

- Type: `(interaction: ButtonInteraction) => Awaitable<void>;`

## References

- [`ButtonInteraction`](https://discord.js.org/docs/packages/discord.js/main/ButtonInteraction:Class)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# CommandKitButtonBuilderInteractionCollectorDispatchContextData

Extends `Omit<InteractionCollectorOptions<ButtonInteraction>, 'filter' | 'componentType'>`

### `message`

The message to listen for button interactions on.

- Type: [Message](https://discord.js.org/docs/packages/discord.js/main/Message:Class)

### `time`

The duration (in ms) that the collector should run for.

- Type: `number` | `undefined`

### `autoReset`

If the collector should automatically reset the timer when a button is clicked.

- Type: `boolean` | `undefined`
3 changes: 3 additions & 0 deletions apps/docs/pages/docs/typedef/CommandKitButtonBuilderOnEnd.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# CommandKitButtonBuilderOnEnd

- Type: `() => Awaitable<void>`
4 changes: 3 additions & 1 deletion apps/docs/pages/docs/typedef/_meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{
"AutocompleteProps": "AutocompleteProps",
"CommandData": "CommandData",
"CommandKit": "CommandKit",
"CommandKitButtonBuilderInteractionCollectorDispatch": "CommandKitButtonBuilderInteractionCollectorDispatch",
"CommandKitButtonBuilderInteractionCollectorDispatchContextData": "CommandKitButtonBuilderInteractionCollectorDispatchContextData",
"CommandKitButtonBuilderOnEnd": "CommandKitButtonBuilderOnEnd",
"CommandObject": "CommandObject",
"CommandOptions": "CommandOptions",
"ContextMenuCommandProps": "ContextMenuCommandProps",
Expand Down