Skip to content

Commit

Permalink
feat: add automatic docgen
Browse files Browse the repository at this point in the history
  • Loading branch information
twlite committed Dec 14, 2024
1 parent c462cc3 commit fe9b9d8
Show file tree
Hide file tree
Showing 47 changed files with 1,093 additions and 281 deletions.
2 changes: 1 addition & 1 deletion apps/docs/app/(home)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function HomePage() {
Guide
</Link>
<Link
href="/docs/typedef/AutocompleteProps"
href="/docs"
className="font-semibold bg-blue-500 py-2 px-4 rounded-full"
>
Docs
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/app/layout.config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const baseOptions: BaseLayoutProps = {
},
{
text: 'Documentation',
url: '/docs/typedef/AutocompleteProps',
url: '/docs',
active: 'nested-url',
},
{
Expand Down
136 changes: 136 additions & 0 deletions apps/docs/content/docs/classes/ButtonKit.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
---
title: ButtonKit
description: No description provided
---

## ButtonKit extends ButtonBuilder

```typescript
ButtonKit(data);
```

| Parameter | Type | Optional |
| --------- | ------------------------------------------------------------- | -------- |
| data | Partial\<ButtonComponentData> \| Partial\<APIButtonComponent> ||

## Properties

### public data: any

The API data associated with this component.

## Methods

### public dispose(): ButtonKit

- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/components/ButtonKit.ts#L165)

### 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.

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

| Parameter | Type | Optional | Description |
| --------- | -------------------------------------------------------------- | -------- | ----------------------------------------------------- |
| handler | CommandKitButtonBuilderInteractionCollectorDispatch || The handler to run when the button is clicked |
| data | CommandKitButtonBuilderInteractionCollectorDispatchContextData || The context data to use for the interaction collector |

- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/components/ButtonKit.ts#L74)

### public onEnd(handler): this

| Parameter | Type | Optional |
| --------- | ---------------------------- | -------- |
| handler | CommandKitButtonBuilderOnEnd ||

- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/components/ButtonKit.ts#L98)

### public setCustomId(customId): this

Sets the custom id for this button.

| Parameter | Type | Optional | Description |
| --------- | ------------------------------------------------------------------------------------------------- | -------- | -------------------- |
| customId | [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) || The custom id to use |

### public setDisabled(disabled?): this

Sets whether this button is disabled.

| Parameter | Type | Optional | Description |
| --------- | --------------------------------------------------------------------------------------------------- | -------- | ------------------------------ |
| disabled | [boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean) || Whether to disable this button |

### public setEmoji(emoji): this

Sets the emoji to display on this button.

| Parameter | Type | Optional | Description |
| --------- | ------------------------ | -------- | ---------------- |
| emoji | ComponentEmojiResolvable || The emoji to use |

### public setLabel(label): this

Sets the label for this button.

| Parameter | Type | Optional | Description |
| --------- | ------------------------------------------------------------------------------------------------- | -------- | ---------------- |
| label | [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) || The label to use |

### public setSKUId(skuId): this

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

| Parameter | Type | Optional | Description |
| --------- | ------------------------------------------------------------------------------------------------- | -------- | ----------------- |
| skuId | [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) || The SKU id to use |

### public setStyle(style): this

Sets the style of this button.

| Parameter | Type | Optional | Description |
| --------- | ----------- | -------- | ---------------- |
| style | ButtonStyle || The style to use |

### public setURL(url): this

Sets the URL for this button.

| Parameter | Type | Optional | Description |
| --------- | ------------------------------------------------------------------------------------------------- | -------- | -------------- |
| url | [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) || The URL to use |

### public toJSON(): APIButtonComponent

ComponentBuilder.toJSON

### public static from(other): ButtonBuilder

| Parameter | Type | Optional |
| --------- | ------------------ | ---------------------------------- | --- |
| other | APIButtonComponent | JSONEncodable\<APIButtonComponent> ||
83 changes: 50 additions & 33 deletions apps/docs/content/docs/classes/CommandKit.mdx
Original file line number Diff line number Diff line change
@@ -1,67 +1,84 @@
---
title: CommandKit
description: CommandKit is a command handler for Discord.js that makes it easy to create and manage commands, events, and validations.
description: No description provided
---

# CommandKit
## CommandKit

### `commands`
```typescript
CommandKit(options);
```

- Type: [`CommandObject[]`](/docs/typedef/CommandObject)
| Parameter | Type | Optional | Description |
| --------- | ----------------- | -------- | ------------------------------------- |
| options | CommandKitOptions || The default CommandKit configuration. |

An array of all the command objects that CommandKit is handling. This includes all the properties and methods that are also set outside of CommandKit's configuration. It does however not include the `run` method since CommandKit handles that internally.
## Properties

### `commandsPath`
### public static \_instance: any

- Type: `string` | `undefined`
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L8)

The path to the commands directory which was set when [instantiating CommandKit](/guide/commandkit-setup).
### public client: any

### `eventsPath`
Get the client attached to this CommandKit instance.

- Type: `string` | `undefined`
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L38)

