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 {
1717 Separator ,
1818 MediaGallery ,
1919 MediaGalleryItem ,
20+ File ,
2021} from 'commandkit' ;
2122import {
23+ AttachmentBuilder ,
2224 ButtonStyle ,
2325 Colors ,
2426 MessageFlags ,
@@ -59,23 +61,22 @@ export const command: CommandData = {
5961// }
6062
6163export 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} ;
Original file line number Diff line number Diff 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' ;
1211import {
12+ type ChatInputCommand ,
1313 MediaGallery ,
1414 MediaGalleryItem ,
1515 TextDisplay ,
Original file line number Diff line number Diff 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' ;
1317import {
1418 Colors ,
1519 MessageFlags ,
Original file line number Diff line number Diff 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' ;
1317import { AttachmentBuilder , Colors , MessageFlags } from ' discord.js' ;
1418
1519export const chatInput: ChatInputCommand = async ({
You can’t perform that action at this time.
0 commit comments