From 88adb8df510db7d23c1e09686149ef1d7295c647 Mon Sep 17 00:00:00 2001 From: Starman <30315137+Starman3787@users.noreply.github.com> Date: Fri, 15 Nov 2024 13:26:05 +0000 Subject: [PATCH] expose session data --- src/Client.js | 10 ++++++++++ src/gateway/index.js | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Client.js b/src/Client.js index 385d17db..c1cc82ba 100644 --- a/src/Client.js +++ b/src/Client.js @@ -334,6 +334,16 @@ class Client extends EventsEmitter { return this.#guilds; } + /** + * The session data for this client. + * @type {Object} + * @readonly + * @public + */ + get sessionData() { + return this.#shards.map((shard) => shard.getSessionData()); + } + /** * The function to call when a soft restart is needed. * @public diff --git a/src/gateway/index.js b/src/gateway/index.js index afd8c797..239beffd 100644 --- a/src/gateway/index.js +++ b/src/gateway/index.js @@ -208,6 +208,14 @@ class Shard { this.#ws.send(_updatePresence(name, type, status, afk, since)); } + getSessionData() { + return { + sessionId: this.#_sessionId, + sequence: this.#_s, + resumeGatewayUrl: this.#resumeGatewayUrl, + }; + } + #heartbeatInit() { setTimeout(() => { this.#heartbeat();