linkdave 0.2.0-dev.67c58c7 → 0.2.0-dev.db8ab4a

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/dist/client.js CHANGED
@@ -63,8 +63,8 @@ export class LinkDaveClient extends EventEmitter {
63
63
  if (!node.connected || node.draining) {
64
64
  continue;
65
65
  }
66
- if (node.playerCount < lowestCount) {
67
- lowestCount = node.playerCount;
66
+ if (node.stats.players < lowestCount) {
67
+ lowestCount = node.stats.players;
68
68
  bestNode = node;
69
69
  }
70
70
  }
package/dist/node.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from "node:events";
2
2
  import { RESTClient } from "./rest.js";
3
- import type { Events, PlayPayload, SeekPayload, VoiceUpdatePayload } from "./types.js";
3
+ import type { Events, PlayPayload, SeekPayload, StatsPayload, VoiceUpdatePayload } from "./types.js";
4
4
  export interface NodeOptions {
5
5
  name: string;
6
6
  url: string;
@@ -31,7 +31,7 @@ export declare class Node extends EventEmitter {
31
31
  disconnect(): void;
32
32
  get state(): NodeState;
33
33
  get sessionId(): string | null;
34
- get playerCount(): number;
34
+ get stats(): StatsPayload;
35
35
  get draining(): boolean;
36
36
  get connected(): boolean;
37
37
  incrementPlayerCount(): void;
package/dist/node.js CHANGED
@@ -20,7 +20,7 @@ export class Node extends EventEmitter {
20
20
  #reconnectAttempts = 0;
21
21
  #reconnectTimeout = null;
22
22
  #state = NodeState.Disconnected;
23
- #playerCount = 0;
23
+ #stats = { players: 0, playing_tracks: 0, uptime: 0, memory: 0 };
24
24
  constructor(options) {
25
25
  super();
26
26
  this.name = options.name;
@@ -80,8 +80,8 @@ export class Node extends EventEmitter {
80
80
  get sessionId() {
81
81
  return this.#sessionId;
82
82
  }
83
- get playerCount() {
84
- return this.#playerCount;
83
+ get stats() {
84
+ return this.#stats;
85
85
  }
86
86
  get draining() {
87
87
  return this.state === NodeState.Draining;
@@ -90,12 +90,12 @@ export class Node extends EventEmitter {
90
90
  return this.#state === NodeState.Connected || this.#state === NodeState.Draining;
91
91
  }
92
92
  incrementPlayerCount() {
93
- this.#playerCount++;
93
+ this.#stats.players++;
94
94
  }
95
95
  decrementPlayerCount() {
96
- if (this.#playerCount > 0) {
97
- this.#playerCount--;
98
- }
96
+ if (this.#stats.players <= 0)
97
+ return;
98
+ this.#stats.players--;
99
99
  }
100
100
  #onMessage(event) {
101
101
  try {
@@ -131,8 +131,7 @@ export class Node extends EventEmitter {
131
131
  this.emit(EventName.VoiceDisconnect, message.d);
132
132
  break;
133
133
  case ServerOpCodes.Stats:
134
- this.#playerCount = message.d.players;
135
- this.#state = message.d.draining ? NodeState.Draining : NodeState.Connected;
134
+ this.#stats = message.d;
136
135
  this.emit(EventName.Stats, message.d);
137
136
  break;
138
137
  case ServerOpCodes.NodeDraining:
package/dist/types.d.ts CHANGED
@@ -160,7 +160,6 @@ export interface StatsPayload {
160
160
  playing_tracks: number;
161
161
  uptime: number;
162
162
  memory: number;
163
- draining: boolean;
164
163
  }
165
164
  export interface PlayerMigratePayload {
166
165
  guild_id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linkdave",
3
- "version": "0.2.0-dev.67c58c7",
3
+ "version": "0.2.0-dev.db8ab4a",
4
4
  "author": "Luna Seemann <luna@wamellow.com> (http://shi.gg)",
5
5
  "description": "TypeScript client library for linkdave Discord audio streaming server",
6
6
  "repository": {