poru 3.0.0 → 3.0.1

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.
@@ -0,0 +1,13 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: parasdev
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
13
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
package/README.md CHANGED
@@ -50,37 +50,45 @@ To use you need a configured [Lavalink](https://github.com/Frederikam/Lavalink)
50
50
  ## Example usage basic bot
51
51
 
52
52
  ```javascript
53
- const { Client } = require('discord.js');
54
- const { Poru } = require('poru');
53
+ const { Client, GatewayIntentBits } = require('discord.js');
54
+ const { Poru } = require('poru');
55
55
  const nodes = [
56
- {
57
- id: "main_node",
58
- hostname:"localhost",
59
- port: 8080,
60
- password: "iloveyou3000"
61
- }
56
+ {
57
+ id: "main_node",
58
+ hostname: "localhost",
59
+ port: 8080,
60
+ password: "iloveyou3000"
61
+ }
62
+ ]
63
+ const PoruOptions = {
64
+ reconnectTime: 0,
65
+ resumeKey: 'MyPlayers',
66
+ resumeTimeout: 60,
67
+ defaultPlatform: "ytsearch"
68
+ }
69
+ const client = new Client({
70
+ intents: [
71
+ GatewayIntentBits.Guilds,
72
+ GatewayIntentBits.GuildMessages,
73
+ GatewayIntentBits.GuildVoiceStates,
74
+ GatewayIntentBits.MessageContent
62
75
  ]
63
-
64
- const client = new Client();
65
-
66
- client.poru = new Poru(client,nodes,PoruOptions)
67
-
68
-
76
+ });
77
+ client.poru = new Poru(client, nodes, PoruOptions)
69
78
 
70
79
  client.poru.on('trackStart', (player, track) => {
71
-
72
- player.textChannel.send(`Now playing \`${track.title}\``);
80
+ const channel = client.channels.cache.get(player.textChannel);
81
+ return channel.send(`Now playing \`${track.title}\``);
73
82
  });
74
83
 
75
-
76
84
  client.on('ready', () => {
77
85
  console.log('Ready!');
78
86
  client.poru.init(client);
79
87
  });
80
88
 
81
89
 
