FlowRegistry

Gerencia a definição e registro de flows

Importação

typescript
import { FlowRegistry } from 'discord-flow';

Construtor

typescript
const registry = new FlowRegistry();

Métodos

define()

Define um novo flow no registry.

typescript
1registry.define(id: string, configurator: (flow: FlowBuilder) => void): this
2
3// Exemplo
4registry.define('meu-flow', (flow) => {
5 flow.start('idle');
6 flow.state('idle')
7 .on.command({ name: 'start' }, () => ({
8 response: { content: 'Started!' }
9 }));
10});

get()

Obtém um flow pelo ID.

typescript
1registry.get(id: string): FlowDefinition | undefined
2
3// Exemplo
4const flow = registry.get('meu-flow');

getCommands()

Retorna todos os nomes de comandos registrados.

typescript
1registry.getCommands(): string[]
2
3// Exemplo
4const commands = registry.getCommands();
5// ['start', 'help', 'ping']

getCommandsMetadata()

Retorna metadados completos dos comandos para registro automático.

typescript
1registry.getCommandsMetadata(): CommandMetadata[]
2
3interface CommandMetadata {
4 name: string;
5 description: string;
6 options?: CommandOption[];
7}

findFlowForCommand()

Encontra o flow que contém um comando específico.

typescript
1registry.findFlowForCommand(command: string): string | undefined
2
3// Exemplo
4const flowId = registry.findFlowForCommand('ping');