@hieuxyz/rpc 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2025, hieuxyz
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,176 @@
1
+ # @hieuxyz/rpc
2
+
3
+ [![NPM Version](https://img.shields.io/npm/v/@hieuxyz/rpc.svg)](https://www.npmjs.com/package/@hieuxyz/rpc)
4
+ [![License](https://img.shields.io/npm/l/@hieuxyz/rpc.svg)](https://github.com/hieuxyz/rpc/blob/main/LICENSE)
5
+ [![Downloads](https://img.shields.io/npm/dt/@hieuxyz/rpc.svg)](https://www.npmjs.com/package/@hieuxyz/rpc)
6
+
7
+ An easy-to-use Discord Rich Presence (RPC) library built for the Node.js environment using TypeScript. This library is designed to simplify the creation and management of custom RPC states for Discord user accounts.
8
+
9
+ > [!WARNING]
10
+ > **I don't take any responsibility for blocked Discord accounts that used this module.**
11
+
12
+ > [!CAUTION]
13
+ > **Using this on a user account is prohibited by the [Discord TOS](https://discord.com/terms) and can lead to the account block.**
14
+ > **When using these libraries, you accept the risk of exposing your Discord Token.**
15
+
16
+ ## Outstanding features
17
+
18
+ - **Flexible Builder Pattern:** Easily build your RPC state with intuitive chainable methods.
19
+ - **Easy to use:** The `Client` class abstracts away all the complex connection and setup logic, letting you get started with just a few lines of code.
20
+ - **Auto Resume:** Built-in auto reconnect and session recovery mechanism in case of network failure, ensuring your RPC is always stable.
21
+
22
+ ## Install
23
+
24
+ Use `npm` or `yarn` to install libraries:
25
+
26
+ ```bash
27
+ npm i @hieuxyz/rpc
28
+ ```
29
+
30
+ ## How to use
31
+
32
+ Here is a complete example to get you started.
33
+
34
+ **1. Create a `.env` file**
35
+
36
+ In the root directory of your project, create a file called `.env` and paste your Discord token into it.
37
+
38
+ ```
39
+ DISCORD_USER_TOKEN="YOUR_DISCORD_USER_TOKEN_HERE"
40
+ ```
41
+
42
+ **2. Write your source code (e.g. `index.ts`)**
43
+
44
+ ```typescript
45
+ import * as path from 'path';
46
+ import { Client, RawImage, LocalImage, logger } from '@hieuxyz/rpc';
47
+
48
+ async function start() {
49
+ const token = process.env.DISCORD_USER_TOKEN;
50
+
51
+ if (!token) {
52
+ logger.error("Token not found in .env file. Please set DISCORD_USER_TOKEN.");
53
+ return;
54
+ }
55
+
56
+ // Initialize client with token
57
+ const client = new Client({ token });
58
+
59
+ await client.run();
60
+
61
+ client.rpc
62
+ .setName("Visual Studio Code")
63
+ .setDetails("Developing a new library")
64
+ .setState("Workspace: @hieuxyz/rpc")
65
+ .setPlatform('desktop') // 'desktop', 'xbox', 'ps5', etc.
66
+ .setType(0) // 0: Playing
67
+ .setTimestamps(Date.now())
68
+ .setParty(1, 5)
69
+ .setLargeImage(new RawImage("mp:external/b7uybXM7LoJRB6_ig-65aX6dCHm2qGCEe8CiS5j7c2M/https/cdn.worldvectorlogo.com/logos/typescript.svg"), "TypeScript")
70
+ .setSmallImage(new LocalImage(path.join(__dirname, 'vscode.png')), "VS Code")
71
+ .setButtons([
72
+ { label: "View on GitHub", url: "https://github.com/hieuxyz00/hieuxyz_rpc" }
73
+ ]);
74
+
75
+ await client.rpc.build();
76
+
77
+ setTimeout(async () => {
78
+ logger.info("Updating RPC details dynamically...");
79
+
80
+ // Change the necessary information
81
+ client.rpc
82
+ .setDetails("Reviewing pull requests")
83
+ .setState("PR #01: Feature enhancement")
84
+ .setParty(2, 5);
85
+
86
+ await client.rpc.updateRPC();
87
+
88
+ logger.info("RPC has been dynamically updated!");
89
+
90
+ }, 15000);
91
+
92
+ process.on('SIGINT', () => {
93
+ logger.info("SIGINT received. Closing connection...");
94
+ client.close();
95
+ process.exit(0);
96
+ });
97
+ }
98
+
99
+ start().catch(err => {
100
+ logger.error(`An unexpected error occurred: ${err}`);
101
+ });
102
+ ```
103
+
104
+ ## Get Token ?
105
+
106
+ - Based: [findByProps](https://discord.com/channels/603970300668805120/1085682686607249478/1085682686607249478)
107
+
108
+ <strong>Run code (Discord Console - [Ctrl + Shift + I])</strong>
109
+
110
+ ```js
111
+ window.webpackChunkdiscord_app.push([
112
+ [Symbol()],
113
+ {},
114
+ req => {
115
+ if (!req.c) return;
116
+ for (let m of Object.values(req.c)) {
117
+ try {
118
+ if (!m.exports || m.exports === window) continue;
119
+ if (m.exports?.getToken) return copy(m.exports.getToken());
120
+ for (let ex in m.exports) {
121
+ if (m.exports?.[ex]?.getToken && m.exports[ex][Symbol.toStringTag] !== 'IntlMessagesProxy') return copy(m.exports[ex].getToken());
122
+ }
123
+ } catch {}
124
+ }
125
+ },
126
+ ]);
127
+
128
+ window.webpackChunkdiscord_app.pop();
129
+ console.log('%cWorked!', 'font-size: 50px');
130
+ console.log(`%cYou now have your token in the clipboard!`, 'font-size: 16px');
131
+ ```
132
+
133
+ ## API Reference
134
+
135
+ ### The `Client` Class
136
+
137
+ This is the main starting point.
138
+
139
+ - `new Client(options)`: Create a new instance.
140
+ - `options.token` (required): Your Discord user token.
141
+ - `options.apiBaseUrl` (optional): Override the default image proxy service URL.
142
+ - `client.run()`: Start connecting to Discord Gateway.
143
+ - `client.rpc`: Access the instance of `HieuxyzRPC` to build the state.
144
+
145
+ ### Class `HieuxyzRPC`
146
+
147
+ Main builder class for RPC.
148
+
149
+ - `.setName(string)`: Activity name (first line).
150
+ - `.setDetails(string)`: Activity details (second line).
151
+ - `.setState(string)`: Activity status (third line).
152
+ - `.setTimestamps(start?, end?)`: Set start/end time.
153
+ - `.setParty(current, max)`: Set group information.
154
+ - `.setLargeImage(RpcImage, text?)`: Set large image and caption.
155
+ - `.setSmallImage(RpcImage, text?)`: Set thumbnail and caption.
156
+ - `.setButtons(buttons[])`: Set buttons (up to 2).
157
+ - `.setPlatform(platform)`: Lay the platform (`'desktop'`, `'xbox'`, `'ps5'`).
158
+ - `.build()`: First RPC send.
159
+ - `.updateRPC()`: Send updates to an existing RPC.(it just call build() lol)
160
+
161
+ ### Types of images
162
+
163
+ - `new ExternalImage(url)`: Use image from an external URL (will be proxy).
164
+ - `new LocalImage(filePath, fileName?)`: Upload a photo from your device.
165
+ - `new RawImage(assetKey)`: Use an existing asset key directly.
166
+ - `new DiscordImage(key)`: Use assets already on Discord.
167
+
168
+ ## Author
169
+
170
+ Developed by **hieuxyz**.
171
+
172
+ - GitHub: [@hieuxyz00](https://github.com/hieuxyz00)
173
+
174
+ ## Copyright
175
+
176
+ This project is licensed under the ISC License. See the `LICENSE` file for more details.
@@ -0,0 +1,46 @@
1
+ import { HieuxyzRPC } from './rpc/HieuxyzRPC';
2
+ /**
3
+ * Option to initialize Client.
4
+ */
5
+ export interface ClientOptions {
6
+ /** Your Discord user token. */
7
+ token: string;
8
+ /** (Optional) Base URL of the image proxy service. */
9
+ apiBaseUrl?: string;
10
+ }
11
+ /**
12
+ * The main Client class for interacting with Discord Rich Presence.
13
+ * This is the starting point for creating and managing your RPC state.
14
+ * @example
15
+ * const client = new Client({ token: "YOUR_DISCORD_TOKEN" });
16
+ * await client.run();
17
+ * client.rpc.setName("Visual Studio Code");
18
+ * await client.rpc.build();
19
+ */
20
+ export declare class Client {
21
+ /**
22
+ * Provides access to RPC constructor methods.
23
+ * Use this property to set your Rich Presence state details.
24
+ */
25
+ readonly rpc: HieuxyzRPC;
26
+ private readonly websocket;
27
+ private readonly imageService;
28
+ private readonly token;
29
+ /**
30
+ * Create a new Client instance.
31
+ * @param options - Options to configure the client.
32
+ * @throws {Error} If no token is provided in the options.
33
+ */
34
+ constructor(options: ClientOptions);
35
+ /**
36
+ * Connect to Discord Gateway and prepare the client for RPC updates.
37
+ * This method must be called before sending any Rich Presence updates.
38
+ * @returns {Promise<void>} A promise will be resolved when the client is ready.
39
+ */
40
+ run(): Promise<void>;
41
+ /**
42
+ * Close the connection to Discord Gateway.
43
+ * Terminate RPC and clean up resources.
44
+ */
45
+ close(): void;
46
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Client = void 0;
4
+ const DiscordWebSocket_1 = require("./gateway/DiscordWebSocket");
5
+ const HieuxyzRPC_1 = require("./rpc/HieuxyzRPC");
6
+ const ImageService_1 = require("./rpc/ImageService");
7
+ const logger_1 = require("./utils/logger");
8
+ /**
9
+ * The main Client class for interacting with Discord Rich Presence.
10
+ * This is the starting point for creating and managing your RPC state.
11
+ * @example
12
+ * const client = new Client({ token: "YOUR_DISCORD_TOKEN" });
13
+ * await client.run();
14
+ * client.rpc.setName("Visual Studio Code");
15
+ * await client.rpc.build();
16
+ */
17
+ class Client {
18
+ /**
19
+ * Provides access to RPC constructor methods.
20
+ * Use this property to set your Rich Presence state details.
21
+ */
22
+ rpc;
23
+ websocket;
24
+ imageService;
25
+ token;
26
+ /**
27
+ * Create a new Client instance.
28
+ * @param options - Options to configure the client.
29
+ * @throws {Error} If no token is provided in the options.
30
+ */
31
+ constructor(options) {
32
+ if (!options.token) {
33
+ throw new Error("Tokens are required to connect to Discord.");
34
+ }
35
+ this.token = options.token;
36
+ this.imageService = new ImageService_1.ImageService(options.apiBaseUrl);
37
+ this.websocket = new DiscordWebSocket_1.DiscordWebSocket(this.token);
38
+ this.rpc = new HieuxyzRPC_1.HieuxyzRPC(this.websocket, this.imageService);
39
+ }
40
+ /**
41
+ * Connect to Discord Gateway and prepare the client for RPC updates.
42
+ * This method must be called before sending any Rich Presence updates.
43
+ * @returns {Promise<void>} A promise will be resolved when the client is ready.
44
+ */
45
+ async run() {
46
+ this.websocket.connect();
47
+ logger_1.logger.info("Waiting for Discord session to be ready...");
48
+ await this.websocket.readyPromise;
49
+ logger_1.logger.info("Client is ready to send Rich Presence updates.");
50
+ }
51
+ /**
52
+ * Close the connection to Discord Gateway.
53
+ * Terminate RPC and clean up resources.
54
+ */
55
+ close() {
56
+ this.websocket.close();
57
+ }
58
+ }
59
+ exports.Client = Client;
@@ -0,0 +1,47 @@
1
+ import { PresenceUpdatePayload } from './entities/types';
2
+ /**
3
+ * Manage WebSocket connections to Discord Gateway.
4
+ * Handles low-level operations like heartbeating, identifying, and resuming.
5
+ */
6
+ export declare class DiscordWebSocket {
7
+ private token;
8
+ private ws;
9
+ private sequence;
10
+ private heartbeatInterval;
11
+ private sessionId;
12
+ private resumeGatewayUrl;
13
+ private resolveReady;
14
+ /**
15
+ * A promise will be resolved when the Gateway connection is ready.
16
+ * and received the READY event.
17
+ */
18
+ readyPromise: Promise<void>;
19
+ /**
20
+ * Create a DiscordWebSocket instance.
21
+ * @param token - Discord user token for authentication.
22
+ * @throws {Error} If the token is invalid.
23
+ */
24
+ constructor(token: string);
25
+ private isTokenValid;
26
+ /**
27
+ * Initiate connection to Discord Gateway.
28
+ * If there was a previous session, it will try to resume.
29
+ */
30
+ connect(): void;
31
+ private onMessage;
32
+ private startHeartbeating;
33
+ private identify;
34
+ private resume;
35
+ /**
36
+ * Send presence update payload to Gateway.
37
+ * @param presence - Payload update status to send.
38
+ */
39
+ sendActivity(presence: PresenceUpdatePayload): void;
40
+ private sendJson;
41
+ /**
42
+ * Close the WebSocket connection and clean up the resources.
43
+ */
44
+ close(): void;
45
+ private cleanupHeartbeat;
46
+ private shouldReconnect;
47
+ }
@@ -0,0 +1,169 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.DiscordWebSocket = void 0;
7
+ const ws_1 = __importDefault(require("ws"));
8
+ const logger_1 = require("../utils/logger");
9
+ const identify_1 = require("./entities/identify");
10
+ const OpCode_1 = require("./entities/OpCode");
11
+ /**
12
+ * Manage WebSocket connections to Discord Gateway.
13
+ * Handles low-level operations like heartbeating, identifying, and resuming.
14
+ */
15
+ class DiscordWebSocket {
16
+ token;
17
+ ws = null;
18
+ sequence = null;
19
+ heartbeatInterval = null;
20
+ sessionId = null;
21
+ resumeGatewayUrl = null;
22
+ resolveReady = () => { };
23
+ /**
24
+ * A promise will be resolved when the Gateway connection is ready.
25
+ * and received the READY event.
26
+ */
27
+ readyPromise = new Promise(resolve => (this.resolveReady = resolve));
28
+ /**
29
+ * Create a DiscordWebSocket instance.
30
+ * @param token - Discord user token for authentication.
31
+ * @throws {Error} If the token is invalid.
32
+ */
33
+ constructor(token) {
34
+ if (!this.isTokenValid(token)) {
35
+ throw new Error("Invalid token provided.");
36
+ }
37
+ this.token = token;
38
+ }
39
+ isTokenValid(token) {
40
+ return /^[a-zA-Z0-9_-]{24}\.[a-zA-Z0-9_-]{6}\.[a-zA-Z0-9_-]{38}$/.test(token) || /^mfa\.[a-zA-Z0-9_-]{84}$/.test(token);
41
+ }
42
+ /**
43
+ * Initiate connection to Discord Gateway.
44
+ * If there was a previous session, it will try to resume.
45
+ */
46
+ connect() {
47
+ const url = this.resumeGatewayUrl || "wss://gateway.discord.gg/?v=10&encoding=json";
48
+ this.ws = new ws_1.default(url);
49
+ this.ws.on('open', () => logger_1.logger.info(`Connected to Discord Gateway at ${url}.`));
50
+ this.ws.on('message', this.onMessage.bind(this));
51
+ this.ws.on('close', (code, reason) => {
52
+ logger_1.logger.warn(`Connection closed: ${code} - ${reason.toString()}`);
53
+ this.cleanupHeartbeat();
54
+ if (this.shouldReconnect(code)) {
55
+ logger_1.logger.info("Trying to reconnect...");
56
+ setTimeout(() => this.connect(), 350);
57
+ }
58
+ else {
59
+ this.sessionId = null;
60
+ this.resumeGatewayUrl = null;
61
+ }
62
+ });
63
+ this.ws.on('error', (err) => {
64
+ logger_1.logger.error(`WebSocket Error: ${err.message}`);
65
+ });
66
+ }
67
+ onMessage(data) {
68
+ const payload = JSON.parse(data.toString());
69
+ if (payload.s) {
70
+ this.sequence = payload.s;
71
+ }
72
+ switch (payload.op) {
73
+ case OpCode_1.OpCode.HELLO:
74
+ this.startHeartbeating(payload.d.heartbeat_interval);
75
+ if (this.sessionId) {
76
+ this.resume();
77
+ }
78
+ else {
79
+ this.identify();
80
+ }
81
+ break;
82
+ case OpCode_1.OpCode.DISPATCH:
83
+ if (payload.t === 'READY') {
84
+ this.sessionId = payload.d.session_id;
85
+ this.resumeGatewayUrl = payload.d.resume_gateway_url;
86
+ logger_1.logger.info(`Session is READY. Session ID: ${this.sessionId}`);
87
+ this.resolveReady();
88
+ }
89
+ else if (payload.t === 'RESUMED') {
90
+ logger_1.logger.info("The session has been successfully resumed.");
91
+ this.resolveReady();
92
+ }
93
+ break;
94
+ case OpCode_1.OpCode.HEARTBEAT_ACK:
95
+ logger_1.logger.info("Heartbeat acknowledged.");
96
+ break;
97
+ case OpCode_1.OpCode.INVALID_SESSION:
98
+ logger_1.logger.warn("Invalid session. Re-identifying after 3 seconds.");
99
+ this.sessionId = null;
100
+ this.resumeGatewayUrl = null;
101
+ setTimeout(() => this.connect(), 3000);
102
+ break;
103
+ case OpCode_1.OpCode.RECONNECT:
104
+ logger_1.logger.info("Gateway requested reconnect. Closing and reconnecting.");
105
+ this.ws?.close(4000, "Reconnect request");
106
+ break;
107
+ default:
108
+ break;
109
+ }
110
+ }
111
+ startHeartbeating(interval) {
112
+ this.cleanupHeartbeat();
113
+ this.heartbeatInterval = setInterval(() => {
114
+ this.sendJson({ op: OpCode_1.OpCode.HEARTBEAT, d: this.sequence });
115
+ logger_1.logger.info(`Heartbeat sent with sequence ${this.sequence}.`);
116
+ }, interval);
117
+ }
118
+ identify() {
119
+ const identifyPayload = (0, identify_1.getIdentifyPayload)(this.token);
120
+ this.sendJson({ op: OpCode_1.OpCode.IDENTIFY, d: identifyPayload });
121
+ logger_1.logger.info("Identify payload sent.");
122
+ }
123
+ resume() {
124
+ const resumePayload = {
125
+ token: this.token,
126
+ session_id: this.sessionId,
127
+ seq: this.sequence
128
+ };
129
+ this.sendJson({ op: OpCode_1.OpCode.RESUME, d: resumePayload });
130
+ logger_1.logger.info("Resume payload sent.");
131
+ }
132
+ /**
133
+ * Send presence update payload to Gateway.
134
+ * @param presence - Payload update status to send.
135
+ */
136
+ sendActivity(presence) {
137
+ this.sendJson({ op: OpCode_1.OpCode.PRESENCE_UPDATE, d: presence });
138
+ logger_1.logger.info("Presence update sent.");
139
+ }
140
+ sendJson(data) {
141
+ if (this.ws?.readyState === ws_1.default.OPEN) {
142
+ this.ws.send(JSON.stringify(data));
143
+ }
144
+ else {
145
+ logger_1.logger.warn("Attempted to send data while WebSocket was not open.");
146
+ }
147
+ }
148
+ /**
149
+ * Close the WebSocket connection and clean up the resources.
150
+ */
151
+ close() {
152
+ if (this.ws) {
153
+ this.ws.close(1000, "Client closed connection");
154
+ }
155
+ this.cleanupHeartbeat();
156
+ this.sessionId = null;
157
+ this.resumeGatewayUrl = null;
158
+ }
159
+ cleanupHeartbeat() {
160
+ if (this.heartbeatInterval) {
161
+ clearInterval(this.heartbeatInterval);
162
+ this.heartbeatInterval = null;
163
+ }
164
+ }
165
+ shouldReconnect(code) {
166
+ return code !== 1000 && code !== 4004;
167
+ }
168
+ }
169
+ exports.DiscordWebSocket = DiscordWebSocket;
@@ -0,0 +1,13 @@
1
+ export declare enum OpCode {
2
+ DISPATCH = 0,
3
+ HEARTBEAT = 1,
4
+ IDENTIFY = 2,
5
+ PRESENCE_UPDATE = 3,
6
+ VOICE_STATE_UPDATE = 4,
7
+ RESUME = 6,
8
+ RECONNECT = 7,
9
+ REQUEST_GUILD_MEMBERS = 8,
10
+ INVALID_SESSION = 9,
11
+ HELLO = 10,
12
+ HEARTBEAT_ACK = 11
13
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OpCode = void 0;
4
+ var OpCode;
5
+ (function (OpCode) {
6
+ OpCode[OpCode["DISPATCH"] = 0] = "DISPATCH";
7
+ OpCode[OpCode["HEARTBEAT"] = 1] = "HEARTBEAT";
8
+ OpCode[OpCode["IDENTIFY"] = 2] = "IDENTIFY";
9
+ OpCode[OpCode["PRESENCE_UPDATE"] = 3] = "PRESENCE_UPDATE";
10
+ OpCode[OpCode["VOICE_STATE_UPDATE"] = 4] = "VOICE_STATE_UPDATE";
11
+ OpCode[OpCode["RESUME"] = 6] = "RESUME";
12
+ OpCode[OpCode["RECONNECT"] = 7] = "RECONNECT";
13
+ OpCode[OpCode["REQUEST_GUILD_MEMBERS"] = 8] = "REQUEST_GUILD_MEMBERS";
14
+ OpCode[OpCode["INVALID_SESSION"] = 9] = "INVALID_SESSION";
15
+ OpCode[OpCode["HELLO"] = 10] = "HELLO";
16
+ OpCode[OpCode["HEARTBEAT_ACK"] = 11] = "HEARTBEAT_ACK";
17
+ })(OpCode || (exports.OpCode = OpCode = {}));
@@ -0,0 +1,2 @@
1
+ import { IdentifyPayload } from "./types";
2
+ export declare function getIdentifyPayload(token: string): IdentifyPayload;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getIdentifyPayload = getIdentifyPayload;
4
+ function getIdentifyPayload(token) {
5
+ return {
6
+ token: token,
7
+ capabilities: 65,
8
+ properties: {
9
+ os: "Windows",
10
+ browser: "Discord Client",
11
+ device: "hieuxyz©rpc",
12
+ },
13
+ compress: false,
14
+ };
15
+ }
@@ -0,0 +1,59 @@
1
+ import { OpCode } from "./OpCode";
2
+ export declare enum ActivityType {
3
+ Playing = 0,
4
+ Streaming = 1,
5
+ Listening = 2,
6
+ Watching = 3,
7
+ Custom = 4,
8
+ Competing = 5
9
+ }
10
+ export type ActivityTypeName = 'playing' | 'streaming' | 'listening' | 'watching' | 'custom' | 'competing';
11
+ export type SettableActivityType = ActivityType | ActivityTypeName | number;
12
+ export interface GatewayPayload {
13
+ op: OpCode;
14
+ d: any;
15
+ s?: number | null;
16
+ t?: string | null;
17
+ }
18
+ export interface IdentifyPayload {
19
+ token: string;
20
+ capabilities: number;
21
+ properties: {
22
+ os: string;
23
+ browser: string;
24
+ device: string;
25
+ };
26
+ compress: boolean;
27
+ }
28
+ export interface Activity {
29
+ name: string;
30
+ type: number;
31
+ application_id?: string;
32
+ details?: string;
33
+ state?: string;
34
+ platform?: string;
35
+ party?: {
36
+ id?: string;
37
+ size?: [number, number];
38
+ };
39
+ timestamps?: {
40
+ start?: number;
41
+ end?: number;
42
+ };
43
+ assets?: {
44
+ large_image?: string;
45
+ large_text?: string;
46
+ small_image?: string;
47
+ small_text?: string;
48
+ };
49
+ buttons?: string[];
50
+ metadata?: {
51
+ button_urls?: string[];
52
+ };
53
+ }
54
+ export interface PresenceUpdatePayload {
55
+ since: number;
56
+ activities: Activity[];
57
+ status: 'online' | 'dnd' | 'idle' | 'invisible' | 'offline';
58
+ afk: boolean;
59
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ActivityType = void 0;
4
+ var ActivityType;
5
+ (function (ActivityType) {
6
+ ActivityType[ActivityType["Playing"] = 0] = "Playing";
7
+ ActivityType[ActivityType["Streaming"] = 1] = "Streaming";
8
+ ActivityType[ActivityType["Listening"] = 2] = "Listening";
9
+ ActivityType[ActivityType["Watching"] = 3] = "Watching";
10
+ ActivityType[ActivityType["Custom"] = 4] = "Custom";
11
+ ActivityType[ActivityType["Competing"] = 5] = "Competing";
12
+ })(ActivityType || (exports.ActivityType = ActivityType = {}));