Skip to content

Commit 56c7cd1

Browse files
committed
docs: update component examples
1 parent c3a7c2d commit 56c7cd1

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

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

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ import {
1717
Separator,
1818
MediaGallery,
1919
MediaGalleryItem,
20+
File,
2021
} from 'commandkit';
2122
import {
23+
AttachmentBuilder,
2224
ButtonStyle,
2325
Colors,
2426
MessageFlags,
@@ -59,23 +61,22 @@ export const command: CommandData = {
5961
// }
6062

6163
export const chatInput: ChatInputCommand = async ({ interaction }) => {
62-
const images = [
63-
'https://cdn.discordapp.com/embed/avatars/0.png',
64-
'https://cdn.discordapp.com/embed/avatars/1.png',
65-
'https://cdn.discordapp.com/embed/avatars/2.png',
66-
];
64+
const fileContent = '# Hello World\nThis is a test markdown file.';
6765

68-
const components = [
69-
<TextDisplay content="# Discord Avatars Gallery" />,
70-
<MediaGallery>
71-
{images.map((url, index) => (
72-
<MediaGalleryItem url={url} description={`Avatar ${index + 1}`} />
73-
))}
74-
</MediaGallery>,
75-
];
66+
const container = (
67+
<Container accentColor={Colors.Blue}>
68+
<TextDisplay content="Here's a file:" />
69+
<File url="attachment://example.md" />
70+
</Container>
71+
);
7672

7773
await interaction.reply({
78-
components: components,
74+
components: [container],
75+
files: [
76+
new AttachmentBuilder(Buffer.from(fileContent), {
77+
name: 'example.md',
78+
}),
79+
],
7980
flags: MessageFlags.IsComponentsV2,
8081
});
8182
};

apps/website/docs/guide/04-jsx-components/03-discord-components-v2/03-media-gallery.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ items in a grid layout.
88
## Basic usage
99

1010
```tsx title="src/app/commands/gallery-example.tsx"
11-
import type { ChatInputCommand } from 'commandkit';
1211
import {
12+
type ChatInputCommand,
1313
MediaGallery,
1414
MediaGalleryItem,
1515
TextDisplay,

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ your message components.
88
## Basic usage
99

1010
```tsx title="src/app/commands/separator-example.tsx"
11-
import type { ChatInputCommand } from 'commandkit';
12-
import { Container, TextDisplay, Separator } from 'commandkit';
11+
import {
12+
type ChatInputCommand,
13+
Container,
14+
TextDisplay,
15+
Separator,
16+
} from 'commandkit';
1317
import {
1418
Colors,
1519
MessageFlags,

apps/website/docs/guide/04-jsx-components/03-discord-components-v2/05-file.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ Discord messages.
88
## Basic usage
99

1010
```tsx title="src/app/commands/file-example.tsx"
11-
import type { ChatInputCommand } from 'commandkit';
12-
import { Container, File, TextDisplay } from 'commandkit';
11+
import {
12+
type ChatInputCommand,
13+
Container,
14+
File,
15+
TextDisplay,
16+
} from 'commandkit';
1317
import { AttachmentBuilder, Colors, MessageFlags } from 'discord.js';
1418

1519
export const chatInput: ChatInputCommand = async ({

0 commit comments

Comments
 (0)