API Reference
Complete API documentation for the Hazel Bot SDK
This reference documents all public APIs in the Hazel Bot SDK.
Entry Points
The SDK provides two ways to create a bot:
| Function | Use Case |
|---|---|
runHazelBot | Simplified setup with automatic config loading |
createHazelBot | Full control for advanced use cases |
runHazelBot
The recommended way to create a bot. Handles configuration, signal handling, and lifecycle automatically.
import { Effect } from "effect"
import { runHazelBot } from "@hazel/bot-sdk"
runHazelBot({
commands, // Optional: CommandGroup
layers, // Optional: Additional Effect layers
setup: (bot) =>
Effect.gen(function* () {
// Register handlers here
}),
})createHazelBot
For advanced use cases where you need full control over the runtime:
import { Effect } from "effect"
import { createHazelBot, HazelBotClient } from "@hazel/bot-sdk"
const runtime = createHazelBot({
botToken: process.env.BOT_TOKEN!,
commands,
})
const program = Effect.gen(function* () {
const bot = yield* HazelBotClient
// ...
yield* bot.start
yield* Effect.never
})
runtime.runPromise(program.pipe(Effect.scoped))Reference Pages
HazelBotClient
Event handlers and message operations
Commands
Command.make and CommandGroup
Configuration
Environment variables and options
Errors
Error types and handling
Quick Reference
Event Handlers
| Method | Description |
|---|---|
bot.onMessage(handler) | New messages |
bot.onMessageUpdate(handler) | Message edits |
bot.onMessageDelete(handler) | Message deletions |
bot.onChannelCreated(handler) | New channels |
bot.onChannelUpdated(handler) | Channel updates |
bot.onChannelDeleted(handler) | Channel deletions |
bot.onChannelMemberAdded(handler) | Member joins |
bot.onChannelMemberRemoved(handler) | Member leaves |
bot.onCommand(command, handler) | Slash commands |
Message Operations
| Method | Description |
|---|---|
bot.message.send(channelId, content) | Send a message |
bot.message.reply(message, content) | Reply to a message |
bot.message.update(message, content) | Edit a message |
bot.message.delete(messageId) | Delete a message |
bot.message.react(message, emoji) | React with emoji |
Other Operations
| Method | Description |
|---|---|
bot.typing.start(channelId, memberId) | Show typing indicator |
bot.typing.stop(typingIndicatorId) | Hide typing indicator |
bot.channel.update(channel, updates) | Update channel |
bot.withErrorHandler(ctx) | Wrap handler with error handling |
bot.start | Start the bot |
bot.getAuthContext | Get bot auth context |