Documentation
¶
Overview ¶
Package framework provides a simple embedding API for running a single Discord bot with a JavaScript authoring runtime inside any Go application.
The main entrypoint is New(), which accepts functional options:
bot, err := framework.New(
framework.WithCredentialsFromEnv(),
framework.WithScript("./my-bot/index.js"),
framework.WithSyncOnStart(true),
)
bot.Run(ctx)
For custom native modules, use WithRuntimeModuleRegistrars.
Index ¶
- type Bot
- type Config
- type Credentials
- type Option
- func WithCredentials(credentials Credentials) Option
- func WithCredentialsFromEnv() Option
- func WithRuntimeConfig(runtimeConfig map[string]any) Option
- func WithRuntimeModuleRegistrars(registrars ...engine.RuntimeModuleRegistrar) Option
- func WithScript(path string) Option
- func WithSyncOnStart(enabled bool) Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bot ¶
type Bot struct {
// contains filtered or unexported fields
}
Bot is the public single-bot wrapper around the internal runtime.
func (*Bot) SyncCommands ¶
SyncCommands manually syncs the bot's application commands.
type Config ¶
type Config struct {
Credentials Credentials
ScriptPath string
RuntimeConfig map[string]any
SyncOnStart bool
RuntimeModuleRegistrars []engine.RuntimeModuleRegistrar
}
Config describes the simple single-bot embedding path.
type Credentials ¶
type Credentials struct {
BotToken string
ApplicationID string
GuildID string
PublicKey string
ClientID string
ClientSecret string
}
Credentials holds the explicit Discord settings needed to run one bot.
type Option ¶
Option configures the public single-bot framework constructor.
func WithCredentials ¶
func WithCredentials(credentials Credentials) Option
WithCredentials configures explicit Discord credentials.
func WithCredentialsFromEnv ¶
func WithCredentialsFromEnv() Option
WithCredentialsFromEnv loads Discord credentials from the same env vars as the CLI.
func WithRuntimeConfig ¶
WithRuntimeConfig injects arbitrary runtime config values into ctx.config.
func WithRuntimeModuleRegistrars ¶
func WithRuntimeModuleRegistrars(registrars ...engine.RuntimeModuleRegistrar) Option
WithRuntimeModuleRegistrars appends custom per-runtime native module registrars.
func WithScript ¶
WithScript configures the explicit JavaScript bot script path.
func WithSyncOnStart ¶
WithSyncOnStart enables a command sync before opening the gateway session.