Skip to content

Commit c0b35cf

Browse files
committed
docs: update <ActionRow /> examples
1 parent b7103b4 commit c0b35cf

File tree

2 files changed

+76
-41
lines changed

2 files changed

+76
-41
lines changed

apps/test-bot/src/app/commands/(interactions)/commandkit.tsx

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,47 +4,75 @@ import {
44
CommandData,
55
OnButtonKitClick,
66
ChatInputCommandContext,
7+
StringSelectMenu,
8+
StringSelectMenuOption,
79
} from 'commandkit';
8-
import { MessageFlags } from 'discord.js';
10+
import { ButtonStyle, MessageFlags } from 'discord.js';
911

1012
export const command: CommandData = {
1113
name: 'commandkit',
1214
description: 'This is a commandkit command.',
1315
};
1416

15-
const handleButtonClick: OnButtonKitClick = async (interaction) => {
16-
const { customId } = interaction;
17+
// const handleButtonClick: OnButtonKitClick = async (interaction) => {
18+
// const { customId } = interaction;
1719

18-
await interaction.reply({
19-
content: `You clicked the "${customId}" button!`,
20-
flags: MessageFlags.Ephemeral,
21-
});
22-
};
20+
// await interaction.reply({
21+
// content: `You clicked the "${customId}" button!`,
22+
// flags: MessageFlags.Ephemeral,
23+
// });
24+
// };
2325

24-
function ButtonGrid() {
25-
return (
26-
<>
27-
{Array.from({ length: 5 }, (_, i) => (
28-
<ActionRow>
29-
{Array.from({ length: 5 }, (_, j) => (
30-
<Button
31-
onClick={handleButtonClick}
32-
customId={`button ${i * 5 + j + 1}`}
33-
>
34-
{i * 5 + j + 1}
35-
</Button>
36-
))}
37-
</ActionRow>
38-
))}
39-
</>
40-
);
41-
}
26+
// function ButtonGrid() {
27+
// return (
28+
// <>
29+
// {Array.from({ length: 5 }, (_, i) => (
30+
// <ActionRow>
31+
// {Array.from({ length: 5 }, (_, j) => (
32+
// <Button
33+
// onClick={handleButtonClick}
34+
// customId={`button ${i * 5 + j + 1}`}
35+
// >
36+
// {i * 5 + j + 1}
37+
// </Button>
38+
// ))}
39+
// </ActionRow>
40+
// ))}
41+
// </>
42+
// );
43+
// }
4244

4345
export async function chatInput({ interaction }: ChatInputCommandContext) {
44-
await interaction.deferReply();
46+
// await interaction.deferReply();
47+
48+
// await interaction.editReply({
49+
// content: 'Click the button below to test CommandKit buttons.',
50+
// components: <ButtonGrid />,
51+
// });
4552

46-
await interaction.editReply({
47-
content: 'Click the button below to test CommandKit buttons.',
48-
components: <ButtonGrid />,
53+
const firstRow = (
54+
<ActionRow>
55+
<Button style={ButtonStyle.Primary} customId="button-1">
56+
Primary Action
57+
</Button>
58+
<Button style={ButtonStyle.Secondary} customId="button-2">
59+
Secondary Action
60+
</Button>
61+
</ActionRow>
62+
);
63+
64+
const secondRow = (
65+
<ActionRow>
66+
<Button style={ButtonStyle.Success} customId="button-3">
67+
Confirm
68+
</Button>
69+
<Button style={ButtonStyle.Danger} customId="button-4">
70+
Cancel
71+
</Button>
72+
</ActionRow>
73+
);
74+
75+
await interaction.reply({
76+
components: [firstRow, secondRow],
4977
});
5078
}

apps/website/docs/guide/04-jsx-components/02-discord-components-v1/01-action-row.mdx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,15 @@ components like buttons and select menus together in a single row.
88
## Basic usage
99

1010
```tsx title="src/app/commands/example.tsx"
11-
import type { ChatInputCommand } from 'commandkit';
12-
import { ActionRow, Button } from 'commandkit';
11+
import { type ChatInputCommand, ActionRow, Button } from 'commandkit';
1312

1413
export const chatInput: ChatInputCommand = async ({
1514
interaction,
1615
}) => {
1716
const row = (
1817
<ActionRow>
19-
<Button>Click me!</Button>
20-
<Button>Another button</Button>
18+
<Button customId="button-1">Click me!</Button>
19+
<Button customId="button-2">Another button</Button>
2120
</ActionRow>
2221
);
2322

@@ -31,8 +30,8 @@ export const chatInput: ChatInputCommand = async ({
3130
## With select menus
3231

3332
```tsx title="src/app/commands/select-example.tsx"
34-
import type { ChatInputCommand } from 'commandkit';
3533
import {
34+
type ChatInputCommand,
3635
ActionRow,
3736
StringSelectMenu,
3837
StringSelectMenuOption,
@@ -63,23 +62,31 @@ You can use multiple ActionRows in a single message to organize your
6362
components:
6463

6564
```tsx title="src/app/commands/multiple-rows.tsx"
66-
import type { ChatInputCommand } from 'commandkit';
67-
import { ActionRow, Button } from 'commandkit';
65+
import { type ChatInputCommand, ActionRow, Button } from 'commandkit';
66+
import { ButtonStyle } from 'discord.js';
6867

6968
export const chatInput: ChatInputCommand = async ({
7069
interaction,
7170
}) => {
7271
const firstRow = (
7372
<ActionRow>
74-
<Button style="primary">Primary Action</Button>
75-
<Button style="secondary">Secondary Action</Button>
73+
<Button style={ButtonStyle.Primary} customId="button-1">
74+
Primary Action
75+
</Button>
76+
<Button style={ButtonStyle.Secondary} customId="button-2">
77+
Secondary Action
78+
</Button>
7679
</ActionRow>
7780
);
7881

7982
const secondRow = (
8083
<ActionRow>
81-
<Button style="success">Confirm</Button>
82-
<Button style="danger">Cancel</Button>
84+
<Button style={ButtonStyle.Success} customId="button-3">
85+
Confirm
86+
</Button>
87+
<Button style={ButtonStyle.Danger} customId="button-4">
88+
Cancel
89+
</Button>
8390
</ActionRow>
8491
);
8592

0 commit comments

Comments
 (0)