> ## Documentation Index
> Fetch the complete documentation index at: https://stars-components.js.org/llms.txt
> Use this file to discover all available pages before exploring further.

# @wolfstar/shared-http-pieces

> Reuse commands and error listeners across Star Network bots.

<CodeGroup>
  ```bash npm theme={"system"}
  npm install @wolfstar/shared-http-pieces
  ```

  ```bash pnpm theme={"system"}
  pnpm add @wolfstar/shared-http-pieces
  ```

  ```bash yarn theme={"system"}
  yarn add @wolfstar/shared-http-pieces
  ```

  ```bash bun theme={"system"}
  bun add @wolfstar/shared-http-pieces
  ```
</CodeGroup>

<CardGroup cols={2}>
  <Card title="npm" icon="npm" horizontal href="https://npmx.dev/package/@wolfstar/shared-http-pieces" />

  <Card title="Source" icon="github" horizontal href="https://github.com/wolfstar-project/stars-components/tree/main/packages/shared-http-pieces" />
</CardGroup>

## 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 resolved path
  is also exported as `localesPath`, if you need it directly.

## Usage

You can either register after setting environment parameters:

```typescript theme={"system"}
process.env.CLIENT_REPOSITORY = 'https://github.com/wolfstar-project/wolfstar';
process.env.CLIENT_INVITE =
	'https://discord.com/oauth2/authorize?client_id=266624760782258186&permissions=534185897078&scope=bot%20applications.commands';

import '@wolfstar/shared-http-pieces/register';
```

Or import its utilities as well as registering:

```typescript theme={"system"}
import { setRepository, setInvite } from '@wolfstar/shared-http-pieces';
import '@wolfstar/shared-http-pieces/register';

setRepository('wolfstar'); // setRepository('https://github.com/wolfstar-project/wolfstar');
setInvite('266624760782258186', '534185897078');
```

Furthermore, error handling can be enabled by setting the `SENTRY_DSN`, `@wolfstar/shared-http-pieces` includes a way to register [Sentry](https://docs.sentry.io) and registers handlers to handle errors into Sentry. The plugin also reads `SENTRY_ROOT` to set [`RewriteFrames`](https://docs.sentry.io/platforms/node/configuration/integrations/pluggable-integrations/#rewriteframes)'s root, defaults to `process.cwd()`.
