Components V2

Novos componentes do Discord para criar interfaces ricas

Container

Containers agrupam componentes com uma cor de destaque:

typescript
1import { Container, TextDisplay, Section, Button } from 'discord-flow';
2
3Container({
4 accentColor: 0x1EBE38,
5 components: [
6 TextDisplay({ content: '## Título' }),
7 Section({
8 accessory: Button({
9 customId: 'action',
10 label: 'Clique',
11 style: 1
12 }),
13 components: [
14 TextDisplay({ content: 'Conteúdo da seção' })
15 ]
16 })
17 ]
18});

Section

Sections organizam conteúdo com um accessory (botão ou thumbnail):

typescript
1Section({
2 accessory: Button({
3 customId: 'settings',
4 label: 'Configurar',
5 style: 2
6 }),
7 components: [
8 TextDisplay({ content: '**Configurações**' }),
9 TextDisplay({ content: 'Gerencie suas preferências' })
10 ]
11});
12
13// Com thumbnail
14Section({
15 accessory: Thumbnail({
16 url: 'https://example.com/image.png'
17 }),
18 components: [
19 TextDisplay({ content: 'Descrição com imagem' })
20 ]
21});

MediaGallery

Exibe múltiplas imagens em uma galeria:

typescript
1MediaGallery({
2 items: [
3 { url: 'https://example.com/img1.png' },
4 { url: 'https://example.com/img2.png' },
5 { url: 'https://example.com/img3.png' }
6 ]
7});

Separator

Adiciona um divisor visual:

typescript
1Separator({ spacing: 'large' }); // 'small' | 'large'

File

Exibe um arquivo para download:

typescript
1File({
2 url: 'https://example.com/document.pdf',
3 filename: 'document.pdf'
4});

Exemplo Completo

typescript
1import {
2 Container, Section, TextDisplay,
3 Button, Separator, ActionRow
4} from 'discord-flow';
5
6const panel = Container({
7 accentColor: 0x1EBE38,
8 components: [
9 TextDisplay({ content: '# Painel Admin' }),
10 Separator({ spacing: 'small' }),
11 Section({
12 accessory: Button({
13 customId: 'users',
14 label: 'Ver',
15 style: 2
16 }),
17 components: [
18 TextDisplay({ content: '**Usuários**' }),
19 TextDisplay({ content: '42 usuários ativos' })
20 ]
21 }),
22 Section({
23 accessory: Button({
24 customId: 'logs',
25 label: 'Ver',
26 style: 2
27 }),
28 components: [
29 TextDisplay({ content: '**Logs**' }),
30 TextDisplay({ content: '128 eventos hoje' })
31 ]
32 }),
33 Separator({ spacing: 'small' }),
34 ActionRow({
35 components: [
36 Button({ customId: 'refresh', label: 'Atualizar', style: 1 }),
37 Button({ customId: 'settings', label: 'Config', style: 2 })
38 ]
39 })
40 ]
41});