Skip to content

Commit 243244c

Browse files
committed
docs: update Container example
1 parent b37c728 commit 243244c

File tree

3 files changed

+61
-38
lines changed

3 files changed

+61
-38
lines changed

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

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,16 @@ import {
1212
Modal,
1313
ShortInput,
1414
ParagraphInput,
15+
TextDisplay,
16+
Container,
17+
Separator,
1518
} from 'commandkit';
16-
import { ButtonStyle, MessageFlags } from 'discord.js';
19+
import {
20+
ButtonStyle,
21+
Colors,
22+
MessageFlags,
23+
SeparatorSpacingSize,
24+
} from 'discord.js';
1725

1826
export const command: CommandData = {
1927
name: 'commandkit',
@@ -48,34 +56,35 @@ export const command: CommandData = {
4856
// );
4957
// }
5058

51-
const handleSubmit: OnModalKitSubmit = async (interaction, context) => {
52-
const name = interaction.fields.getTextInputValue('name');
53-
const description = interaction.fields.getTextInputValue('description');
54-
55-
await interaction.reply({
56-
content: `**Profile Created!**\n**Name:** ${name}\n**Description:** ${description}`,
57-
flags: MessageFlags.Ephemeral,
58-
});
59-
60-
context.dispose();
61-
};
62-
6359
export const chatInput: ChatInputCommand = async ({ interaction }) => {
64-
const modal = (
65-
<Modal title="User Profile" onSubmit={handleSubmit}>
66-
<ShortInput
67-
customId="name"
68-
label="Name"
69-
placeholder="Enter your name"
70-
required
60+
const headerContainer = (
61+
<Container accentColor={Colors.Blue}>
62+
<TextDisplay content="# Bot Status Report" />
63+
<TextDisplay
64+
content={`Generated on <t:${Math.floor(Date.now() / 1000)}:F>`}
7165
/>
72-
<ParagraphInput
73-
customId="description"
74-
label="Description"
75-
placeholder="Tell us about yourself"
76-
/>
77-
</Modal>
66+
</Container>
67+
);
68+
69+
const statsContainer = (
70+
<Container accentColor={Colors.Green}>
71+
<TextDisplay content="## Server Statistics" />
72+
<TextDisplay content="**Servers:** 50" />
73+
<TextDisplay content="**Users:** 15,000" />
74+
<TextDisplay content="**Commands executed:** 1,250 today" />
75+
</Container>
7876
);
7977

80-
await interaction.showModal(modal);
78+
const alertsContainer = (
79+
<Container accentColor={Colors.Yellow}>
80+
<TextDisplay content="## System Alerts" />
81+
<TextDisplay content="⚠️ Scheduled maintenance in 2 hours" />
82+
<TextDisplay content="✅ All systems operational" />
83+
</Container>
84+
);
85+
86+
await interaction.reply({
87+
components: [headerContainer, statsContainer, alertsContainer],
88+
flags: MessageFlags.IsComponentsV2,
89+
});
8190
};

apps/website/docs/guide/04-jsx-components/03-discord-components-v2/01-text-display.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ you to show text content in your Discord messages.
88
## Basic usage
99

1010
```tsx title="src/app/commands/text-example.tsx"
11-
import type { ChatInputCommand } from 'commandkit';
12-
import { TextDisplay } from 'commandkit';
11+
import { type ChatInputCommand, TextDisplay } from 'commandkit';
1312
import { MessageFlags } from 'discord.js';
1413

1514
export const chatInput: ChatInputCommand = async ({

apps/website/docs/guide/04-jsx-components/03-discord-components-v2/02-container.mdx

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@ organize and style multiple components together.
88
## Basic usage
99

1010
```tsx title="src/app/commands/container-example.tsx"
11-
import type { ChatInputCommand } from 'commandkit';
12-
import { Container, TextDisplay } from 'commandkit';
11+
import {
12+
type ChatInputCommand,
13+
Container,
14+
TextDisplay,
15+
} from 'commandkit';
1316
import { Colors, MessageFlags } from 'discord.js';
1417

1518
export const chatInput: ChatInputCommand = async ({
@@ -35,8 +38,11 @@ The `Container` component accepts an `accentColor` prop that can be
3538
used to customize its appearance:
3639

3740
```tsx title="src/app/commands/styled-container.tsx"
38-
import type { ChatInputCommand } from 'commandkit';
39-
import { Container, TextDisplay } from 'commandkit';
41+
import {
42+
type ChatInputCommand,
43+
Container,
44+
TextDisplay,
45+
} from 'commandkit';
4046
import { Colors, MessageFlags } from 'discord.js';
4147

4248
export const chatInput: ChatInputCommand = async ({
@@ -69,8 +75,12 @@ export const chatInput: ChatInputCommand = async ({
6975
You can nest various components inside a Container:
7076

7177
```tsx title="src/app/commands/nested-container.tsx"
72-
import type { ChatInputCommand } from 'commandkit';
73-
import { Container, TextDisplay, Separator } from 'commandkit';
78+
import {
79+
type ChatInputCommand,
80+
Container,
81+
TextDisplay,
82+
Separator,
83+
} from 'commandkit';
7484
import {
7585
Colors,
7686
MessageFlags,
@@ -109,8 +119,11 @@ export const chatInput: ChatInputCommand = async ({
109119
You can use multiple containers to organize different sections:
110120

111121
```tsx title="src/app/commands/multi-container.tsx"
112-
import type { ChatInputCommand } from 'commandkit';
113-
import { Container, TextDisplay } from 'commandkit';
122+
import {
123+
type ChatInputCommand,
124+
Container,
125+
TextDisplay,
126+
} from 'commandkit';
114127
import { Colors, MessageFlags } from 'discord.js';
115128

116129
export const chatInput: ChatInputCommand = async ({
@@ -119,7 +132,9 @@ export const chatInput: ChatInputCommand = async ({
119132
const headerContainer = (
120133
<Container accentColor={Colors.Blue}>
121134
<TextDisplay content="# Bot Status Report" />
122-
<TextDisplay content="*Generated on <t:${Math.floor(Date.now() / 1000)}:F>*" />
135+
<TextDisplay
136+
content={`Generated on <t:${Math.floor(Date.now() / 1000)}:F>`}
137+
/>
123138
</Container>
124139
);
125140

0 commit comments

Comments
 (0)