poru 1.0.7 → 1.1.0
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/README.md +1 -1
- package/package.json +1 -1
- package/src/Node.js +11 -12
- package/src/Poru.js +2 -2
package/README.md
CHANGED
|
@@ -85,7 +85,7 @@ client.once("ready", () => {
|
|
|
85
85
|
console.log(`Logged in as ${client.user.tag}`);
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
//
|
|
88
|
+
// this event used to make connections upto date with lavalink
|
|
89
89
|
client.on("raw",async d => await client.poru.packetUpdate(d));
|
|
90
90
|
|
|
91
91
|
// Finally login at the END of your code
|
package/package.json
CHANGED
package/src/Node.js
CHANGED
|
@@ -12,10 +12,11 @@ class Node {
|
|
|
12
12
|
this.password = options.password ||"youshallnotpass"
|
|
13
13
|
this.secure = options.secure || false;
|
|
14
14
|
this.ws = null;
|
|
15
|
-
this.reconnect = options.reconnect || 10000;
|
|
16
15
|
this.reconnectTime = 50000;
|
|
17
16
|
this.resumeKey = options.resumeKey || null;
|
|
18
|
-
this._resumeTimeout = options.resumeTimeout || 60
|
|
17
|
+
this._resumeTimeout = options.resumeTimeout || 60;
|
|
18
|
+
this.reconnectAttempt;
|
|
19
|
+
this.reconnects = 0;
|
|
19
20
|
this.queue = [];
|
|
20
21
|
this.isConnected = false;
|
|
21
22
|
this.stats = {
|
|
@@ -56,9 +57,9 @@ class Node {
|
|
|
56
57
|
|
|
57
58
|
|
|
58
59
|
open(){
|
|
59
|
-
if (this.
|
|
60
|
-
clearTimeout(this.
|
|
61
|
-
delete this.
|
|
60
|
+
if (this.reconnectAttempt) {
|
|
61
|
+
clearTimeout(this.reconnectAttempt);
|
|
62
|
+
delete this.reconnectAttempt;
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
this.queue =[];
|
|
@@ -89,13 +90,11 @@ message(payload) {
|
|
|
89
90
|
}
|
|
90
91
|
|
|
91
92
|
close(event) {
|
|
92
|
-
// if (!event) return "Unknown event";
|
|
93
|
-
/**
|
|
94
|
-
* Fire up when node disconnect
|
|
95
|
-
* @event nodeClosed
|
|
96
|
-
*/
|
|
97
93
|
this.manager.emit("nodeClose", event, this);
|
|
98
|
-
if (event !== 1000)
|
|
94
|
+
if (event !== 1000){
|
|
95
|
+
|
|
96
|
+
return this.reconnect();
|
|
97
|
+
}
|
|
99
98
|
}
|
|
100
99
|
|
|
101
100
|
|
|
@@ -126,7 +125,7 @@ destroy(){
|
|
|
126
125
|
}
|
|
127
126
|
|
|
128
127
|
reconnect() {
|
|
129
|
-
this.
|
|
128
|
+
this.reconnectAttempt = setTimeout(() => {
|
|
130
129
|
this.isConnected = false;
|
|
131
130
|
this.ws.removeAllListeners();
|
|
132
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);
|