Skip to content

Commit ac564f2

Browse files
committed
feat: add thumbnail element
1 parent 79a92b8 commit ac564f2

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

apps/test-bot/src/app/commands/(general)/components.tsx

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import CommandKit, {
1212
Section,
1313
Separator,
1414
TextDisplay,
15+
Thumbnail,
1516
} from 'commandkit';
1617
import {
1718
AttachmentBuilder,
@@ -53,12 +54,16 @@ export const chatInput: ChatInputCommand = async (ctx) => {
5354
<TextDisplay content="# CommandKit Components v2 test" />
5455
<Section>
5556
<TextDisplay content="This is a section" />
57+
<Thumbnail url="https://cdn.discordapp.com/embed/avatars/0.png" />
58+
</Section>
59+
<Separator spacing={SeparatorSpacingSize.Large} />
60+
<Section>
61+
<TextDisplay content="This is after separator" />
5662
<Button url="https://commandkit.dev" style={ButtonStyle.Link}>
5763
Website
5864
</Button>
5965
</Section>
60-
<Separator spacing={SeparatorSpacingSize.Large} />
61-
<TextDisplay content="This is after separator" />
66+
<Separator spacing={SeparatorSpacingSize.Large} dividier />
6267
<File url="attachment://components-v2-are-awesome.md" />
6368
<Separator spacing={SeparatorSpacingSize.Large} dividier />
6469
<TextDisplay content="Discord's default avatars" />

packages/commandkit/src/components/v2/container.ts

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
SectionBuilder,
99
SeparatorBuilder,
1010
TextDisplayBuilder,
11+
ThumbnailBuilder,
1112
} from 'discord.js';
1213
import { applyId } from './common';
1314

packages/commandkit/src/components/v2/section.ts

+18-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
// import { TextDisplayBuilder, TextDisplayComponentData } from 'discord.js';
2-
31
import {
42
ButtonBuilder,
5-
ComponentBuilder,
63
SectionBuilder,
74
TextDisplayBuilder,
85
ThumbnailBuilder,
@@ -33,3 +30,21 @@ export function Section(props: SectionProps): SectionBuilder {
3330

3431
return section;
3532
}
33+
34+
export interface ThumbnailProps {
35+
id?: number;
36+
description?: string;
37+
spoiler?: boolean;
38+
url: string;
39+
}
40+
41+
export function Thumbnail(props: ThumbnailProps) {
42+
const thumbnail = new ThumbnailBuilder({
43+
description: props.description,
44+
spoiler: props.spoiler,
45+
id: props.id,
46+
media: { url: props.url },
47+
});
48+
49+
return thumbnail;
50+
}

0 commit comments

Comments
 (0)