The path to the events directory which was set when [instantiating CommandKit](/guide/commandkit-setup).
### public commandHandler: any

### `validationsPath`
Get command handler instance.

- Type: `string` | `undefined`
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L45)

The path to the validations directory which was set when [instantiating CommandKit](/guide/commandkit-setup).
### public commands: any

### `devUserIds`
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L125)

- Type: `string[]`
### public commandsPath: any

The array of developer user IDs which was set when [instantiating CommandKit](/guide/commandkit-setup).
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L141)

### `devGuildIds`
### public devGuildIds: any

- Type: `string[]`
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L169)

The array of development server IDs which was set when [instantiating CommandKit](/guide/commandkit-setup).
### public devRoleIds: any

### `devRoleIds`
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L176)

- Type: `string[]`
### public devUserIds: any

The array of developer role IDs which was set when [instantiating CommandKit](/guide/commandkit-setup).
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L162)

### `reloadCommands`
### public eventsPath: any

- Props type: `'dev'` | `'global'` | [`ReloadType`](/docs/enums/ReloadType) (optional)
- Return type: `Promise<void>`
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L148)

Reloads application commands. Using "dev" will only reload commands marked with `devOnly`, and using "global" will do the opposite. Not passing in a property will reload both dev and global commands. The reload behaviour depends on [`bulkRegister`](/guide/commandkit-setup#bulkregister-optional).
### public validationsPath: any

### `reloadEvents`
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L155)

- Return type: `Promise<void>`
## Methods

Resets and reloads application events.
### public reloadCommands(type?): [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[void](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)>

### `reloadValidations`
Updates application commands with the latest from "commandsPath".

- Return type: `Promise<void>`
| Parameter | Type | Optional |
| --------- | ------------- | -------- |
| type | ReloadOptions ||

Reloads application commands validations.
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L101)

### public reloadEvents(): [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[void](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)>

Updates application events with the latest from "eventsPath".

- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L109)

### public reloadValidations(): [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\<[void](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined)>

Updates application command validations with the latest from "validationsPath".

- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/CommandKit.ts#L117)
56 changes: 0 additions & 56 deletions apps/docs/content/docs/classes/components/ButtonKit.mdx

This file was deleted.

10 changes: 10 additions & 0 deletions apps/docs/content/docs/classes/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: Classes
description: Classes provided by CommandKit
---

# Classes

<Cards><Card title="ButtonKit" description="No description available." href="/docs/classes/ButtonKit" />

<Card title="CommandKit" description="No description available." href="/docs/classes/CommandKit" /></Cards>
15 changes: 7 additions & 8 deletions apps/docs/content/docs/enums/ReloadType.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
---
title: ReloadType
description: The type of reload to perform when reloading commands or events.
description: No description provided
---

# ReloadType
## ReloadType

### Developer
| Property | Type | Value | Description |
| --------- | -------- | ----- | -------------------------------- |
| Developer | 'dev' | N/A | Reload developer/guild commands. |
| Global | 'global' | N/A | Reload global commands. |

- Value: `dev`

### Global

- Value: `global`
- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/types.ts#L284)
14 changes: 14 additions & 0 deletions apps/docs/content/docs/enums/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Enums
description: Enums provided by CommandKit
---

# Enums

<Cards>
<Card
title="ReloadType"
description="No description available."
href="/docs/enums/ReloadType"
/>
</Cards>
12 changes: 12 additions & 0 deletions apps/docs/content/docs/functions/defineConfig.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
title: defineConfig
description: No description provided
---

### defineConfig(config): Partial\<[CommandKitConfig](/docs/types/CommandKitConfig.mdx)>

| Parameter | Type | Optional |
| --------- | -------------------------------------------------------------------- | -------- |
| config | PartialConfig\<[CommandKitConfig](/docs/types/CommandKitConfig.mdx)> ||

- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/config.ts#L71)
8 changes: 8 additions & 0 deletions apps/docs/content/docs/functions/getConfig.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
title: getConfig
description: No description provided
---

### getConfig(): [CommandKitConfig](/docs/types/CommandKitConfig.mdx)

- [Source](https://github.com/underctrl-io/commandkit/blob/c462cc3d6f765a7ee19e33a651f0f2f4666b111b/packages/commandkit/src/config.ts#L60)
Loading

0 comments on commit fe9b9d8

Please sign in to comment.