Skip to content

Commit

Permalink
expose session data
Browse files Browse the repository at this point in the history
  • Loading branch information
Starman3787 committed Nov 15, 2024
1 parent 0338c18 commit 88adb8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/gateway/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 88adb8d

Please sign in to comment.