poru 1.0.3 → 1.0.6

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 CHANGED
@@ -19,10 +19,10 @@
19
19
 
20
20
  ## Table of contents
21
21
 
22
- - [Documentation](https://gorillas-team.github.io/Gorilink/)
22
+ - [Documentation](https://poru.parasdocs.tech)
23
23
  - [Installation](#installation)
24
24
  - [About](#about)
25
- - [Example](#example-usage-basic-bot)
25
+ - [Example](https://github.com/parasop/poru-example)
26
26
 
27
27
  # Installation
28
28
  ```
@@ -42,10 +42,72 @@ To use you need a configured [Lavalink](https://github.com/Frederikam/Lavalink)
42
42
  - 100% Customizable
43
43
  - Easy to setup
44
44
 
45
+ ## Implementation
46
+ [Poru Music](https://github.com/parasop/poru-example) **Example bot as guide for beginning.**
47
+
48
+
45
49
  ## Example usage basic bot
46
50
  ```javascript
47
- // adding soon
51
+ // main file
52
+ // Require both libraries
53
+ const { Client } = require("discord.js");
54
+ const { Poru } = require("poru");
55
+
56
+ // Initiate both main classes
57
+ const client = new Client();
58
+
59
+ // Define some options for the node
60
+ const nodes = [
61
+ {
62
+ host: "localhost",
63
+ password: "youshallnotpass",
64
+ port: 2333,
65
+ secure:false
66
+ }
67
+ ];
68
+
69
+ // Assign Manager to the client variable
70
+ client.poru = new Poru(client,nodes);
71
+
72
+ // Emitted whenever a node connects
73
+ client.poru.on("nodeConnect", node => {
74
+ console.log(`Node "${node.name}" connected.`)
75
+ })
76
+
77
+ // Emitted whenever a node encountered an error
78
+ client.poru.on("nodeError", (node, error) => {
79
+ console.log(`Node "${node.name}" encountered an error`)
80
+ })
81
+
82
+ // Listen for when the client becomes ready
83
+ client.once("ready", () => {
84
+ client.poru.init(client;
85
+ console.log(`Logged in as ${client.user.tag}`);
86
+ });
87
+
88
+ // THIS IS REQUIRED. Send raw events to Erela.js
89
+ client.on("raw",async d => await client.poru.packetUpdate(d));
90
+
91
+ // Finally login at the END of your code
92
+ client.login("your bot token here");
93
+
94
+
95
+ ```
96
+
97
+
98
+ ```javascript
99
+ // creating player
100
+ const player = await client.poru.createConnection({
101
+ guild: message.guild.id,
102
+ voiceChannel: message.member.voice.channel.id,
103
+ textChannel: message.channel,
104
+ selfDeaf: true,
105
+ selfMute: false,
106
+ })
107
+ // Getting tracks
108
+ const resolve = await client.poru.resolve('Ignite',"yt");
48
109
  ```
49
110
 
50
111
  ## Need Help?
51
- If you do not understand something in the documentation or have any questions, please join our [My disocrd server ](https://discord.gg/Zmmc47Nrh8)
112
+ Feel free to join our [discord server](https://discord.gg/Zmmc47Nrh8), Give us suggestions and advice about errors and new features.
113
+ with ❤️ by [Paras](https://github.com/parasop) .
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poru",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
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
@@ -106,13 +106,29 @@ message(payload) {
106
106
  * Fire up when node return an error
107
107
  * @event nodeError
108
108
  */
109
- this.manager.emit("nodeError", event, this);
109
+ this.manager.emit("nodeError", this, event);
110
110
  return this.reconnect();
111
111
  }
112
112
 
113
+ destroy(){
114
+ if(!this.isConnected) return;
115
+
116
+ const players = this.manager.players.filter(p => p.node == this);
117
+ if (players.size) players.forEach(p => p.destroy());
118
+ this.ws.close(1000, "destroy");
119
+ this.ws.removeAllListeners();
120
+ this.ws = null;
121
+ this.reconnect = 1;
122
+ this.manager.nodes.delete(this.host)
123
+ this.manager.emit("nodeDestroy", this);
124
+
125
+
126
+ }
127
+
113
128
  reconnect() {
114
- this.reconnect = setTimeout(() => {
115
- this.connected = false;
129
+ this.reconnect++;
130
+ setTimeout(() => {
131
+ this.isConnected = false;
116
132
  this.ws.removeAllListeners();
117
133
  this.ws = null;
118
134
  this.manager.emit("nodeReconnect", this);
package/src/Player.js CHANGED
@@ -6,8 +6,11 @@ class Player extends EventEmitter {
6
6
  super();
7
7
 
8
8
  this.manager = manager;
9
- this.queue = new Queue()
9
+
10
+ this.queue = new Queue();
11
+
10
12
  this.node = node;
13
+
11
14
  this.filters = new Filters(this, this.node)
12
15
 
13
16
 
@@ -32,7 +35,7 @@ class Player extends EventEmitter {
32
35
 
33
36
  this.timestamp = Date.now();
34
37
 
35
- this.pause = false;
38
+ this.paused = false;
36
39
  this.position = 0;
37
40
 
38
41
 
@@ -46,9 +49,6 @@ class Player extends EventEmitter {
46
49
 
47
50
 
48
51
 
49
-
50
-
51
-
52
52
  this.on("event", (data) => (this.lavalinkEvent(data).bind(this))());
53
53
  this.on("event", (data) => this.manager.emit("debug", data))
54
54
  this.on("playerUpdate", (packet) => {
@@ -58,7 +58,9 @@ class Player extends EventEmitter {
58
58
  volume: this.state.volume,
59
59
  equalizer: this.state.equalizer,
60
60
  ...packet.state,
61
+
61
62
  };
63
+ this.manager.emit("playerUpdate", this, packet);
62
64
  });
63
65
  }
64
66
  async play() {
@@ -250,7 +252,7 @@ class Player extends EventEmitter {
250
252
  TrackStartEvent() {
251
253
  this.playing = true;
252
254
  this.paused = false;
253
- this.manager.emit("trackStart", this, this.currentTrack);
255
+ this.manager.emit("trackStart", this, this.currentTrack, data);
254
256
  },
255
257
  // eslint-disable-next-line consistent-return
256
258
  TrackEndEvent() {
package/src/Poru.js CHANGED
@@ -38,6 +38,12 @@ class Poru extends EventEmitter {
38
38
  return node;
39
39
  }
40
40
 
41
+ deleteNode(identifier){
42
+ const node = this.nodes.get(identifier);
43
+ if (!node) return;
44
+ node.destroy();
45
+ this.nodes.delete(identifier)
46
+ }
41
47
  //create connection with discord voice channel
42
48
  createConnection(data = {}, options = {}) {
43
49
  const player = this.players.get(data.guild.id || data.guild);
@@ -56,6 +62,8 @@ class Poru extends EventEmitter {
56
62
  return this.Player(data);
57
63
  }
58
64
 
65
+
66
+
59
67
  init(client) {
60
68
 
61
69
  this.user =client.user.id;