File tree Expand file tree Collapse file tree 4 files changed +28
-19
lines changed
test-bot/src/app/commands/(interactions)
website/docs/guide/04-jsx-components/03-discord-components-v2 Expand file tree Collapse file tree 4 files changed +28
-19
lines changed Original file line number Diff line number Diff line change @@ -17,8 +17,10 @@ import {
17
17
Separator ,
18
18
MediaGallery ,
19
19
MediaGalleryItem ,
20
+ File ,
20
21
} from 'commandkit' ;
21
22
import {
23
+ AttachmentBuilder ,
22
24
ButtonStyle ,
23
25
Colors ,
24
26
MessageFlags ,
@@ -59,23 +61,22 @@ export const command: CommandData = {
59
61
// }
60
62
61
63
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.' ;
67
65
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
+ ) ;
76
72
77
73
await interaction . reply ( {
78
- components : components ,
74
+ components : [ container ] ,
75
+ files : [
76
+ new AttachmentBuilder ( Buffer . from ( fileContent ) , {
77
+ name : 'example.md' ,
78
+ } ) ,
79
+ ] ,
79
80
flags : MessageFlags . IsComponentsV2 ,
80
81
} ) ;
81
82
} ;
Original file line number Diff line number Diff line change @@ -8,8 +8,8 @@ items in a grid layout.
8
8
## Basic usage
9
9
10
10
``` tsx title="src/app/commands/gallery-example.tsx"
11
- import type { ChatInputCommand } from ' commandkit' ;
12
11
import {
12
+ type ChatInputCommand ,
13
13
MediaGallery ,
14
14
MediaGalleryItem ,
15
15
TextDisplay ,
Original file line number Diff line number Diff line change @@ -8,8 +8,12 @@ your message components.
8
8
## Basic usage
9
9
10
10
``` 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' ;
13
17
import {
14
18
Colors ,
15
19
MessageFlags ,
Original file line number Diff line number Diff line change @@ -8,8 +8,12 @@ Discord messages.
8
8
## Basic usage
9
9
10
10
``` 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' ;
13
17
import { AttachmentBuilder , Colors , MessageFlags } from ' discord.js' ;
14
18
15
19
export const chatInput: ChatInputCommand = async ({
You can’t perform that action at this time.
0 commit comments