@discord-flow/core
v1.1.1
Published
Core flow engine for discord-flow
Maintainers
Readme
@discord-flow/core
Core flow engine for discord-flow. Provides the state machine and flow builder.
Installation
npm install @discord-flow/coreUsage
import { registry } from '@discord-flow/core';
const engine = registry.create();
registry.define('myBot', (flow) => {
flow.start('idle');
flow.state('idle')
.on.command({ name: 'start' }, () => ({
response: { content: 'Started!' },
transition: 'running'
}));
flow.state('running')
.on.command({ name: 'stop' }, () => ({
response: { content: 'Stopped!' },
transition: 'idle'
}));
});API
registry.create()
Creates a new flow engine instance.
registry.define(name, builder)
Defines a new flow with the given name.
flow.start(stateName)
Sets the initial state.
flow.state(name)
Defines a new state.
.on.command(options, handler)
Handles slash commands.
.on.button(id, handler)
Handles button clicks.
.on.modal(id, handler)
Handles modal submissions.
.on.select(id, handler)
Handles select menu interactions.
License
MIT
