The first public release gave us more feedback from people building their own bots. In 0.2.0, much of the work went into the places where commands, components, and services meet. Dynamic buttons and selects can carry data between interactions, guards work across more handler types, and logging and webhooks have their own packages.
We also fixed problems with shutdown, scheduled tasks, and stored component data. The example apps were updated alongside the packages so you can see how those changes fit into a bot.
Component data survives a restart
The memory adapter was removed from context.storage and payload.storage in defineComponents. Choose filesystem, redis, or sqlite for data kept by these stores. The filesystem adapter writes to .spraxium/contexts.json and .spraxium/payloads.json, so it's an option for a single bot process that needs to keep its data between restarts.
The old adapter lost all state when the process stopped. A button flow could work during testing and then lose its context after a deploy. Using persistent storage makes that behavior easier to account for from the start, including expiration and revocation.
Logging and webhooks have their own packages
@spraxium/logger moves logging out of Core. It supports custom levels, timestamp formatting, token masking, and transports you can add yourself. You can also send entries to a Discord webhook. Console output no longer depends on chalk, and environment validation uses the logger's table builder for its startup output.
@spraxium/webhook gives a bot two ways to send webhook messages. A class with @WebhookSender can use @Send to send the value returned by a method. For code that chooses a destination or sends several messages, WebhookService exposes methods such as send, sendEmbed, sendMany, and sendAll. Named webhooks are configured once through defineWebhook, together with an optional username and an error handler.
More ways to handle Discord interactions
Context menu commands now support both user and message targets. Define them with @ContextMenuCommand, attach the handler with @ContextMenuCommandHandler, and use guards and @Ctx as you would for slash commands. They register alongside slash commands at startup. In development, unchanged command definitions can skip another registration request.
@Defer and @AutoDefer help with Discord's three-second response window. The first defers a reply after guards pass. The second waits for a threshold, which defaults to two seconds, and defers only if the handler still hasn't responded. The handler can keep using interaction.reply() when it has a response ready.
Handlers also gained decorators for specific input types. Slash options can use @SlashStringOption, @SlashIntegerOption, @SlashBooleanOption, @SlashUserOption, @SlashChannelOption, @SlashRoleOption, @SlashMentionableOption, @SlashAttachmentOption, and @SlashNumberOption. The existing @SlashOpt still works and is marked deprecated.
Modal fields now have decorators for text, selects, radio groups, checkbox groups, individual checkboxes, and file uploads. We also fixed submitted radio and checkbox values being lost before they reached the handler. The command and modal examples use the new decorators.
Dynamic components can build their label and appearance from data when they're rendered. For stored payloads, @ButtonPayload() and @SelectPayload() give that data back to the handler. The default lifetime is ten minutes and can be set on the component. @PayloadRef() lets a handler consume a payload after the first use, and ButtonPayloadService.revokeMany() can invalidate several buttons when a flow ends elsewhere.
Small values can also travel in the custom ID through encoding: 'inline'. The handler reads them with @ButtonParams() or @SelectParams(). This is useful for a record ID or a flag that can stay in the message. Discord's 100-character limit still applies, and the framework checks it when rendering the component.
For a flow with several steps, ContextService.create() gives you shared data to attach with rowWithContext(). A handler receives it through @FlowContext() and can save its changes with flow.save(). A component can carry context together with a payload or inline parameters.
ButtonService.buildMixedRow() combines different dynamic button types in one row and returns the stored payload references for later revocation. Inside a Components V2 container, @V2DynamicRow splits a list of items into rows automatically.
Guards now run for buttons, selects, and modals through the same execution path used by Core. That includes global guards registered at startup. A permission check used by a slash command can also protect the interactions that follow it.
Startup and development
A project lock at .spraxium/spraxium.lock helps avoid starting the same bot twice from one directory. It records the process ID, checks whether an old process is still running, and removes stale locks. The --force-unlock and --no-lock flags, also available as SPRAXIUM_FORCE_UNLOCK and SPRAXIUM_NO_LOCK, cover cases where you need to change that behavior.
Startup also checks for updates to installed Spraxium packages in the background. Results are cached for 24 hours across projects on the same machine. Set SPRAXIUM_NO_UPGRADE_NOTIFIER=1 to turn that check off.
Translations, scheduled jobs, and examples
The i18n package adds buildLocalizedButton, buildLocalizedSelect, buildLocalizedModal, buildLocalizedEmbed, and buildLocalizedV2 to resolve translation keys from component definitions. In Schedule, @RunOnce(date) adds a job for a specific date and removes it after execution. A date that's already passed at startup produces a warning.
There are examples for shared guards, localized components, webhooks, and context menus. The slash command example also shows deferral. Package keywords were updated to help people find the packages on npm, and Codespaces now runs the build during setup.
Fixes across the packages
Shutdown now waits for handlers that are still running. Guards and exceptions were made more consistent across handler types, including errors after a reply was deferred. Signal gained nonce storage options and fixes to envelope verification.
We also fixed recovery from damaged payload entries, fallback behavior in Redis and file stores, and @RunOnce state changes around restarts. In the HTTP package, rate limiting and access logging are now connected to the request flow. Those settings existed in 0.1.0 but weren't being applied.