@nxenjs/discord-rich-presence
v1.0.0
Published
A lightweight module to manage Discord Rich Presence via IPC.
Downloads
78
Readme
A lightweight module to manage Discord Rich Presence via IPC.
Installation:
Node.js 18 or newer is required.
npm install @nxenjs/discord-rich-presence
yarn add @nxenjs/discord-rich-presence
pnpm add @nxenjs/discord-rich-presence
bun add @nxenjs/discord-rich-presenceHow to Use:
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
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. |
