open-index/open-npm huggingface dataset:
npm package: @nxenjs/discord-rich-presence
Description: A lightweight module to manage Discord Rich Presence via IPC.
Author: nxen
Latest version: 1.0.0

<div align="center">
  <div>
    <h1><b>
      DISCORD-RICH-PRESENCE
      <br>
      <a href="https://www.npmjs.com/package/@nxenjs/discord-rich-presence">
        <img src="https://img.shields.io/npm/v/@nxenjs/discord-rich-presence?label=NPM" alt="NPM" />
      </a>
      <a href="https://github.com/shadoow051/DBM-v14">
        <img src="https://img.shields.io/github/contributors/shadoow051/DBM-v14?label=Contributors" alt="Contributors" />
      </a>
      <a href="https://github.com/shadoow051/DBM-v14">
        <img src="https://img.shields.io/github/last-commit/shadoow051/DBM-v14?label=Last%20Commit" alt="Last Commit" />
      </a>
    </b></h1>
  </div>
</div>

**A lightweight module to manage Discord Rich Presence via IPC.**

---

# Installation:
Node.js 18 or newer is required.
```bash
npm install @nxenjs/discord-rich-presence
yarn add @nxenjs/discord-rich-presence
pnpm add @nxenjs/discord-rich-presence
bun add @nxenjs/discord-rich-presence
```

# How to Use:

```js
import { Client } from "@nxenjs/discord-rich-presence";

const rpc = new Client();
const clientId = "1470175687960087850"; // Replace with your Discord App client ID

rpc.on("ready", () => {
  rpc.setActivity({
    name: "Activity Name",
    details: "Activity Details",
    state: "Activity State",
  });
});

await rpc.login(clientId);
```
or
```js
import { Client } from "@nxenjs/discord-rich-presence";

const rpc = new Client();
const clientId = "1470175687960087850"; // Replace with your Discord App client ID

rpc.on("ready", () => {
  rpc.clearActivity();
});

await rpc.login(clientId);
```

# Exports:

| Export  | Description                                |
|---------|--------------------------------------------|
| Client  | The main class for managing rich presence |
| version | Constant containing the module version    |

# Client:

| Method        | Arguments                                      | Description |
|---------------|-----------------------------------------------|-------------|
| login         | `clientId: string`                             | Connects to Discord using the provided application client ID. Returns a Promise resolving to the client instance. |
| destroy       | -                                             | Destroys the client and disconnects the IPC socket. Returns a Promise. |
| setActivity   | `activity: Object`, `pid?: number`            | Updates the user's Rich Presence. `pid` defaults to the current process ID. Returns a Promise resolving to a boolean. |
| clearActivity | `pid?: number`                                 | Clears the user's Rich Presence. `pid` defaults to the current process ID. Returns a Promise resolving to a boolean. |