poru 1.0.8 → 1.0.9

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.
Files changed (3) hide show
  1. package/package.json +1 -1
  2. package/src/Node.js +11 -11
  3. package/src/Poru.js +2 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poru",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "A stable and powefull lavalink client with so many features",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Node.js CHANGED
@@ -14,7 +14,9 @@ class Node {
14
14
  this.ws = null;
15
15
  this.reconnectTime = 50000;
16
16
  this.resumeKey = options.resumeKey || null;
17
- this._resumeTimeout = options.resumeTimeout || 60
17
+ this._resumeTimeout = options.resumeTimeout || 60;
18
+ this.reconnectAttempt;
19
+ this.reconnects = 0;
18
20
  this.queue = [];
19
21
  this.isConnected = false;
20
22
  this.stats = {
@@ -55,9 +57,9 @@ class Node {
55
57
 
56
58
 
57
59
  open(){
58
- if (this.reconnect) {
59
- clearTimeout(this.reconnect);
60
- delete this.reconnect;
60
+ if (this.reconnectAttempt) {
61
+ clearTimeout(this.reconnectAttempt);
62
+ delete this.reconnectAttempt;
61
63
  }
62
64
 
63
65
  this.queue =[];
@@ -88,13 +90,11 @@ message(payload) {
88
90
  }
89
91
 
90
92
  close(event) {
91
- // if (!event) return "Unknown event";
92
- /**
93
- * Fire up when node disconnect
94
- * @event nodeClosed
95
- */
96
93
  this.manager.emit("nodeClose", event, this);
97
- if (event !== 1000) return this.reconnect();
94
+ if (event !== 1000){
95
+
96
+ return this.reconnect();
97
+ }
98
98
  }
99
99
 
100
100
 
@@ -125,7 +125,7 @@ destroy(){
125
125
  }
126
126
 
127
127
  reconnect() {
128
- this.reconnect = setTimeout(() => {
128
+ this.reconnectAttempt = setTimeout(() => {
129
129
  this.isConnected = false;
130
130
  this.ws.removeAllListeners();
131
131
  this.ws = null;
package/src/Poru.js CHANGED
@@ -131,10 +131,10 @@ class Poru extends EventEmitter {
131
131
  const guild = data.guild.id || data.guild;
132
132
  const Nodes = this.nodes.get(guild);
133
133
  if (Nodes) return Nodes;
134
- if (this.leastUsedNodes.length === 0) throw new Error("No nodes are avaliable");
134
+ if (this.leastUsedNodes.length === 0) throw new Error("[Poru Error] No nodes are avaliable");
135
135
  const node = this.nodes.get(this.leastUsedNodes[0].name
136
136
  || this.leastUsedNodes[0].host);
137
- if (!node) throw new Error("No nodes are avalible");
137
+ if (!node) throw new Error("[Poru Error] No nodes are avalible");
138
138
 
139
139
  // eslint-disable-next-line new-cap
140
140
  const player = new this.player(node, data, this);