82
- client.on('interactionCreate', async interaction => {
83
- if (!interaction.isCommand()) return;
90
+ client.on('interactionCreate', async (interaction) => {
91
+ if (!interaction.isChatInputCommand()) return;
84
92
  if (!interaction.member.voice.channel) return interaction.reply({ content: `Please connect with voice channel `, ephemeral: true });
85
93
 
86
94
  const track = interaction.options.getString('track');
@@ -88,7 +96,7 @@ client.on('interactionCreate', async interaction => {
88
96
  const res = await client.poru.resolve(track);
89
97
 
90
98
  if (res.loadType === "LOAD_FAILED") {
91
- return interaction.reply(`Failed to load track`);
99
+ return interaction.reply('Failed to load track.');
92
100
  } else if (res.loadType === "NO_MATCHES") {
93
101
  return interaction.reply('No source found!');
94
102
  }
@@ -97,14 +105,14 @@ client.on('interactionCreate', async interaction => {
97
105
  const player = client.poru.createConnection({
98
106
  guildId: interaction.guild.id,
99
107
  voiceChannel: interaction.member.voice.channelId,
100
- textChannel: interaction.channel,
101
- deaf: true
108
+ textChannel: interaction.channel.id,
109
+ selfDeaf: true
102
110
  });
103
111
 
104
112
 
105
113
  if (res.loadType === 'PLAYLIST_LOADED') {
106
114
  for (const track of res.tracks) {
107
- trackk.info.requester = interaction.user;
115
+ track.info.requester = interaction.user;
108
116
  player.queue.add(track);
109
117
  }
110
118
 
@@ -119,7 +127,8 @@ client.on('interactionCreate', async interaction => {
119
127
  if (!player.isPlaying && player.isConnected) player.play();
120
128
  });
121
129
 
122
- client.login('TOKEN');```
130
+ client.login('TOKEN');
131
+ ```
123
132
 
124
133
  ## Need Help?
125
134
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poru",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "A stable and powefull lavalink client with so many features",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/Player.js CHANGED
@@ -41,7 +41,7 @@ class Player extends EventEmitter {
41
41
 
42
42
  this.currentTrack = {};
43
43
 
44
- this.previousTrack = {};
44
+ this.previousTrack = null;
45
45
 
46
46
  this.voiceUpdateState = null;
47
47
 
@@ -273,7 +273,7 @@ class Player extends EventEmitter {
273
273
  const events = {
274
274
  TrackStartEvent() {
275
275
  this.isPlaying = true;
276
- this.paused = false;
276
+ this.isPaused = false;
277
277
  this.manager.emit("trackStart", this, this.currentTrack, data);
278
278
  },
279
279
  // eslint-disable-next-line consistent-return
@@ -295,21 +295,25 @@ class Player extends EventEmitter {
295
295
  }
296
296
 
297
297
  if (this.queue.length === 0) {
298
- return this.manager.emit("queueEnd", this, this.track, data);
298
+ this.manager.emit("queueEnd",this, this.track, data);
299
+ return this.destroy();
300
+
299
301
  } else if (this.queue.length > 0) {
300
302
  this.manager.emit("trackEnd", this, this.currentTrack, data)
301
303
  return this.play();
302
304
  }
303
- this.manager.emit("queueEnd", this, this.track, data);
305
+ this.manager.emit("queueEnd", this, this.currentTrack, data);
306
+ this.destroy();
304
307
 
305
308
  },
306
309
  TrackStuckEvent() {
307
- this.queue.shift();
308
- this.manager.emit("trackError", this, this.track, data);
310
+ this.manager.emit("trackError", this,this.currentTrack, data);
311
+ this.stop();
312
+
309
313
  },
310
314
  TrackExceptionEvent() {
311
- this.queue.shift();
312
315
  this.manager.emit("trackError", this, this.track, data);
316
+ this.stop();
313
317
  },
314
318
  WebSocketClosedEvent() {
315
319
  if ([4015, 4009].includes(data.code)) {
package/src/Poru.js CHANGED
@@ -11,7 +11,7 @@ class Poru extends EventEmitter {
11
11
  constructor(client, nodes, options = {}) {
12
12
  super();
13
13
  if (!client) throw new Error("[Poru Error] You didn't provide a valid client");
14
- if (!nodes) throw new Error("[Poru Error] You did't provide a lavalink node");
14
+ if (!nodes) throw new Error("[Poru Error] You didn't provide a lavalink node");
15
15
 
16
16
  this.client = client;
17
17
  this._nodes = nodes;
@@ -17,8 +17,36 @@ class Filters {
17
17
  }
18
18
 
19
19
 
20
- setEqualizer(bands){
21
- this.equalizer = bands;
20
+ setEqualizer(band,gain){
21
+ this.band = band || this.band;
22
+ this.gain = gain || this.gain;
23
+
24
+ this.equalizer = [
25
+ {
26
+ band: this.band,
27
+ gain: this.gain,
28
+ },
29
+ {
30
+ band: this.band,
31
+ gain: this.gain,
32
+ },
33
+ {
34
+ band: this.band,
35
+ gain: this.gain,
36
+ },
37
+ {
38
+ band: this.band,
39
+ gain: this.gain,
40
+ },
41
+ {
42
+ band: this.band,
43
+ gain: this.gain,
44
+ },
45
+ {
46
+ band: this.band,
47
+ gain: this.gain,
48
+ },
49
+ ]
22
50
  this.updateFilters();
23
51
  return this;
24
52
  }
@@ -130,13 +158,7 @@ class Filters {
130
158
  if (!this.player) return;
131
159
  this.bassboost = !!val;
132
160
  this.bassboost = val / 100;
133
- this.setEqualizer(
134
- val
135
- ? Array(6)
136
- .fill(0.22)
137
- .map((x, i) => ({ band: i, gain: x * val }))
138
- : []
139
- );
161
+ this.setEqualizer(1,0.90);
140
162
  }
141
163
 
142
164
  updateFilters(){
@@ -3,7 +3,7 @@ const {fetch} = require("undici")
3
3
  let spotifyPattern =
4
4
  /^(?:https:\/\/open\.spotify\.com\/(?:user\/[A-Za-z0-9]+\/)?|spotify:)(album|playlist|track|artist)(?:[/:])([A-Za-z0-9]+).*$/;
5
5
 
6
- const Track = require("../guild/Track")
6
+ const PoruTrack = require("../guild/PoruTrack")
7
7
 
8
8
  class Spotify {
9
9
  constructor(manager) {
@@ -223,7 +223,7 @@ class Spotify {
223
223
  async buildUnresolved(track) {
224
224
  if (!track) throw new ReferenceError('The Spotify track object was not provided');
225
225
 
226
- return new Track({
226
+ return new PoruTrack({
227
227
  track: '',
228
228
  info: {
229
229
  sourceName: 'spotify',