Skip to content

Why Arona

Arona builds interactive chat messages with effect/ui. You write one component. Arona renders it on Discord and on Slack.

A chat message is not a document. It changes after every click.

A button press arrives as an interaction. The bot must find the message, update its state, and edit the message. Most bots spread that work across handlers, caches, and ad-hoc payload code.

Arona makes the message a component with a Model. The interaction updates the Model. The view re-renders. The host edits the message.

A component has four parts:

  • Props: the values the command passes in.
  • Model: the state the component owns.
  • Message: the events the view can send.
  • View: a pure function from Model to elements.

update is pure. It returns the next Model. The host sends the new state to the platform. There is no React runtime, no hooks, and no JSX step.

Each platform package provides a host and a vocabulary:

  • @arona/platform-discord renders Discord Components V2.
  • @arona/platform-slack renders Slack Block Kit.

@arona/core owns the renderer, the message lifecycle, sessions, and telemetry. Platform packages only add their host, target, vocabulary, and components.

This file is examples/counter. The workspace type-checks it, so it compiles:

examples/counter/src/index.ts
import { UiSchema } from "effect/ui";
import * as Discord from "@arona/platform-discord";
import {
ActionRow,
Button,
Container,
DiscordGatewayClient,
Intent,
SlashCommand,
Text,
} from "@arona/platform-discord";
import { NodeRuntime } from "@effect/platform-node";
import { Config, Effect, Schema } from "effect";
const Clicked = UiSchema.TaggedEnum({ Clicked: {} });
const CounterProps = Schema.Struct({ start: Schema.optional(Schema.Int) });
const Counter = Discord.component({
name: "Counter",
props: CounterProps,
model: Schema.Struct({ count: Schema.Finite }),
message: Clicked,
}).make({
init: ($) => ({ count: $.props.start ?? 0 }),
update: {
Clicked: ($) => $.evolve({ count: (count) => count + 1 }),
},
view: (h, model) =>
Container(h, {
children: [
Text(h, `# Count: ${model.count}`),
ActionRow(h, {
children: [Button(h, { onClick: Clicked.Clicked(), children: ["+1"] })],
}),
],
}),
});
const counter = SlashCommand.make("counter", {
description: "Increment a counter",
options: {
start: SlashCommand.integer({ description: "Starting count" }),
},
component: Counter,
});
const program = Effect.gen(function* () {
const config = yield* Config.all({
token: Config.Redacted("DISCORD_APP_TOKEN"),
clientId: Config.String("DISCORD_APP_ID"),
devGuildId: Config.option(Config.String("DISCORD_DEV_GUILD_ID")),
});
return yield* Effect.gen(function* () {
const client = yield* DiscordGatewayClient;
const user = yield* client.login;
yield* Effect.log(`Logged in as ${user.username}`);
return yield* Effect.never;
}).pipe(
Effect.provide(
DiscordGatewayClient.layerEphemeral({
token: config.token,
clientId: config.clientId,
devGuildId: config.devGuildId,
intents: [Intent.Guilds],
commands: [counter],
}),
),
);
});
NodeRuntime.runMain(program);

The command, the component, and the client fit in one file. Start the process and the bot logs in and registers /counter.