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
2 changes: 1 addition & 1 deletion apps/test-bot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"node": "node"
},
"dependencies": {
"@ai-sdk/google": "^1.2.19",
"@ai-sdk/google": "^2.0.8",
"@commandkit/ai": "workspace:*",
"@commandkit/cache": "workspace:*",
"@commandkit/devtools": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: Setup CommandKit
description:
Setup a new CommandKit project using the create-commandkit CLI
description: Setup a new CommandKit project using the create-commandkit CLI
---

:::info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ const pets = Array.from({ length: 20 }, (_, i) => ({
value: `petId_${i}`,
}));

export const autocomplete: AutocompleteCommand = async ({
interaction,
}) => {
export const autocomplete: AutocompleteCommand = async ({ interaction }) => {
try {
// Get the input value of your autocomplete option
const input = interaction.options.getString('name', false);
Expand All @@ -69,9 +67,7 @@ export const autocomplete: AutocompleteCommand = async ({
}
};

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const chosenPetId = interaction.options.getString('name', true);
const chosenPet = pets.find((pet) => pet.value === chosenPetId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ understanding the nature of these context menu commands easier.
## Message context menu command

```ts title="src/app/commands/report-message.ts"
import type {
CommandData,
MessageContextMenuCommand,
} from 'commandkit';
import type { CommandData, MessageContextMenuCommand } from 'commandkit';
import { MessageFlags } from 'discord.js';

export const command: CommandData = {
Expand Down
6 changes: 1 addition & 5 deletions apps/website/docs/guide/02-commands/05-after-function.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ cleanup tasks.
## Usage

```ts title="src/app/commands/ping.ts"
import {
type CommandData,
type ChatInputCommand,
after,
} from 'commandkit';
import { type CommandData, type ChatInputCommand, after } from 'commandkit';

export const command: CommandData = {};

Expand Down
8 changes: 2 additions & 6 deletions apps/website/docs/guide/02-commands/07-middlewares.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ import { MiddlewareContext } from 'commandkit';

export function beforeExecute(ctx: MiddlewareContext) {
// This function will be executed before the command is executed
console.log(
`User ${ctx.interaction.user.id} is about to execute a command`,
);
console.log(`User ${ctx.interaction.user.id} is about to execute a command`);
}

export function afterExecute(ctx: MiddlewareContext) {
Expand Down Expand Up @@ -68,9 +66,7 @@ import type { MiddlewareContext } from 'commandkit';
export function beforeExecute(ctx: MiddlewareContext) {
// This middleware will run before any moderation command
if (!ctx.interaction.member.permissions.has('KickMembers')) {
throw new Error(
'You need moderation permissions to use this command',
);
throw new Error('You need moderation permissions to use this command');
}
}
```
Expand Down
13 changes: 3 additions & 10 deletions apps/website/docs/guide/03-events/01-discordjs-events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,7 @@ Some Discord.js events have multiple parameters, such as the
```ts title="src/app/events/messageUpdate/log-message-update.ts"
import type { EventHandler } from 'commandkit';

const handler: EventHandler<'messageUpdate'> = (
oldMessage,
newMessage,
) => {
const handler: EventHandler<'messageUpdate'> = (oldMessage, newMessage) => {
console.log(
`Message from ${oldMessage.author?.username} updated: ${oldMessage.content} -> ${newMessage.content}`,
);
Expand All @@ -135,9 +132,7 @@ const handler: EventHandler<'messageCreate'> = (
client,
commandkit,
) => {
console.log(
`Message from ${message.author.username}: ${message.content}`,
);
console.log(`Message from ${message.author.username}: ${message.content}`);
};

export default handler;
Expand Down Expand Up @@ -171,9 +166,7 @@ export default handler;
import type { EventHandler } from 'commandkit';

const handler: EventHandler<'messageCreate'> = (message) => {
console.log(
`Message from ${message.author.username}: ${message.content}`,
);
console.log(`Message from ${message.author.username}: ${message.content}`);
};

export default handler;
Expand Down
7 changes: 1 addition & 6 deletions apps/website/docs/guide/04-jsx-components/01-using-jsx.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ builders:
## Example usage

```tsx
import {
Container,
TextDisplay,
ActionRow,
Button,
} from 'commandkit';
import { Container, TextDisplay, ActionRow, Button } from 'commandkit';
import { ButtonStyle } from 'discord.js';

const message = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ components like buttons and select menus together in a single row.
```tsx title="src/app/commands/example.tsx"
import { type ChatInputCommand, ActionRow, Button } from 'commandkit';

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const row = (
<ActionRow>
<Button customId="button-1">Click me!</Button>
Expand All @@ -37,9 +35,7 @@ import {
StringSelectMenuOption,
} from 'commandkit';

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const row = (
<ActionRow>
<StringSelectMenu placeholder="Choose an option">
Expand All @@ -65,9 +61,7 @@ components:
import { type ChatInputCommand, ActionRow, Button } from 'commandkit';
import { ButtonStyle } from 'discord.js';

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const firstRow = (
<ActionRow>
<Button style={ButtonStyle.Primary} customId="button-1">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ emojis.
```tsx title="src/app/commands/button-example.tsx"
import { type ChatInputCommand, ActionRow, Button } from 'commandkit';

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const buttonRow = (
<ActionRow>
<Button customId="clickme-button">Click me!</Button>
Expand All @@ -36,9 +34,7 @@ Discord provides several button styles that you can import from the
import { type ChatInputCommand, ActionRow, Button } from 'commandkit';
import { ButtonStyle } from 'discord.js';

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const buttons = (
<ActionRow>
<Button style={ButtonStyle.Primary} customId="primary">
Expand Down Expand Up @@ -71,9 +67,7 @@ Link buttons redirect users to external URLs:
import { type ChatInputCommand, ActionRow, Button } from 'commandkit';
import { ButtonStyle } from 'discord.js';

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const linkButton = (
<ActionRow>
<Button style={ButtonStyle.Link} url="https://discord.com">
Expand All @@ -96,9 +90,7 @@ Add emojis to make your buttons more visually appealing:
```tsx title="src/app/commands/emoji-button.tsx"
import { type ChatInputCommand, ActionRow, Button } from 'commandkit';

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const emojiButton = (
<ActionRow>
<Button emoji="🎮" customId="play-game">
Expand All @@ -124,9 +116,7 @@ Disable buttons to prevent interaction:
```tsx title="src/app/commands/disabled-button.tsx"
import { type ChatInputCommand, ActionRow, Button } from 'commandkit';

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const disabledButton = (
<ActionRow>
<Button disabled customId="disabled">
Expand Down Expand Up @@ -156,10 +146,7 @@ import {
} from 'commandkit';
import { MessageFlags } from 'discord.js';

const handleClick: OnButtonKitClick = async (
interaction,
context,
) => {
const handleClick: OnButtonKitClick = async (interaction, context) => {
await interaction.reply({
content: 'Button clicked!',
flags: MessageFlags.Ephemeral,
Expand All @@ -169,9 +156,7 @@ const handleClick: OnButtonKitClick = async (
context.dispose();
};

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const interactiveButton = (
<ActionRow>
<Button onClick={handleClick} customId="clickme-button">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,10 @@ const handleSelect: OnStringSelectMenuKitSubmit = async (
context.dispose();
};

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const selectMenu = (
<ActionRow>
<StringSelectMenu
placeholder="Choose an option"
onSelect={handleSelect}
>
<StringSelectMenu placeholder="Choose an option" onSelect={handleSelect}>
<StringSelectMenuOption
label="Option 1"
value="1"
Expand Down Expand Up @@ -99,9 +94,7 @@ const handleSelect: OnChannelSelectMenuKitSubmit = async (
context.dispose();
};

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const selectMenu = (
<ActionRow>
<ChannelSelectMenu
Expand Down Expand Up @@ -145,15 +138,10 @@ const handleSelect: OnRoleSelectMenuKitSubmit = async (
context.dispose();
};

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const selectMenu = (
<ActionRow>
<RoleSelectMenu
placeholder="Choose a role"
onSelect={handleSelect}
/>
<RoleSelectMenu placeholder="Choose a role" onSelect={handleSelect} />
</ActionRow>
);

Expand Down Expand Up @@ -191,15 +179,10 @@ const handleSelect: OnUserSelectMenuKitSubmit = async (
context.dispose();
};

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const selectMenu = (
<ActionRow>
<UserSelectMenu
placeholder="Choose a user"
onSelect={handleSelect}
/>
<UserSelectMenu placeholder="Choose a user" onSelect={handleSelect} />
</ActionRow>
);

Expand Down Expand Up @@ -237,9 +220,7 @@ const handleSelect: OnMentionableSelectMenuKitSubmit = async (
context.dispose();
};

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const selectMenu = (
<ActionRow>
<MentionableSelectMenu
Expand Down Expand Up @@ -285,9 +266,7 @@ const handleSelect: OnStringSelectMenuKitSubmit = async (
context.dispose();
};

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const selectMenu = (
<ActionRow>
<StringSelectMenu
Expand All @@ -296,26 +275,10 @@ export const chatInput: ChatInputCommand = async ({
maxValues={3}
onSelect={handleSelect}
>
<StringSelectMenuOption
label="Pizza"
value="pizza"
emoji="🍕"
/>
<StringSelectMenuOption
label="Burger"
value="burger"
emoji="🍔"
/>
<StringSelectMenuOption
label="Pasta"
value="pasta"
emoji="🍝"
/>
<StringSelectMenuOption
label="Sushi"
value="sushi"
emoji="🍣"
/>
<StringSelectMenuOption label="Pizza" value="pizza" emoji="🍕" />
<StringSelectMenuOption label="Burger" value="burger" emoji="🍔" />
<StringSelectMenuOption label="Pasta" value="pasta" emoji="🍝" />
<StringSelectMenuOption label="Sushi" value="sushi" emoji="🍣" />
</StringSelectMenu>
</ActionRow>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@ import {
} from 'commandkit';
import { MessageFlags } from 'discord.js';

const handleSubmit: OnModalKitSubmit = async (
interaction,
context,
) => {
const handleSubmit: OnModalKitSubmit = async (interaction, context) => {
const name = interaction.fields.getTextInputValue('name');
const description =
interaction.fields.getTextInputValue('description');
const description = interaction.fields.getTextInputValue('description');

await interaction.reply({
content: `**Profile Created!**\n**Name:** ${name}\n**Description:** ${description}`,
Expand All @@ -34,9 +30,7 @@ const handleSubmit: OnModalKitSubmit = async (
context.dispose();
};

export const chatInput: ChatInputCommand = async ({
interaction,
}) => {
export const chatInput: ChatInputCommand = async ({ interaction }) => {
const modal = (
<Modal title="User Profile" onSubmit={handleSubmit}>
<ShortInput
Expand Down
Loading
Loading