discord-player 5.2.1-dev → 5.2.3-dev

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
@@ -168,7 +168,7 @@ These bots are made by the community, they can help you build your own!
168
168
 
169
169
  ### Smooth Volume
170
170
 
171
- Discord Player will make volume transition smooth. To enable this, you need to add this line at the top of your main file:
171
+ Discord Player will by default try to implement this. If smooth volume does not work, you need to add this line at the top of your main file:
172
172
 
173
173
  ```js
174
174
  // CJS
package/dist/Player.js CHANGED
@@ -7,11 +7,11 @@ const tiny_typed_emitter_1 = require("tiny-typed-emitter");
7
7
  const Queue_1 = require("./Structures/Queue");
8
8
  const VoiceUtils_1 = require("./VoiceInterface/VoiceUtils");
9
9
  const types_1 = require("./types/types");
10
- const Track_1 = (0, tslib_1.__importDefault)(require("./Structures/Track"));
10
+ const Track_1 = tslib_1.__importDefault(require("./Structures/Track"));
11
11
  const QueryResolver_1 = require("./utils/QueryResolver");
12
- const youtube_sr_1 = (0, tslib_1.__importDefault)(require("youtube-sr"));
12
+ const youtube_sr_1 = tslib_1.__importDefault(require("youtube-sr"));
13
13
  const Util_1 = require("./utils/Util");
14
- const spotify_url_info_1 = (0, tslib_1.__importDefault)(require("spotify-url-info"));
14
+ const spotify_url_info_1 = tslib_1.__importDefault(require("spotify-url-info"));
15
15
  const PlayerError_1 = require("./Structures/PlayerError");
16
16
  const ytdl_core_1 = require("ytdl-core");
17
17
  const soundcloud_scraper_1 = require("soundcloud-scraper");
@@ -26,7 +26,7 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
26
26
  * @param {PlayerInitOptions} [options={}] The player init options
27
27
  */
28
28
  constructor(client, options = {}) {
29
- var _a;
29
+ var _a, _b, _c, _d, _e;
30
30
  super();
31
31
  this.options = {
32
32
  autoRegisterExtractor: true,
@@ -44,7 +44,7 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
44
44
  * @type {Client}
45
45
  */
46
46
  this.client = client;
47
- if (!new discord_js_1.Intents(this.client.options.intents).has(discord_js_1.Intents.FLAGS.GUILD_VOICE_STATES)) {
47
+ if (((_b = (_a = this.client) === null || _a === void 0 ? void 0 : _a.options) === null || _b === void 0 ? void 0 : _b.intents) && !new discord_js_1.Intents((_d = (_c = this.client) === null || _c === void 0 ? void 0 : _c.options) === null || _d === void 0 ? void 0 : _d.intents).has(discord_js_1.Intents.FLAGS.GUILD_VOICE_STATES)) {
48
48
  throw new PlayerError_1.PlayerError('client is missing "GUILD_VOICE_STATES" intent');
49
49
  }
50
50
  /**
@@ -53,7 +53,7 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
53
53
  */
54
54
  this.options = Object.assign(this.options, options);
55
55
  this.client.on("voiceStateUpdate", this._handleVoiceState.bind(this));
56
- if ((_a = this.options) === null || _a === void 0 ? void 0 : _a.autoRegisterExtractor) {
56
+ if ((_e = this.options) === null || _e === void 0 ? void 0 : _e.autoRegisterExtractor) {
57
57
  let nv; // eslint-disable-line @typescript-eslint/no-explicit-any
58
58
  if ((nv = Util_1.Util.require("@discord-player/extractor"))) {
59
59
  ["Attachment", "Facebook", "Reverbnation", "Vimeo"].forEach((ext) => void this.use(ext, nv[ext]));
@@ -71,14 +71,69 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
71
71
  const queue = this.getQueue(oldState.guild.id);
72
72
  if (!queue)
73
73
  return;
74
- if (oldState.channelId && newState.channelId && oldState.channelId !== newState.channelId) {
75
- if ((queue === null || queue === void 0 ? void 0 : queue.connection) && newState.member.id === newState.guild.me.id)
76
- queue.connection.channel = newState.channel;
77
- if (newState.member.id === newState.guild.me.id || (newState.member.id !== newState.guild.me.id && oldState.channelId === queue.connection.channel.id)) {
74
+ if (oldState.channelId && !newState.channelId && newState.member.id === newState.guild.me.id) {
75
+ try {
76
+ queue.destroy();
77
+ }
78
+ catch (_a) {
79
+ /* noop */
80
+ }
81
+ return void this.emit("botDisconnect", queue);
82
+ }
83
+ if (!oldState.channelId && newState.channelId && newState.member.id === newState.guild.me.id) {
84
+ if (newState.serverMute || !newState.serverMute) {
85
+ queue.setPaused(newState.serverMute);
86
+ }
87
+ else if (newState.suppress || !newState.suppress) {
88
+ if (newState.suppress)
89
+ newState.guild.me.voice.setRequestToSpeak(true).catch(Util_1.Util.noop);
90
+ queue.setPaused(newState.suppress);
91
+ }
92
+ }
93
+ if (oldState.channelId === newState.channelId && newState.member.id === newState.guild.me.id) {
94
+ if (oldState.serverMute !== newState.serverMute) {
95
+ queue.setPaused(newState.serverMute);
96
+ }
97
+ else if (oldState.suppress !== newState.suppress) {
98
+ if (newState.suppress)
99
+ newState.guild.me.voice.setRequestToSpeak(true).catch(Util_1.Util.noop);
100
+ queue.setPaused(newState.suppress);
101
+ }
102
+ }
103
+ if (queue.connection && !newState.channelId && oldState.channelId === queue.connection.channel.id) {
104
+ if (!Util_1.Util.isVoiceEmpty(queue.connection.channel))
105
+ return;
106
+ const timeout = setTimeout(() => {
78
107
  if (!Util_1.Util.isVoiceEmpty(queue.connection.channel))
79
108
  return;
109
+ if (!this.queues.has(queue.guild.id))
110
+ return;
111
+ if (queue.options.leaveOnEmpty)
112
+ queue.destroy();
113
+ this.emit("channelEmpty", queue);
114
+ }, queue.options.leaveOnEmptyCooldown || 0).unref();
115
+ queue._cooldownsTimeout.set(`empty_${oldState.guild.id}`, timeout);
116
+ }
117
+ if (queue.connection && newState.channelId && newState.channelId === queue.connection.channel.id) {
118
+ const emptyTimeout = queue._cooldownsTimeout.get(`empty_${oldState.guild.id}`);
119
+ const channelEmpty = Util_1.Util.isVoiceEmpty(queue.connection.channel);
120
+ if (!channelEmpty && emptyTimeout) {
121
+ clearTimeout(emptyTimeout);
122
+ queue._cooldownsTimeout.delete(`empty_${oldState.guild.id}`);
123
+ }
124
+ }
125
+ if (oldState.channelId && newState.channelId && oldState.channelId !== newState.channelId && newState.member.id === newState.guild.me.id) {
126
+ if (queue.connection && newState.member.id === newState.guild.me.id)
127
+ queue.connection.channel = newState.channel;
128
+ const emptyTimeout = queue._cooldownsTimeout.get(`empty_${oldState.guild.id}`);
129
+ const channelEmpty = Util_1.Util.isVoiceEmpty(queue.connection.channel);
130
+ if (!channelEmpty && emptyTimeout) {
131
+ clearTimeout(emptyTimeout);
132
+ queue._cooldownsTimeout.delete(`empty_${oldState.guild.id}`);
133
+ }
134
+ else {
80
135
  const timeout = setTimeout(() => {
81
- if (!Util_1.Util.isVoiceEmpty(queue.connection.channel))
136
+ if (queue.connection && !Util_1.Util.isVoiceEmpty(queue.connection.channel))
82
137
  return;
83
138
  if (!this.queues.has(queue.guild.id))
84
139
  return;
@@ -88,58 +143,6 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
88
143
  }, queue.options.leaveOnEmptyCooldown || 0).unref();
89
144
  queue._cooldownsTimeout.set(`empty_${oldState.guild.id}`, timeout);
90
145
  }
91
- if (!oldState.channelId && newState.channelId && newState.member.id === newState.guild.me.id) {
92
- if (newState.serverMute || !newState.serverMute) {
93
- queue.setPaused(newState.serverMute);
94
- }
95
- else if (newState.suppress || !newState.suppress) {
96
- if (newState.suppress)
97
- newState.guild.me.voice.setRequestToSpeak(true).catch(Util_1.Util.noop);
98
- queue.setPaused(newState.suppress);
99
- }
100
- }
101
- if (oldState.channelId === newState.channelId && oldState.member.id === newState.guild.me.id) {
102
- if (oldState.serverMute !== newState.serverMute) {
103
- queue.setPaused(newState.serverMute);
104
- }
105
- else if (oldState.suppress !== newState.suppress) {
106
- if (newState.suppress)
107
- newState.guild.me.voice.setRequestToSpeak(true).catch(Util_1.Util.noop);
108
- queue.setPaused(newState.suppress);
109
- }
110
- }
111
- if (oldState.member.id === this.client.user.id && !newState.channelId) {
112
- queue.destroy();
113
- return void this.emit("botDisconnect", queue);
114
- }
115
- if (!queue.connection || !queue.connection.channel)
116
- return;
117
- if (!oldState.channelId || newState.channelId) {
118
- const emptyTimeout = queue._cooldownsTimeout.get(`empty_${oldState.guild.id}`);
119
- const channelEmpty = Util_1.Util.isVoiceEmpty(queue.connection.channel);
120
- if (newState.channelId === queue.connection.channel.id) {
121
- if (!channelEmpty && emptyTimeout) {
122
- clearTimeout(emptyTimeout);
123
- queue._cooldownsTimeout.delete(`empty_${oldState.guild.id}`);
124
- }
125
- }
126
- }
127
- else {
128
- if (oldState.channelId === queue.connection.channel.id) {
129
- if (!Util_1.Util.isVoiceEmpty(queue.connection.channel))
130
- return;
131
- const timeout = setTimeout(() => {
132
- if (!Util_1.Util.isVoiceEmpty(queue.connection.channel))
133
- return;
134
- if (!this.queues.has(queue.guild.id))
135
- return;
136
- if (queue.options.leaveOnEmpty)
137
- queue.destroy();
138
- this.emit("channelEmpty", queue);
139
- }, queue.options.leaveOnEmptyCooldown || 0).unref();
140
- queue._cooldownsTimeout.set(`empty_${oldState.guild.id}`, timeout);
141
- }
142
- }
143
146
  }
144
147
  }
145
148
  /**
@@ -157,7 +160,7 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
157
160
  return this.queues.get(guild.id);
158
161
  const _meta = queueInitOptions.metadata;
159
162
  delete queueInitOptions["metadata"];
160
- (_a = queueInitOptions.volumeSmoothness) !== null && _a !== void 0 ? _a : (queueInitOptions.volumeSmoothness = 0.1);
163
+ (_a = queueInitOptions.volumeSmoothness) !== null && _a !== void 0 ? _a : (queueInitOptions.volumeSmoothness = 0.08);
161
164
  (_b = queueInitOptions.ytdlOptions) !== null && _b !== void 0 ? _b : (queueInitOptions.ytdlOptions = this.options.ytdlOptions);
162
165
  const queue = new Queue_1.Queue(this, guild, queueInitOptions);
163
166
  queue.metadata = _meta;
@@ -205,7 +208,7 @@ class Player extends tiny_typed_emitter_1.TypedEmitter {
205
208
  */
206
209
  search(query, options) {
207
210
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
208
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
211
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
209
212
  if (query instanceof Track_1.default)
210
213
  return { playlist: query.playlist || null, tracks: [query] };
211
214
  if (!options)
@@ -30,7 +30,7 @@ class ExtractorModel {
30
30
  */
31
31
  handle(query) {
32
32
  var _a, _b, _c;
33
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
33
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
34
34
  const data = yield this._raw.getInfo(query);
35
35
  if (!data)
36
36
  return null;
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Queue = void 0;
5
5
  const tslib_1 = require("tslib");
6
6
  const discord_js_1 = require("discord.js");
7
- const Track_1 = (0, tslib_1.__importDefault)(require("./Track"));
7
+ const Track_1 = tslib_1.__importDefault(require("./Track"));
8
8
  const types_1 = require("../types/types");
9
- const discord_ytdl_core_1 = (0, tslib_1.__importDefault)(require("discord-ytdl-core"));
9
+ const discord_ytdl_core_1 = tslib_1.__importDefault(require("discord-ytdl-core"));
10
10
  const voice_1 = require("@discordjs/voice");
11
11
  const Util_1 = require("../utils/Util");
12
- const youtube_sr_1 = (0, tslib_1.__importDefault)(require("youtube-sr"));
13
- const AudioFilters_1 = (0, tslib_1.__importDefault)(require("../utils/AudioFilters"));
12
+ const youtube_sr_1 = tslib_1.__importDefault(require("youtube-sr"));
13
+ const AudioFilters_1 = tslib_1.__importDefault(require("../utils/AudioFilters"));
14
14
  const PlayerError_1 = require("./PlayerError");
15
15
  class Queue {
16
16
  /**
@@ -105,7 +105,7 @@ class Queue {
105
105
  */
106
106
  get current() {
107
107
  var _a, _b;
108
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
108
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
109
109
  return;
110
110
  return (_b = (_a = this.connection.audioResource) === null || _a === void 0 ? void 0 : _a.metadata) !== null && _b !== void 0 ? _b : this.tracks[0];
111
111
  }
@@ -114,14 +114,14 @@ class Queue {
114
114
  * @type {boolean}
115
115
  */
116
116
  get destroyed() {
117
- return (0, tslib_1.__classPrivateFieldGet)(this, _Queue_destroyed, "f");
117
+ return tslib_1.__classPrivateFieldGet(this, _Queue_destroyed, "f");
118
118
  }
119
119
  /**
120
120
  * Returns current track
121
121
  * @returns {Track}
122
122
  */
123
123
  nowPlaying() {
124
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
124
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
125
125
  return;
126
126
  return this.current;
127
127
  }
@@ -131,44 +131,43 @@ class Queue {
131
131
  * @returns {Promise<Queue>}
132
132
  */
133
133
  connect(channel) {
134
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
135
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
134
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
135
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
136
136
  return;
137
137
  const _channel = this.guild.channels.resolve(channel);
138
138
  if (!["GUILD_STAGE_VOICE", "GUILD_VOICE"].includes(_channel === null || _channel === void 0 ? void 0 : _channel.type))
139
139
  throw new PlayerError_1.PlayerError(`Channel type must be GUILD_VOICE or GUILD_STAGE_VOICE, got ${_channel === null || _channel === void 0 ? void 0 : _channel.type}!`, PlayerError_1.ErrorStatusCode.INVALID_ARG_TYPE);
140
140
  const connection = yield this.player.voiceUtils.connect(_channel, {
141
- deaf: this.options.autoSelfDeaf,
142
- maxTime: this.player.options.connectionTimeout || 20000
141
+ deaf: this.options.autoSelfDeaf
143
142
  });
144
143
  this.connection = connection;
145
144
  if (_channel.type === "GUILD_STAGE_VOICE") {
146
- yield _channel.guild.me.voice.setSuppressed(false).catch(() => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
145
+ yield _channel.guild.me.voice.setSuppressed(false).catch(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
147
146
  return yield _channel.guild.me.voice.setRequestToSpeak(true).catch(Util_1.Util.noop);
148
147
  }));
149
148
  }
150
149
  this.connection.on("error", (err) => {
151
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
150
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
152
151
  return;
153
152
  this.player.emit("connectionError", this, err);
154
153
  });
155
154
  this.connection.on("debug", (msg) => {
156
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
155
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
157
156
  return;
158
157
  this.player.emit("debug", this, msg);
159
158
  });
160
159
  this.player.emit("connectionCreate", this, this.connection);
161
160
  this.connection.on("start", (resource) => {
162
161
  var _a;
163
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
162
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
164
163
  return;
165
164
  this.playing = true;
166
165
  if (!this._filtersUpdate && (resource === null || resource === void 0 ? void 0 : resource.metadata))
167
166
  this.player.emit("trackStart", this, (_a = resource === null || resource === void 0 ? void 0 : resource.metadata) !== null && _a !== void 0 ? _a : this.current);
168
167
  this._filtersUpdate = false;
169
168
  });
170
- this.connection.on("finish", (resource) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
171
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
169
+ this.connection.on("finish", (resource) => tslib_1.__awaiter(this, void 0, void 0, function* () {
170
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
172
171
  return;
173
172
  this.playing = false;
174
173
  if (this._filtersUpdate)
@@ -195,6 +194,9 @@ class Queue {
195
194
  return;
196
195
  }
197
196
  }));
197
+ yield this.player.voiceUtils.enterReady(this.connection.voiceConnection, {
198
+ maxTime: this.player.options.connectionTimeout || 30000
199
+ });
198
200
  return this;
199
201
  });
200
202
  }
@@ -205,7 +207,7 @@ class Queue {
205
207
  */
206
208
  destroy(disconnect = this.options.leaveOnStop) {
207
209
  var _a;
208
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
210
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
209
211
  return;
210
212
  if (this.connection)
211
213
  this.connection.end();
@@ -213,14 +215,14 @@ class Queue {
213
215
  (_a = this.connection) === null || _a === void 0 ? void 0 : _a.disconnect();
214
216
  this.player.queues.delete(this.guild.id);
215
217
  this.player.voiceUtils.cache.delete(this.guild.id);
216
- (0, tslib_1.__classPrivateFieldSet)(this, _Queue_destroyed, true, "f");
218
+ tslib_1.__classPrivateFieldSet(this, _Queue_destroyed, true, "f");
217
219
  }
218
220
  /**
219
221
  * Skips current track
220
222
  * @returns {boolean}
221
223
  */
222
224
  skip() {
223
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
225
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
224
226
  return;
225
227
  if (!this.connection)
226
228
  return false;
@@ -234,7 +236,7 @@ class Queue {
234
236
  * @returns {void}
235
237
  */
236
238
  addTrack(track) {
237
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
239
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
238
240
  return;
239
241
  if (!(track instanceof Track_1.default))
240
242
  throw new PlayerError_1.PlayerError("invalid track", PlayerError_1.ErrorStatusCode.INVALID_TRACK);
@@ -246,7 +248,7 @@ class Queue {
246
248
  * @param {Track[]} tracks Array of tracks to add
247
249
  */
248
250
  addTracks(tracks) {
249
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
251
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
250
252
  return;
251
253
  if (!tracks.every((y) => y instanceof Track_1.default))
252
254
  throw new PlayerError_1.PlayerError("invalid track", PlayerError_1.ErrorStatusCode.INVALID_TRACK);
@@ -259,7 +261,7 @@ class Queue {
259
261
  * @returns {boolean}
260
262
  */
261
263
  setPaused(paused) {
262
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
264
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
263
265
  return;
264
266
  if (!this.connection)
265
267
  return false;
@@ -272,7 +274,7 @@ class Queue {
272
274
  */
273
275
  setBitrate(bitrate) {
274
276
  var _a, _b, _c, _d;
275
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
277
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
276
278
  return;
277
279
  if (!((_b = (_a = this.connection) === null || _a === void 0 ? void 0 : _a.audioResource) === null || _b === void 0 ? void 0 : _b.encoder))
278
280
  return;
@@ -286,11 +288,11 @@ class Queue {
286
288
  * @returns {boolean}
287
289
  */
288
290
  setVolume(amount) {
289
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
291
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
290
292
  return;
291
293
  if (!this.connection)
292
294
  return false;
293
- (0, tslib_1.__classPrivateFieldSet)(this, _Queue_lastVolume, amount, "f");
295
+ tslib_1.__classPrivateFieldSet(this, _Queue_lastVolume, amount, "f");
294
296
  this.options.initialVolume = amount;
295
297
  return this.connection.setVolume(amount);
296
298
  }
@@ -300,7 +302,7 @@ class Queue {
300
302
  * @returns {boolean}
301
303
  */
302
304
  setRepeatMode(mode) {
303
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
305
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
304
306
  return;
305
307
  if (![types_1.QueueRepeatMode.OFF, types_1.QueueRepeatMode.QUEUE, types_1.QueueRepeatMode.TRACK, types_1.QueueRepeatMode.AUTOPLAY].includes(mode))
306
308
  throw new PlayerError_1.PlayerError(`Unknown repeat mode "${mode}"!`, PlayerError_1.ErrorStatusCode.UNKNOWN_REPEAT_MODE);
@@ -314,7 +316,7 @@ class Queue {
314
316
  * @type {number}
315
317
  */
316
318
  get volume() {
317
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
319
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
318
320
  return;
319
321
  if (!this.connection)
320
322
  return 100;
@@ -328,7 +330,7 @@ class Queue {
328
330
  * @type {number}
329
331
  */
330
332
  get streamTime() {
331
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
333
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
332
334
  return;
333
335
  if (!this.connection)
334
336
  return 0;
@@ -340,7 +342,7 @@ class Queue {
340
342
  return NC ? playbackTime * NC : VW ? playbackTime * VW : playbackTime;
341
343
  }
342
344
  set streamTime(time) {
343
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
345
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
344
346
  return;
345
347
  this.seek(time);
346
348
  }
@@ -349,7 +351,7 @@ class Queue {
349
351
  * @returns {AudioFilters}
350
352
  */
351
353
  getFiltersEnabled() {
352
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
354
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
353
355
  return;
354
356
  return AudioFilters_1.default.names.filter((x) => this._activeFilters.includes(x));
355
357
  }
@@ -358,7 +360,7 @@ class Queue {
358
360
  * @returns {AudioFilters}
359
361
  */
360
362
  getFiltersDisabled() {
361
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
363
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
362
364
  return;
363
365
  return AudioFilters_1.default.names.filter((x) => !this._activeFilters.includes(x));
364
366
  }
@@ -368,8 +370,8 @@ class Queue {
368
370
  * @returns {Promise<void>}
369
371
  */
370
372
  setFilters(filters) {
371
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
372
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
373
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
374
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
373
375
  return;
374
376
  if (!filters || !Object.keys(filters).length) {
375
377
  // reset filters
@@ -406,8 +408,8 @@ class Queue {
406
408
  * @returns {boolean}
407
409
  */
408
410
  seek(position) {
409
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
410
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
411
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
412
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
411
413
  return;
412
414
  if (!this.playing || !this.current)
413
415
  return false;
@@ -428,8 +430,8 @@ class Queue {
428
430
  * @returns {Promise<void>}
429
431
  */
430
432
  back() {
431
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
432
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
433
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
434
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
433
435
  return;
434
436
  const prev = this.previousTracks[this.previousTracks.length - 2]; // because last item is the current track
435
437
  if (!prev)
@@ -441,7 +443,7 @@ class Queue {
441
443
  * Clear this queue
442
444
  */
443
445
  clear() {
444
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
446
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
445
447
  return;
446
448
  this.tracks = [];
447
449
  this.previousTracks = [];
@@ -451,7 +453,7 @@ class Queue {
451
453
  * @returns {void}
452
454
  */
453
455
  stop() {
454
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
456
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
455
457
  return;
456
458
  return this.destroy();
457
459
  }
@@ -460,7 +462,7 @@ class Queue {
460
462
  * @returns {boolean}
461
463
  */
462
464
  shuffle() {
463
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
465
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
464
466
  return;
465
467
  if (!this.tracks.length || this.tracks.length < 3)
466
468
  return false;
@@ -478,7 +480,7 @@ class Queue {
478
480
  * @returns {Track}
479
481
  */
480
482
  remove(track) {
481
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
483
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
482
484
  return;
483
485
  let trackFound = null;
484
486
  if (typeof track === "number") {
@@ -501,7 +503,7 @@ class Queue {
501
503
  * @returns {number}
502
504
  */
503
505
  getTrackPosition(track) {
504
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
506
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
505
507
  return;
506
508
  if (typeof track === "number")
507
509
  return this.tracks[track] != null ? track : -1;
@@ -513,7 +515,7 @@ class Queue {
513
515
  * @returns {void}
514
516
  */
515
517
  jump(track) {
516
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
518
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
517
519
  return;
518
520
  const foundTrack = this.remove(track);
519
521
  if (!foundTrack)
@@ -527,7 +529,7 @@ class Queue {
527
529
  * @returns {void}
528
530
  */
529
531
  skipTo(track) {
530
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
532
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
531
533
  return;
532
534
  const trackIndex = this.getTrackPosition(track);
533
535
  const removedTrack = this.remove(track);
@@ -542,7 +544,7 @@ class Queue {
542
544
  * @param {number} [index=0] The index where this track should be
543
545
  */
544
546
  insert(track, index = 0) {
545
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
547
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
546
548
  return;
547
549
  if (!track || !(track instanceof Track_1.default))
548
550
  throw new PlayerError_1.PlayerError("track must be the instance of Track", PlayerError_1.ErrorStatusCode.INVALID_TRACK);
@@ -562,7 +564,7 @@ class Queue {
562
564
  * @returns {PlayerTimestamp}
563
565
  */
564
566
  getPlayerTimestamp() {
565
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
567
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
566
568
  return;
567
569
  const currentStreamTime = this.streamTime;
568
570
  const totalTime = this.current.durationMS;
@@ -580,7 +582,7 @@ class Queue {
580
582
  * @returns {string}
581
583
  */
582
584
  createProgressBar(options = { timecodes: true }) {
583
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
585
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
584
586
  return;
585
587
  const length = typeof options.length === "number" ? (options.length <= 0 || options.length === Infinity ? 15 : options.length) : 15;
586
588
  const index = Math.round((this.streamTime / this.current.durationMS) * length);
@@ -612,7 +614,7 @@ class Queue {
612
614
  * @type {Number}
613
615
  */
614
616
  get totalTime() {
615
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
617
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
616
618
  return;
617
619
  return this.tracks.length > 0 ? this.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : 0;
618
620
  }
@@ -624,8 +626,8 @@ class Queue {
624
626
  */
625
627
  play(src, options = {}) {
626
628
  var _a, _b, _c, _d;
627
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
628
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
629
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
630
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
629
631
  return;
630
632
  if (!this.connection || !this.connection.voiceConnection)
631
633
  throw new PlayerError_1.PlayerError("Voice connection is not available, use <Queue>.connect()!", PlayerError_1.ErrorStatusCode.NO_CONNECTION);
@@ -702,13 +704,15 @@ class Queue {
702
704
  if (options.seek)
703
705
  this._streamTime = options.seek;
704
706
  this._filtersUpdate = options.filtersUpdate;
705
- if (resource.volume && typeof this.options.volumeSmoothness === "number") {
706
- Reflect.set(resource.volume, "_smoothing", this.options.volumeSmoothness || 0);
707
+ const volumeTransformer = resource.volume;
708
+ if ((volumeTransformer === null || volumeTransformer === void 0 ? void 0 : volumeTransformer.hasSmoothness) && typeof this.options.volumeSmoothness === "number") {
709
+ if (typeof volumeTransformer.setSmoothness === "function")
710
+ volumeTransformer.setSmoothness(this.options.volumeSmoothness || 0);
707
711
  }
708
712
  this.setVolume(this.options.initialVolume);
709
713
  setTimeout(() => {
710
714
  this.connection.playStream(resource);
711
- }, (0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_getBufferingTimeout).call(this)).unref();
715
+ }, tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_getBufferingTimeout).call(this)).unref();
712
716
  });
713
717
  }
714
718
  /**
@@ -719,8 +723,8 @@ class Queue {
719
723
  */
720
724
  _handleAutoplay(track) {
721
725
  var _a;
722
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
723
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
726
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
727
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
724
728
  return;
725
729
  if (!track || ![track.source, (_a = track.raw) === null || _a === void 0 ? void 0 : _a.source].includes("youtube")) {
726
730
  if (this.options.leaveOnEnd)
@@ -750,7 +754,7 @@ class Queue {
750
754
  });
751
755
  }
752
756
  *[(_Queue_lastVolume = new WeakMap(), _Queue_destroyed = new WeakMap(), _Queue_instances = new WeakSet(), Symbol.iterator)]() {
753
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
757
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
754
758
  return;
755
759
  yield* this.tracks;
756
760
  }
@@ -760,7 +764,7 @@ class Queue {
760
764
  */
761
765
  toJSON() {
762
766
  var _a, _b;
763
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
767
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
764
768
  return;
765
769
  return {
766
770
  id: this.id,
@@ -775,7 +779,7 @@ class Queue {
775
779
  * @returns {string}
776
780
  */
777
781
  toString() {
778
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
782
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
779
783
  return;
780
784
  if (!this.tracks.length)
781
785
  return "No songs available to display!";
@@ -784,7 +788,7 @@ class Queue {
784
788
  }
785
789
  exports.Queue = Queue;
786
790
  _Queue_watchDestroyed = function _Queue_watchDestroyed(emit = true) {
787
- if ((0, tslib_1.__classPrivateFieldGet)(this, _Queue_destroyed, "f")) {
791
+ if (tslib_1.__classPrivateFieldGet(this, _Queue_destroyed, "f")) {
788
792
  if (emit)
789
793
  this.player.emit("error", this, new PlayerError_1.PlayerError("Cannot use destroyed queue", PlayerError_1.ErrorStatusCode.DESTROYED_QUEUE));
790
794
  return true;
@@ -37,7 +37,8 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
37
37
  * @type {boolean}
38
38
  */
39
39
  this.paused = false;
40
- this.voiceConnection.on("stateChange", (_, newState) => (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
40
+ // @ts-expect-error ???
41
+ this.voiceConnection.on("stateChange", (_, newState) => tslib_1.__awaiter(this, void 0, void 0, function* () {
41
42
  if (newState.status === voice_1.VoiceConnectionStatus.Disconnected) {
42
43
  if (newState.reason === voice_1.VoiceConnectionDisconnectReason.WebSocketClose && newState.closeCode === 4014) {
43
44
  try {
@@ -88,6 +89,7 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
88
89
  }
89
90
  }
90
91
  }));
92
+ // @ts-expect-error ???
91
93
  this.audioPlayer.on("stateChange", (oldState, newState) => {
92
94
  if (newState.status === voice_1.AudioPlayerStatus.Playing) {
93
95
  if (!this.paused)
@@ -171,7 +173,7 @@ class StreamDispatcher extends tiny_typed_emitter_1.TypedEmitter {
171
173
  * @returns {Promise<StreamDispatcher>}
172
174
  */
173
175
  playStream(resource = this.audioResource) {
174
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
176
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
175
177
  if (!resource)
176
178
  throw new PlayerError_1.PlayerError("Audio resource is not available!", PlayerError_1.ErrorStatusCode.NO_AUDIO_RESOURCE);
177
179
  if (resource.ended)
@@ -24,7 +24,7 @@ class VoiceUtils {
24
24
  * @returns {Promise<StreamDispatcher>}
25
25
  */
26
26
  connect(channel, options) {
27
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
27
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
28
28
  const conn = yield this.join(channel, options);
29
29
  const sub = new StreamDispatcher_1.StreamDispatcher(conn, channel, options.maxTime);
30
30
  this.cache.set(channel.guild.id, sub);
@@ -38,14 +38,19 @@ class VoiceUtils {
38
38
  * @returns {VoiceConnection}
39
39
  */
40
40
  join(channel, options) {
41
- var _a;
42
- return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
43
- let conn = (0, voice_1.joinVoiceChannel)({
41
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
42
+ const conn = (0, voice_1.joinVoiceChannel)({
44
43
  guildId: channel.guild.id,
45
44
  channelId: channel.id,
46
45
  adapterCreator: channel.guild.voiceAdapterCreator,
47
46
  selfDeaf: Boolean(options.deaf)
48
47
  });
48
+ return conn;
49
+ });
50
+ }
51
+ enterReady(conn, options = {}) {
52
+ var _a;
53
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
49
54
  try {
50
55
  conn = yield (0, voice_1.entersState)(conn, voice_1.VoiceConnectionStatus.Ready, (_a = options === null || options === void 0 ? void 0 : options.maxTime) !== null && _a !== void 0 ? _a : 20000);
51
56
  return conn;
@@ -30,9 +30,12 @@ class VolumeTransformer extends stream_1.Transform {
30
30
  default:
31
31
  throw new Error("VolumeTransformer type should be one of s16le, s16be, s32le, s32be");
32
32
  }
33
+ this.type = options.type;
33
34
  this._bytes = this._bits / 8;
34
35
  this._extremum = Math.pow(2, this._bits - 1);
35
- this.volume = typeof options.volume === "undefined" ? 1 : options.volume;
36
+ this.volume = Number.isNaN(options.volume) ? 1 : Number(options.volume);
37
+ if (!Number.isFinite(this.volume))
38
+ this.volume = 1;
36
39
  this._targetVolume = this.volume;
37
40
  this._chunk = Buffer.alloc(0);
38
41
  this._smoothing = options.smoothness || 0;
@@ -43,15 +46,17 @@ class VolumeTransformer extends stream_1.Transform {
43
46
  _writeInt(buffer, int, index) {
44
47
  return index;
45
48
  }
46
- _transform(chunk, encoding, done) {
47
- if (this._smoothing > 0 && this.volume !== this._targetVolume) {
48
- if (this.volume < this._targetVolume) {
49
- this.volume = this.volume + this._smoothing >= this._targetVolume ? this._targetVolume : this.volume + this._smoothing;
50
- }
51
- else if (this.volume > this._targetVolume) {
52
- this.volume = this.volume - this._smoothing <= this._targetVolume ? this._targetVolume : this.volume - this._smoothing;
53
- }
49
+ _applySmoothness() {
50
+ if (this.volume < this._targetVolume) {
51
+ this.volume = this.volume + this._smoothing >= this._targetVolume ? this._targetVolume : this.volume + this._smoothing;
52
+ }
53
+ else if (this.volume > this._targetVolume) {
54
+ this.volume = this.volume - this._smoothing <= this._targetVolume ? this._targetVolume : this.volume - this._smoothing;
54
55
  }
56
+ }
57
+ _transform(chunk, encoding, done) {
58
+ if (this.smoothingEnabled() && this.volume !== this._targetVolume)
59
+ this._applySmoothness();
55
60
  if (this.volume === 1) {
56
61
  this.push(chunk);
57
62
  return done();
@@ -74,6 +79,12 @@ class VolumeTransformer extends stream_1.Transform {
74
79
  this._chunk = null;
75
80
  }
76
81
  setVolume(volume) {
82
+ if (Number.isNaN(volume))
83
+ volume = 1;
84
+ if (typeof volume !== "number")
85
+ volume = Number(volume);
86
+ if (!Number.isFinite(volume))
87
+ volume = volume < 0 ? 0 : 1;
77
88
  this._targetVolume = volume;
78
89
  if (this._smoothing <= 0)
79
90
  this.volume = volume;
@@ -90,5 +101,20 @@ class VolumeTransformer extends stream_1.Transform {
90
101
  get volumeLogarithmic() {
91
102
  return Math.pow(this.volume, 1 / 1.660964);
92
103
  }
104
+ get smoothness() {
105
+ return this._smoothing;
106
+ }
107
+ setSmoothness(smoothness) {
108
+ this._smoothing = smoothness;
109
+ }
110
+ smoothingEnabled() {
111
+ return Number.isFinite(this._smoothing) && this._smoothing > 0;
112
+ }
113
+ get hasSmoothness() {
114
+ return true;
115
+ }
116
+ static get hasSmoothing() {
117
+ return true;
118
+ }
93
119
  }
94
120
  exports.VolumeTransformer = VolumeTransformer;
package/dist/index.d.ts CHANGED
@@ -191,6 +191,9 @@ declare class VoiceUtils {
191
191
  deaf?: boolean;
192
192
  maxTime?: number;
193
193
  }): Promise<VoiceConnection>;
194
+ enterReady(conn: VoiceConnection, options?: {
195
+ maxTime?: number;
196
+ }): Promise<VoiceConnection>;
194
197
  /**
195
198
  * Disconnects voice connection
196
199
  * @param {VoiceConnection} connection The voice connection
package/dist/index.js CHANGED
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = exports.Util = exports.StreamDispatcher = exports.VoiceUtils = exports.Track = exports.Queue = exports.QueryResolver = exports.ErrorStatusCode = exports.PlayerError = exports.Player = exports.Playlist = exports.ExtractorModel = exports.AudioFilters = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ // try applying smooth volume patch on load
6
+ require("./smoothVolume");
5
7
  var AudioFilters_1 = require("./utils/AudioFilters");
6
8
  Object.defineProperty(exports, "AudioFilters", { enumerable: true, get: function () { return AudioFilters_1.AudioFilters; } });
7
9
  var ExtractorModel_1 = require("./Structures/ExtractorModel");
@@ -25,6 +27,6 @@ var StreamDispatcher_1 = require("./VoiceInterface/StreamDispatcher");
25
27
  Object.defineProperty(exports, "StreamDispatcher", { enumerable: true, get: function () { return StreamDispatcher_1.StreamDispatcher; } });
26
28
  var Util_1 = require("./utils/Util");
27
29
  Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return Util_1.Util; } });
28
- (0, tslib_1.__exportStar)(require("./types/types"), exports);
30
+ tslib_1.__exportStar(require("./types/types"), exports);
29
31
  // eslint-disable-next-line @typescript-eslint/no-var-requires
30
32
  exports.version = require(`${__dirname}/../package.json`).version;
@@ -1,5 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const VolumeTransformer_1 = require("./VolumeTransformer");
4
- // eslint-disable-next-line
5
- require("prism-media").VolumeTransformer = VolumeTransformer_1.VolumeTransformer;
3
+ const VolumeTransformer_1 = require("./VoiceInterface/VolumeTransformer");
4
+ try {
5
+ // eslint-disable-next-line
6
+ const mod = require("prism-media");
7
+ if (typeof mod.VolumeTransformer.hasSmoothing !== "boolean") {
8
+ Reflect.set(mod, "VolumeTransformer", VolumeTransformer_1.VolumeTransformer);
9
+ }
10
+ }
11
+ catch (_a) {
12
+ /* do nothing */
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discord-player",
3
- "version": "5.2.1-dev",
3
+ "version": "5.2.3-dev",
4
4
  "description": "Complete framework to facilitate music commands using discord.js",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -13,7 +13,9 @@
13
13
  "require": "./dist/index.js",
14
14
  "import": "./dist/index.mjs"
15
15
  },
16
- "./smoothVolume": "./dist/smoothVolume.js"
16
+ "./smoothVolume": "./dist/smoothVolume.js",
17
+ "./src/*": "./dist/*",
18
+ "./dist/*": "./dist/*"
17
19
  },
18
20
  "scripts": {
19
21
  "dev": "cd example/test && ts-node index.ts",
@@ -65,13 +67,12 @@
65
67
  "dependencies": {
66
68
  "@discordjs/voice": "^0.8.0",
67
69
  "discord-ytdl-core": "^5.0.4",
68
- "libsodium-wrappers": "^0.7.9",
69
- "prism-media": "https://codeload.github.com/discord-player/prism-media/tar.gz/main",
70
+ "libsodium-wrappers": "^0.7.10",
70
71
  "soundcloud-scraper": "^5.0.2",
71
- "spotify-url-info": "^2.2.3",
72
+ "spotify-url-info": "^3.0.0",
72
73
  "tiny-typed-emitter": "^2.1.0",
73
- "youtube-sr": "^4.1.12",
74
- "ytdl-core": "^4.10.0"
74
+ "youtube-sr": "^4.1.15",
75
+ "ytdl-core": "^4.11.0"
75
76
  },
76
77
  "devDependencies": {
77
78
  "@babel/cli": "^7.16.0",
@@ -87,7 +88,7 @@
87
88
  "@typescript-eslint/eslint-plugin": "^5.4.0",
88
89
  "@typescript-eslint/parser": "^5.4.0",
89
90
  "discord-api-types": "^0.24.0",
90
- "discord.js": "^13.3.1",
91
+ "discord.js": "^13.6.0",
91
92
  "eslint": "^8.3.0",
92
93
  "gen-esm-wrapper": "^1.1.3",
93
94
  "husky": "^7.0.4",