discord-player 5.2.2 → 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/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 =
|
|
10
|
+
const Track_1 = tslib_1.__importDefault(require("./Structures/Track"));
|
|
11
11
|
const QueryResolver_1 = require("./utils/QueryResolver");
|
|
12
|
-
const youtube_sr_1 =
|
|
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 =
|
|
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");
|
|
@@ -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 &&
|
|
75
|
-
|
|
76
|
-
queue.
|
|
77
|
-
|
|
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
|
/**
|
|
@@ -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
|
|
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
|
|
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;
|
package/dist/Structures/Queue.js
CHANGED
|
@@ -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 =
|
|
7
|
+
const Track_1 = tslib_1.__importDefault(require("./Track"));
|
|
8
8
|
const types_1 = require("../types/types");
|
|
9
|
-
const discord_ytdl_core_1 =
|
|
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 =
|
|
13
|
-
const AudioFilters_1 =
|
|
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 (
|
|
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
|
|
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 (
|
|
124
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
125
125
|
return;
|
|
126
126
|
return this.current;
|
|
127
127
|
}
|
|
@@ -131,8 +131,8 @@ class Queue {
|
|
|
131
131
|
* @returns {Promise<Queue>}
|
|
132
132
|
*/
|
|
133
133
|
connect(channel) {
|
|
134
|
-
return
|
|
135
|
-
if (
|
|
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))
|
|
@@ -142,32 +142,32 @@ class Queue {
|
|
|
142
142
|
});
|
|
143
143
|
this.connection = connection;
|
|
144
144
|
if (_channel.type === "GUILD_STAGE_VOICE") {
|
|
145
|
-
yield _channel.guild.me.voice.setSuppressed(false).catch(() =>
|
|
145
|
+
yield _channel.guild.me.voice.setSuppressed(false).catch(() => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
146
146
|
return yield _channel.guild.me.voice.setRequestToSpeak(true).catch(Util_1.Util.noop);
|
|
147
147
|
}));
|
|
148
148
|
}
|
|
149
149
|
this.connection.on("error", (err) => {
|
|
150
|
-
if (
|
|
150
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
|
|
151
151
|
return;
|
|
152
152
|
this.player.emit("connectionError", this, err);
|
|
153
153
|
});
|
|
154
154
|
this.connection.on("debug", (msg) => {
|
|
155
|
-
if (
|
|
155
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
|
|
156
156
|
return;
|
|
157
157
|
this.player.emit("debug", this, msg);
|
|
158
158
|
});
|
|
159
159
|
this.player.emit("connectionCreate", this, this.connection);
|
|
160
160
|
this.connection.on("start", (resource) => {
|
|
161
161
|
var _a;
|
|
162
|
-
if (
|
|
162
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this, false))
|
|
163
163
|
return;
|
|
164
164
|
this.playing = true;
|
|
165
165
|
if (!this._filtersUpdate && (resource === null || resource === void 0 ? void 0 : resource.metadata))
|
|
166
166
|
this.player.emit("trackStart", this, (_a = resource === null || resource === void 0 ? void 0 : resource.metadata) !== null && _a !== void 0 ? _a : this.current);
|
|
167
167
|
this._filtersUpdate = false;
|
|
168
168
|
});
|
|
169
|
-
this.connection.on("finish", (resource) =>
|
|
170
|
-
if (
|
|
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))
|
|
171
171
|
return;
|
|
172
172
|
this.playing = false;
|
|
173
173
|
if (this._filtersUpdate)
|
|
@@ -207,7 +207,7 @@ class Queue {
|
|
|
207
207
|
*/
|
|
208
208
|
destroy(disconnect = this.options.leaveOnStop) {
|
|
209
209
|
var _a;
|
|
210
|
-
if (
|
|
210
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
211
211
|
return;
|
|
212
212
|
if (this.connection)
|
|
213
213
|
this.connection.end();
|
|
@@ -215,14 +215,14 @@ class Queue {
|
|
|
215
215
|
(_a = this.connection) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
216
216
|
this.player.queues.delete(this.guild.id);
|
|
217
217
|
this.player.voiceUtils.cache.delete(this.guild.id);
|
|
218
|
-
|
|
218
|
+
tslib_1.__classPrivateFieldSet(this, _Queue_destroyed, true, "f");
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
221
|
* Skips current track
|
|
222
222
|
* @returns {boolean}
|
|
223
223
|
*/
|
|
224
224
|
skip() {
|
|
225
|
-
if (
|
|
225
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
226
226
|
return;
|
|
227
227
|
if (!this.connection)
|
|
228
228
|
return false;
|
|
@@ -236,7 +236,7 @@ class Queue {
|
|
|
236
236
|
* @returns {void}
|
|
237
237
|
*/
|
|
238
238
|
addTrack(track) {
|
|
239
|
-
if (
|
|
239
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
240
240
|
return;
|
|
241
241
|
if (!(track instanceof Track_1.default))
|
|
242
242
|
throw new PlayerError_1.PlayerError("invalid track", PlayerError_1.ErrorStatusCode.INVALID_TRACK);
|
|
@@ -248,7 +248,7 @@ class Queue {
|
|
|
248
248
|
* @param {Track[]} tracks Array of tracks to add
|
|
249
249
|
*/
|
|
250
250
|
addTracks(tracks) {
|
|
251
|
-
if (
|
|
251
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
252
252
|
return;
|
|
253
253
|
if (!tracks.every((y) => y instanceof Track_1.default))
|
|
254
254
|
throw new PlayerError_1.PlayerError("invalid track", PlayerError_1.ErrorStatusCode.INVALID_TRACK);
|
|
@@ -261,7 +261,7 @@ class Queue {
|
|
|
261
261
|
* @returns {boolean}
|
|
262
262
|
*/
|
|
263
263
|
setPaused(paused) {
|
|
264
|
-
if (
|
|
264
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
265
265
|
return;
|
|
266
266
|
if (!this.connection)
|
|
267
267
|
return false;
|
|
@@ -274,7 +274,7 @@ class Queue {
|
|
|
274
274
|
*/
|
|
275
275
|
setBitrate(bitrate) {
|
|
276
276
|
var _a, _b, _c, _d;
|
|
277
|
-
if (
|
|
277
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
278
278
|
return;
|
|
279
279
|
if (!((_b = (_a = this.connection) === null || _a === void 0 ? void 0 : _a.audioResource) === null || _b === void 0 ? void 0 : _b.encoder))
|
|
280
280
|
return;
|
|
@@ -288,11 +288,11 @@ class Queue {
|
|
|
288
288
|
* @returns {boolean}
|
|
289
289
|
*/
|
|
290
290
|
setVolume(amount) {
|
|
291
|
-
if (
|
|
291
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
292
292
|
return;
|
|
293
293
|
if (!this.connection)
|
|
294
294
|
return false;
|
|
295
|
-
|
|
295
|
+
tslib_1.__classPrivateFieldSet(this, _Queue_lastVolume, amount, "f");
|
|
296
296
|
this.options.initialVolume = amount;
|
|
297
297
|
return this.connection.setVolume(amount);
|
|
298
298
|
}
|
|
@@ -302,7 +302,7 @@ class Queue {
|
|
|
302
302
|
* @returns {boolean}
|
|
303
303
|
*/
|
|
304
304
|
setRepeatMode(mode) {
|
|
305
|
-
if (
|
|
305
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
306
306
|
return;
|
|
307
307
|
if (![types_1.QueueRepeatMode.OFF, types_1.QueueRepeatMode.QUEUE, types_1.QueueRepeatMode.TRACK, types_1.QueueRepeatMode.AUTOPLAY].includes(mode))
|
|
308
308
|
throw new PlayerError_1.PlayerError(`Unknown repeat mode "${mode}"!`, PlayerError_1.ErrorStatusCode.UNKNOWN_REPEAT_MODE);
|
|
@@ -316,7 +316,7 @@ class Queue {
|
|
|
316
316
|
* @type {number}
|
|
317
317
|
*/
|
|
318
318
|
get volume() {
|
|
319
|
-
if (
|
|
319
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
320
320
|
return;
|
|
321
321
|
if (!this.connection)
|
|
322
322
|
return 100;
|
|
@@ -330,7 +330,7 @@ class Queue {
|
|
|
330
330
|
* @type {number}
|
|
331
331
|
*/
|
|
332
332
|
get streamTime() {
|
|
333
|
-
if (
|
|
333
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
334
334
|
return;
|
|
335
335
|
if (!this.connection)
|
|
336
336
|
return 0;
|
|
@@ -342,7 +342,7 @@ class Queue {
|
|
|
342
342
|
return NC ? playbackTime * NC : VW ? playbackTime * VW : playbackTime;
|
|
343
343
|
}
|
|
344
344
|
set streamTime(time) {
|
|
345
|
-
if (
|
|
345
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
346
346
|
return;
|
|
347
347
|
this.seek(time);
|
|
348
348
|
}
|
|
@@ -351,7 +351,7 @@ class Queue {
|
|
|
351
351
|
* @returns {AudioFilters}
|
|
352
352
|
*/
|
|
353
353
|
getFiltersEnabled() {
|
|
354
|
-
if (
|
|
354
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
355
355
|
return;
|
|
356
356
|
return AudioFilters_1.default.names.filter((x) => this._activeFilters.includes(x));
|
|
357
357
|
}
|
|
@@ -360,7 +360,7 @@ class Queue {
|
|
|
360
360
|
* @returns {AudioFilters}
|
|
361
361
|
*/
|
|
362
362
|
getFiltersDisabled() {
|
|
363
|
-
if (
|
|
363
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
364
364
|
return;
|
|
365
365
|
return AudioFilters_1.default.names.filter((x) => !this._activeFilters.includes(x));
|
|
366
366
|
}
|
|
@@ -370,8 +370,8 @@ class Queue {
|
|
|
370
370
|
* @returns {Promise<void>}
|
|
371
371
|
*/
|
|
372
372
|
setFilters(filters) {
|
|
373
|
-
return
|
|
374
|
-
if (
|
|
373
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
374
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
375
375
|
return;
|
|
376
376
|
if (!filters || !Object.keys(filters).length) {
|
|
377
377
|
// reset filters
|
|
@@ -408,8 +408,8 @@ class Queue {
|
|
|
408
408
|
* @returns {boolean}
|
|
409
409
|
*/
|
|
410
410
|
seek(position) {
|
|
411
|
-
return
|
|
412
|
-
if (
|
|
411
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
412
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
413
413
|
return;
|
|
414
414
|
if (!this.playing || !this.current)
|
|
415
415
|
return false;
|
|
@@ -430,8 +430,8 @@ class Queue {
|
|
|
430
430
|
* @returns {Promise<void>}
|
|
431
431
|
*/
|
|
432
432
|
back() {
|
|
433
|
-
return
|
|
434
|
-
if (
|
|
433
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
434
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
435
435
|
return;
|
|
436
436
|
const prev = this.previousTracks[this.previousTracks.length - 2]; // because last item is the current track
|
|
437
437
|
if (!prev)
|
|
@@ -443,7 +443,7 @@ class Queue {
|
|
|
443
443
|
* Clear this queue
|
|
444
444
|
*/
|
|
445
445
|
clear() {
|
|
446
|
-
if (
|
|
446
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
447
447
|
return;
|
|
448
448
|
this.tracks = [];
|
|
449
449
|
this.previousTracks = [];
|
|
@@ -453,7 +453,7 @@ class Queue {
|
|
|
453
453
|
* @returns {void}
|
|
454
454
|
*/
|
|
455
455
|
stop() {
|
|
456
|
-
if (
|
|
456
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
457
457
|
return;
|
|
458
458
|
return this.destroy();
|
|
459
459
|
}
|
|
@@ -462,7 +462,7 @@ class Queue {
|
|
|
462
462
|
* @returns {boolean}
|
|
463
463
|
*/
|
|
464
464
|
shuffle() {
|
|
465
|
-
if (
|
|
465
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
466
466
|
return;
|
|
467
467
|
if (!this.tracks.length || this.tracks.length < 3)
|
|
468
468
|
return false;
|
|
@@ -480,7 +480,7 @@ class Queue {
|
|
|
480
480
|
* @returns {Track}
|
|
481
481
|
*/
|
|
482
482
|
remove(track) {
|
|
483
|
-
if (
|
|
483
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
484
484
|
return;
|
|
485
485
|
let trackFound = null;
|
|
486
486
|
if (typeof track === "number") {
|
|
@@ -503,7 +503,7 @@ class Queue {
|
|
|
503
503
|
* @returns {number}
|
|
504
504
|
*/
|
|
505
505
|
getTrackPosition(track) {
|
|
506
|
-
if (
|
|
506
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
507
507
|
return;
|
|
508
508
|
if (typeof track === "number")
|
|
509
509
|
return this.tracks[track] != null ? track : -1;
|
|
@@ -515,7 +515,7 @@ class Queue {
|
|
|
515
515
|
* @returns {void}
|
|
516
516
|
*/
|
|
517
517
|
jump(track) {
|
|
518
|
-
if (
|
|
518
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
519
519
|
return;
|
|
520
520
|
const foundTrack = this.remove(track);
|
|
521
521
|
if (!foundTrack)
|
|
@@ -529,7 +529,7 @@ class Queue {
|
|
|
529
529
|
* @returns {void}
|
|
530
530
|
*/
|
|
531
531
|
skipTo(track) {
|
|
532
|
-
if (
|
|
532
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
533
533
|
return;
|
|
534
534
|
const trackIndex = this.getTrackPosition(track);
|
|
535
535
|
const removedTrack = this.remove(track);
|
|
@@ -544,7 +544,7 @@ class Queue {
|
|
|
544
544
|
* @param {number} [index=0] The index where this track should be
|
|
545
545
|
*/
|
|
546
546
|
insert(track, index = 0) {
|
|
547
|
-
if (
|
|
547
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
548
548
|
return;
|
|
549
549
|
if (!track || !(track instanceof Track_1.default))
|
|
550
550
|
throw new PlayerError_1.PlayerError("track must be the instance of Track", PlayerError_1.ErrorStatusCode.INVALID_TRACK);
|
|
@@ -564,7 +564,7 @@ class Queue {
|
|
|
564
564
|
* @returns {PlayerTimestamp}
|
|
565
565
|
*/
|
|
566
566
|
getPlayerTimestamp() {
|
|
567
|
-
if (
|
|
567
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
568
568
|
return;
|
|
569
569
|
const currentStreamTime = this.streamTime;
|
|
570
570
|
const totalTime = this.current.durationMS;
|
|
@@ -582,7 +582,7 @@ class Queue {
|
|
|
582
582
|
* @returns {string}
|
|
583
583
|
*/
|
|
584
584
|
createProgressBar(options = { timecodes: true }) {
|
|
585
|
-
if (
|
|
585
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
586
586
|
return;
|
|
587
587
|
const length = typeof options.length === "number" ? (options.length <= 0 || options.length === Infinity ? 15 : options.length) : 15;
|
|
588
588
|
const index = Math.round((this.streamTime / this.current.durationMS) * length);
|
|
@@ -614,7 +614,7 @@ class Queue {
|
|
|
614
614
|
* @type {Number}
|
|
615
615
|
*/
|
|
616
616
|
get totalTime() {
|
|
617
|
-
if (
|
|
617
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
618
618
|
return;
|
|
619
619
|
return this.tracks.length > 0 ? this.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : 0;
|
|
620
620
|
}
|
|
@@ -626,8 +626,8 @@ class Queue {
|
|
|
626
626
|
*/
|
|
627
627
|
play(src, options = {}) {
|
|
628
628
|
var _a, _b, _c, _d;
|
|
629
|
-
return
|
|
630
|
-
if (
|
|
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))
|
|
631
631
|
return;
|
|
632
632
|
if (!this.connection || !this.connection.voiceConnection)
|
|
633
633
|
throw new PlayerError_1.PlayerError("Voice connection is not available, use <Queue>.connect()!", PlayerError_1.ErrorStatusCode.NO_CONNECTION);
|
|
@@ -712,7 +712,7 @@ class Queue {
|
|
|
712
712
|
this.setVolume(this.options.initialVolume);
|
|
713
713
|
setTimeout(() => {
|
|
714
714
|
this.connection.playStream(resource);
|
|
715
|
-
},
|
|
715
|
+
}, tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_getBufferingTimeout).call(this)).unref();
|
|
716
716
|
});
|
|
717
717
|
}
|
|
718
718
|
/**
|
|
@@ -723,8 +723,8 @@ class Queue {
|
|
|
723
723
|
*/
|
|
724
724
|
_handleAutoplay(track) {
|
|
725
725
|
var _a;
|
|
726
|
-
return
|
|
727
|
-
if (
|
|
726
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
727
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
728
728
|
return;
|
|
729
729
|
if (!track || ![track.source, (_a = track.raw) === null || _a === void 0 ? void 0 : _a.source].includes("youtube")) {
|
|
730
730
|
if (this.options.leaveOnEnd)
|
|
@@ -754,7 +754,7 @@ class Queue {
|
|
|
754
754
|
});
|
|
755
755
|
}
|
|
756
756
|
*[(_Queue_lastVolume = new WeakMap(), _Queue_destroyed = new WeakMap(), _Queue_instances = new WeakSet(), Symbol.iterator)]() {
|
|
757
|
-
if (
|
|
757
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
758
758
|
return;
|
|
759
759
|
yield* this.tracks;
|
|
760
760
|
}
|
|
@@ -764,7 +764,7 @@ class Queue {
|
|
|
764
764
|
*/
|
|
765
765
|
toJSON() {
|
|
766
766
|
var _a, _b;
|
|
767
|
-
if (
|
|
767
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
768
768
|
return;
|
|
769
769
|
return {
|
|
770
770
|
id: this.id,
|
|
@@ -779,7 +779,7 @@ class Queue {
|
|
|
779
779
|
* @returns {string}
|
|
780
780
|
*/
|
|
781
781
|
toString() {
|
|
782
|
-
if (
|
|
782
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this))
|
|
783
783
|
return;
|
|
784
784
|
if (!this.tracks.length)
|
|
785
785
|
return "No songs available to display!";
|
|
@@ -788,7 +788,7 @@ class Queue {
|
|
|
788
788
|
}
|
|
789
789
|
exports.Queue = Queue;
|
|
790
790
|
_Queue_watchDestroyed = function _Queue_watchDestroyed(emit = true) {
|
|
791
|
-
if (
|
|
791
|
+
if (tslib_1.__classPrivateFieldGet(this, _Queue_destroyed, "f")) {
|
|
792
792
|
if (emit)
|
|
793
793
|
this.player.emit("error", this, new PlayerError_1.PlayerError("Cannot use destroyed queue", PlayerError_1.ErrorStatusCode.DESTROYED_QUEUE));
|
|
794
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
|
-
|
|
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
|
|
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
|
|
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,7 +38,7 @@ class VoiceUtils {
|
|
|
38
38
|
* @returns {VoiceConnection}
|
|
39
39
|
*/
|
|
40
40
|
join(channel, options) {
|
|
41
|
-
return
|
|
41
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
42
42
|
const conn = (0, voice_1.joinVoiceChannel)({
|
|
43
43
|
guildId: channel.guild.id,
|
|
44
44
|
channelId: channel.id,
|
|
@@ -50,7 +50,7 @@ class VoiceUtils {
|
|
|
50
50
|
}
|
|
51
51
|
enterReady(conn, options = {}) {
|
|
52
52
|
var _a;
|
|
53
|
-
return
|
|
53
|
+
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
54
54
|
try {
|
|
55
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);
|
|
56
56
|
return conn;
|
package/dist/index.js
CHANGED
|
@@ -27,6 +27,6 @@ var StreamDispatcher_1 = require("./VoiceInterface/StreamDispatcher");
|
|
|
27
27
|
Object.defineProperty(exports, "StreamDispatcher", { enumerable: true, get: function () { return StreamDispatcher_1.StreamDispatcher; } });
|
|
28
28
|
var Util_1 = require("./utils/Util");
|
|
29
29
|
Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return Util_1.Util; } });
|
|
30
|
-
|
|
30
|
+
tslib_1.__exportStar(require("./types/types"), exports);
|
|
31
31
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
32
32
|
exports.version = require(`${__dirname}/../package.json`).version;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "discord-player",
|
|
3
|
-
"version": "5.2.
|
|
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",
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
"dependencies": {
|
|
68
68
|
"@discordjs/voice": "^0.8.0",
|
|
69
69
|
"discord-ytdl-core": "^5.0.4",
|
|
70
|
-
"libsodium-wrappers": "^0.7.
|
|
70
|
+
"libsodium-wrappers": "^0.7.10",
|
|
71
71
|
"soundcloud-scraper": "^5.0.2",
|
|
72
|
-
"spotify-url-info": "^
|
|
72
|
+
"spotify-url-info": "^3.0.0",
|
|
73
73
|
"tiny-typed-emitter": "^2.1.0",
|
|
74
|
-
"youtube-sr": "^4.1.
|
|
75
|
-
"ytdl-core": "^4.
|
|
74
|
+
"youtube-sr": "^4.1.15",
|
|
75
|
+
"ytdl-core": "^4.11.0"
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@babel/cli": "^7.16.0",
|