Skip to main content

npm

Source

Description

The shared commands used for Star Network’s HTTP-only bots.

Setup

  • Define locales/{{lng}}/commands/shared:infoEmbedDescription as a string. This is the content displayed in /info’s embed description.
  • Define the information variables.
  • Importing @wolfstar/shared-http-pieces/register registers a preGenericsInitialization hook that adds this package’s bundled locales and commands/shared namespace to your Client’s i18n configuration automatically, while retaining the consumer’s own locale path and namespaces. As long as it’s imported before new Client(...), no manual wiring is required. The bundled locales load regardless of whether @wolfstar/plugin-i18next/register is imported before or after it. The resolved path is also exported as localesPath, if you need it directly.

Usage

You can either register after setting environment parameters:
Or import its utilities as well as registering:

Activating with modules

On framework 6.5 and later, list the ./module entry in modules in stars.config instead of importing register. It needs the optional @wolfstar/kit peer dependency.
The module adds this package’s bundled locales with ctx.addLocales. The generated stars:locales plugin merges them into the i18n option before @wolfstar/plugin-i18next builds its handler, so your project’s own languages and namespaces are kept. The module also registers the @wolfstar/shared-http-pieces/pieces plugin, which loads the shared commands and listeners and imports @wolfstar/plugin-i18next/register. You still define the shared:infoEmbedDescription key and the information variables, and Sentry is set up the same way as with register. Use either the module or register, not both. Combining them registers the shared pieces twice. Furthermore, error handling can be enabled by setting the SENTRY_DSN, @wolfstar/shared-http-pieces includes a way to register Sentry and registers handlers to handle errors into Sentry. The plugin also reads SENTRY_ROOT to set RewriteFrames’s root, defaults to process.cwd(). The Sentry error listener does not report a UserError, such as a PreconditionError. These are expected failures, which @wolfstar/http-framework 6.3.0 and later emits as *Denied events. See Expected errors.