Components

Funções helper para criar componentes Discord

Importação

typescript
import {
Button,
ActionRow,
SelectMenu,
TextInput,
Container,
Section,
TextDisplay,
Separator,
MediaGallery,
Thumbnail,
File
} from 'discord-flow';

Button

typescript
1Button({
2 customId: string;
3 label: string;
4 style: 1 | 2 | 3 | 4 | 5;
5 emoji?: { name: string; id?: string };
6 disabled?: boolean;
7 url?: string; // Para style 5 (Link)
8})
9
10// Estilos
11// 1 = Primary(Blurple)
12// 2 = Secondary(Gray)
13// 3 = Success(Green)
14// 4 = Danger(Red)
15// 5 = Link

ActionRow

typescript
1ActionRow({
2 components: Component[];
3})
4
5// Exemplo
6ActionRow({
7 components: [
8 Button({ customId: 'btn1', label: 'Um', style: 1 }),
9 Button({ customId: 'btn2', label: 'Dois', style: 2 })
10 ]
11})

SelectMenu

typescript
1SelectMenu({
2 customId: string;
3 placeholder?: string;
4 minValues?: number;
5 maxValues?: number;
6 options: {
7 label: string;
8 value: string;
9 description?: string;
10 emoji?: { name: string; id?: string };
11 default?: boolean;
12 }[];
13})

TextInput

typescript
1TextInput({
2 customId: string;
3 label: string;
4 style: 1 | 2; // 1 = Short, 2 = Paragraph
5 placeholder?: string;
6 value?: string;
7 required?: boolean;
8 minLength?: number;
9 maxLength?: number;
10})

Container (V2)

typescript
1Container({
2 accentColor?: number; // Cor hex(ex: 0x1EBE38)
3 spoiler?: boolean;
4 components: Component[];
5})

Section (V2)

typescript
1Section({
2 accessory: Button | Thumbnail;
3 components: TextDisplay[];
4})

TextDisplay (V2)

typescript
1TextDisplay({
2 content: string; // Suporta markdown
3})

Separator (V2)

typescript
1Separator({
2 spacing?: 'small' | 'large';
3 divider?: boolean;
4})

MediaGallery (V2)

typescript
1MediaGallery({
2 items: {
3 url: string;
4 description?: string;
5 spoiler?: boolean;
6 }[];
7})

Thumbnail (V2)

typescript
1Thumbnail({
2 url: string;
3 description?: string;
4 spoiler?: boolean;
5})

File (V2)

typescript
1File({
2 url: string;
3 filename?: string;
4 spoiler?: boolean;
5})