distube 3.3.1 → 4.0.0-dev.2
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 +6 -8
- package/dist/DisTube.d.ts +13 -557
- package/dist/DisTube.d.ts.map +1 -1
- package/dist/DisTube.js +38 -639
- package/dist/DisTube.js.map +1 -1
- package/dist/constant.d.ts +0 -101
- package/dist/constant.d.ts.map +1 -1
- package/dist/constant.js +0 -101
- package/dist/constant.js.map +1 -1
- package/dist/core/DisTubeBase.d.ts +0 -40
- package/dist/core/DisTubeBase.d.ts.map +1 -1
- package/dist/core/DisTubeBase.js +0 -44
- package/dist/core/DisTubeBase.js.map +1 -1
- package/dist/core/DisTubeHandler.d.ts +2 -89
- package/dist/core/DisTubeHandler.d.ts.map +1 -1
- package/dist/core/DisTubeHandler.js +14 -124
- package/dist/core/DisTubeHandler.js.map +1 -1
- package/dist/core/DisTubeOptions.d.ts +0 -2
- package/dist/core/DisTubeOptions.d.ts.map +1 -1
- package/dist/core/DisTubeOptions.js +0 -13
- package/dist/core/DisTubeOptions.js.map +1 -1
- package/dist/core/DisTubeStream.d.ts +0 -33
- package/dist/core/DisTubeStream.d.ts.map +1 -1
- package/dist/core/DisTubeStream.js +0 -36
- package/dist/core/DisTubeStream.js.map +1 -1
- package/dist/core/manager/BaseManager.d.ts +1 -16
- package/dist/core/manager/BaseManager.d.ts.map +1 -1
- package/dist/core/manager/BaseManager.js +2 -28
- package/dist/core/manager/BaseManager.js.map +1 -1
- package/dist/core/manager/FilterManager.d.ts +16 -0
- package/dist/core/manager/FilterManager.d.ts.map +1 -0
- package/dist/core/manager/FilterManager.js +88 -0
- package/dist/core/manager/FilterManager.js.map +1 -0
- package/dist/core/manager/GuildIdManager.d.ts +9 -0
- package/dist/core/manager/GuildIdManager.d.ts.map +1 -0
- package/dist/core/manager/GuildIdManager.js +25 -0
- package/dist/core/manager/GuildIdManager.js.map +1 -0
- package/dist/core/manager/QueueManager.d.ts +4 -26
- package/dist/core/manager/QueueManager.d.ts.map +1 -1
- package/dist/core/manager/QueueManager.js +27 -48
- package/dist/core/manager/QueueManager.js.map +1 -1
- package/dist/core/manager/index.d.ts +2 -0
- package/dist/core/manager/index.d.ts.map +1 -1
- package/dist/core/manager/index.js +2 -0
- package/dist/core/manager/index.js.map +1 -1
- package/dist/core/voice/DisTubeVoice.d.ts +0 -50
- package/dist/core/voice/DisTubeVoice.d.ts.map +1 -1
- package/dist/core/voice/DisTubeVoice.js +9 -71
- package/dist/core/voice/DisTubeVoice.js.map +1 -1
- package/dist/core/voice/DisTubeVoiceManager.d.ts +2 -33
- package/dist/core/voice/DisTubeVoiceManager.d.ts.map +1 -1
- package/dist/core/voice/DisTubeVoiceManager.js +1 -32
- package/dist/core/voice/DisTubeVoiceManager.js.map +1 -1
- package/dist/core/voice/index.d.ts +0 -1
- package/dist/core/voice/index.d.ts.map +1 -1
- package/dist/core/voice/index.js +0 -1
- package/dist/core/voice/index.js.map +1 -1
- package/dist/plugin/index.d.ts +0 -1
- package/dist/plugin/index.d.ts.map +1 -1
- package/dist/plugin/index.js +0 -1
- package/dist/plugin/index.js.map +1 -1
- package/dist/struct/CustomPlugin.d.ts +0 -41
- package/dist/struct/CustomPlugin.d.ts.map +1 -1
- package/dist/struct/CustomPlugin.js +0 -34
- package/dist/struct/CustomPlugin.js.map +1 -1
- package/dist/struct/DisTubeError.d.ts +0 -1
- package/dist/struct/DisTubeError.d.ts.map +1 -1
- package/dist/struct/DisTubeError.js +0 -2
- package/dist/struct/DisTubeError.js.map +1 -1
- package/dist/struct/ExtractorPlugin.d.ts +0 -32
- package/dist/struct/ExtractorPlugin.d.ts.map +1 -1
- package/dist/struct/ExtractorPlugin.js +0 -23
- package/dist/struct/ExtractorPlugin.js.map +1 -1
- package/dist/struct/Playlist.d.ts +0 -36
- package/dist/struct/Playlist.d.ts.map +1 -1
- package/dist/struct/Playlist.js +3 -54
- package/dist/struct/Playlist.js.map +1 -1
- package/dist/struct/Plugin.d.ts +0 -58
- package/dist/struct/Plugin.d.ts.map +1 -1
- package/dist/struct/Plugin.js +0 -62
- package/dist/struct/Plugin.js.map +1 -1
- package/dist/struct/Queue.d.ts +10 -177
- package/dist/struct/Queue.d.ts.map +1 -1
- package/dist/struct/Queue.js +49 -256
- package/dist/struct/Queue.js.map +1 -1
- package/dist/struct/SearchResult.d.ts +0 -8
- package/dist/struct/SearchResult.d.ts.map +1 -1
- package/dist/struct/SearchResult.js +0 -47
- package/dist/struct/SearchResult.js.map +1 -1
- package/dist/struct/Song.d.ts +0 -38
- package/dist/struct/Song.d.ts.map +1 -1
- package/dist/struct/Song.js +3 -122
- package/dist/struct/Song.js.map +1 -1
- package/dist/struct/TaskQueue.d.ts +0 -20
- package/dist/struct/TaskQueue.d.ts.map +1 -1
- package/dist/struct/TaskQueue.js +0 -25
- package/dist/struct/TaskQueue.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/type.d.ts +6 -75
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/dist/util.d.ts +1 -30
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +16 -59
- package/dist/util.js.map +1 -1
- package/package.json +22 -14
- package/dist/core/voice/DJSAdapter.d.ts +0 -4
- package/dist/core/voice/DJSAdapter.d.ts.map +0 -1
- package/dist/core/voice/DJSAdapter.js +0 -58
- package/dist/core/voice/DJSAdapter.js.map +0 -1
- package/dist/plugin/youtube-dl.d.ts +0 -12
- package/dist/plugin/youtube-dl.d.ts.map +0 -1
- package/dist/plugin/youtube-dl.js +0 -70
- package/dist/plugin/youtube-dl.js.map +0 -1
package/dist/struct/Queue.js
CHANGED
|
@@ -1,163 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _Queue_filters;
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
exports.Queue = void 0;
|
|
4
16
|
const core_1 = require("../core");
|
|
5
17
|
const __1 = require("..");
|
|
6
|
-
/**
|
|
7
|
-
* Represents a queue.
|
|
8
|
-
* @extends DisTubeBase
|
|
9
|
-
*/
|
|
10
18
|
class Queue extends core_1.DisTubeBase {
|
|
11
|
-
/**
|
|
12
|
-
* Create a queue for the guild
|
|
13
|
-
* @param {DisTube} distube DisTube
|
|
14
|
-
* @param {DisTubeVoice} voice Voice connection
|
|
15
|
-
* @param {Song|Song[]} song First song(s)
|
|
16
|
-
* @param {Discord.BaseGuildTextChannel?} textChannel Default text channel
|
|
17
|
-
*/
|
|
18
19
|
constructor(distube, voice, song, textChannel) {
|
|
19
20
|
super(distube);
|
|
20
|
-
|
|
21
|
-
* The client user as a `GuildMember` of this queue's guild
|
|
22
|
-
* @type {Discord.GuildMember}
|
|
23
|
-
*/
|
|
21
|
+
_Queue_filters.set(this, void 0);
|
|
24
22
|
this.clientMember =
|
|
25
23
|
voice.channel.guild?.me ??
|
|
26
24
|
(() => {
|
|
27
25
|
throw new __1.DisTubeError("INVALID_TYPE", "GuildMember", null, "<VoiceChannel>.guild.me");
|
|
28
26
|
})();
|
|
29
|
-
/**
|
|
30
|
-
* Voice connection of this queue.
|
|
31
|
-
* @type {DisTubeVoice}
|
|
32
|
-
*/
|
|
33
27
|
this.voice = voice;
|
|
34
|
-
/**
|
|
35
|
-
* Queue id (Guild id)
|
|
36
|
-
* @type {Discord.Snowflake}
|
|
37
|
-
*/
|
|
38
28
|
this.id = voice.id;
|
|
39
|
-
/**
|
|
40
|
-
* Get or set the stream volume. Default value: `50`.
|
|
41
|
-
* @type {number}
|
|
42
|
-
*/
|
|
43
29
|
this.volume = 50;
|
|
44
|
-
/**
|
|
45
|
-
* List of songs in the queue (The first one is the playing song)
|
|
46
|
-
* @type {Array<Song>}
|
|
47
|
-
*/
|
|
48
30
|
this.songs = Array.isArray(song) ? [...song] : [song];
|
|
49
|
-
/**
|
|
50
|
-
* List of the previous songs.
|
|
51
|
-
* @type {Array<Song>}
|
|
52
|
-
*/
|
|
53
31
|
this.previousSongs = [];
|
|
54
|
-
/**
|
|
55
|
-
* Whether stream is currently stopped.
|
|
56
|
-
* @type {boolean}
|
|
57
|
-
* @private
|
|
58
|
-
*/
|
|
59
32
|
this.stopped = false;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* @type {boolean}
|
|
63
|
-
* @private
|
|
64
|
-
*/
|
|
65
|
-
this.next = false;
|
|
66
|
-
/**
|
|
67
|
-
* Whether or not the last song was skipped to previous song.
|
|
68
|
-
* @type {boolean}
|
|
69
|
-
* @private
|
|
70
|
-
*/
|
|
71
|
-
this.prev = false;
|
|
72
|
-
/**
|
|
73
|
-
* Whether or not the stream is currently playing.
|
|
74
|
-
* @type {boolean}
|
|
75
|
-
*/
|
|
33
|
+
this._next = false;
|
|
34
|
+
this._prev = false;
|
|
76
35
|
this.playing = true;
|
|
77
|
-
/**
|
|
78
|
-
* Whether or not the stream is currently paused.
|
|
79
|
-
* @type {boolean}
|
|
80
|
-
*/
|
|
81
36
|
this.paused = false;
|
|
82
|
-
/**
|
|
83
|
-
* Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).
|
|
84
|
-
* Default value: `0` (disabled)
|
|
85
|
-
* @type {RepeatMode}
|
|
86
|
-
*/
|
|
87
37
|
this.repeatMode = __1.RepeatMode.DISABLED;
|
|
88
|
-
/**
|
|
89
|
-
* Whether or not the autoplay mode is enabled.
|
|
90
|
-
* Default value: `false`
|
|
91
|
-
* @type {boolean}
|
|
92
|
-
*/
|
|
93
38
|
this.autoplay = false;
|
|
94
|
-
|
|
95
|
-
* Enabled audio filters.
|
|
96
|
-
* Available filters: {@link Filters}
|
|
97
|
-
* @type {Array<string>}
|
|
98
|
-
*/
|
|
99
|
-
this.filters = [];
|
|
100
|
-
/**
|
|
101
|
-
* What time in the song to begin (in seconds).
|
|
102
|
-
* @type {number}
|
|
103
|
-
*/
|
|
39
|
+
__classPrivateFieldSet(this, _Queue_filters, new core_1.FilterManager(distube, this), "f");
|
|
104
40
|
this.beginTime = 0;
|
|
105
|
-
/**
|
|
106
|
-
* The text channel of the Queue. (Default: where the first command is called).
|
|
107
|
-
* @type {Discord.TextChannel?}
|
|
108
|
-
*/
|
|
109
41
|
this.textChannel = textChannel;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
this
|
|
116
|
-
/**
|
|
117
|
-
* Task queuing system
|
|
118
|
-
* @type {TaskQueue}
|
|
119
|
-
* @private
|
|
120
|
-
*/
|
|
121
|
-
this.taskQueue = new __1.TaskQueue();
|
|
122
|
-
/**
|
|
123
|
-
* DisTubeVoice listener
|
|
124
|
-
* @type {Object}
|
|
125
|
-
* @private
|
|
126
|
-
*/
|
|
127
|
-
this.listeners = undefined;
|
|
42
|
+
this._emptyTimeout = undefined;
|
|
43
|
+
this._taskQueue = new __1.TaskQueue();
|
|
44
|
+
this._listeners = undefined;
|
|
45
|
+
}
|
|
46
|
+
get filters() {
|
|
47
|
+
return __classPrivateFieldGet(this, _Queue_filters, "f");
|
|
128
48
|
}
|
|
129
|
-
/**
|
|
130
|
-
* Formatted duration string.
|
|
131
|
-
* @type {string}
|
|
132
|
-
*/
|
|
133
49
|
get formattedDuration() {
|
|
134
50
|
return (0, __1.formatDuration)(this.duration);
|
|
135
51
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Queue's duration.
|
|
138
|
-
* @type {number}
|
|
139
|
-
*/
|
|
140
52
|
get duration() {
|
|
141
53
|
return this.songs.length ? this.songs.reduce((prev, next) => prev + next.duration, 0) : 0;
|
|
142
54
|
}
|
|
143
|
-
/**
|
|
144
|
-
* What time in the song is playing (in seconds).
|
|
145
|
-
* @type {number}
|
|
146
|
-
*/
|
|
147
55
|
get currentTime() {
|
|
148
56
|
return this.voice.playbackDuration + this.beginTime;
|
|
149
57
|
}
|
|
150
|
-
/**
|
|
151
|
-
* Formatted {@link Queue#currentTime} string.
|
|
152
|
-
* @type {string}
|
|
153
|
-
*/
|
|
154
58
|
get formattedCurrentTime() {
|
|
155
59
|
return (0, __1.formatDuration)(this.currentTime);
|
|
156
60
|
}
|
|
157
|
-
/**
|
|
158
|
-
* The voice channel playing in.
|
|
159
|
-
* @type {Discord.VoiceChannel|Discord.StageChannel|null}
|
|
160
|
-
*/
|
|
161
61
|
get voiceChannel() {
|
|
162
62
|
return this.clientMember.voice.channel;
|
|
163
63
|
}
|
|
@@ -167,14 +67,6 @@ class Queue extends core_1.DisTubeBase {
|
|
|
167
67
|
set volume(value) {
|
|
168
68
|
this.voice.volume = value;
|
|
169
69
|
}
|
|
170
|
-
/**
|
|
171
|
-
* @private
|
|
172
|
-
* Add a Song or an array of Song to the queue
|
|
173
|
-
* @param {Song|Song[]} song Song to add
|
|
174
|
-
* @param {number} [position=0] Position to add, <= 0 to add to the end of the queue
|
|
175
|
-
* @throws {Error}
|
|
176
|
-
* @returns {Queue} The guild queue
|
|
177
|
-
*/
|
|
178
70
|
addToQueue(song, position = 0) {
|
|
179
71
|
if (!song || (Array.isArray(song) && !song.length)) {
|
|
180
72
|
throw new __1.DisTubeError("INVALID_TYPE", ["Song", "Array<Song>"], song, "song");
|
|
@@ -200,10 +92,6 @@ class Queue extends core_1.DisTubeBase {
|
|
|
200
92
|
delete song.formats;
|
|
201
93
|
return this;
|
|
202
94
|
}
|
|
203
|
-
/**
|
|
204
|
-
* Pause the guild stream
|
|
205
|
-
* @returns {Queue} The guild queue
|
|
206
|
-
*/
|
|
207
95
|
pause() {
|
|
208
96
|
if (this.paused)
|
|
209
97
|
throw new __1.DisTubeError("PAUSED");
|
|
@@ -212,10 +100,6 @@ class Queue extends core_1.DisTubeBase {
|
|
|
212
100
|
this.voice.pause();
|
|
213
101
|
return this;
|
|
214
102
|
}
|
|
215
|
-
/**
|
|
216
|
-
* Resume the guild stream
|
|
217
|
-
* @returns {Queue} The guild queue
|
|
218
|
-
*/
|
|
219
103
|
resume() {
|
|
220
104
|
if (this.playing)
|
|
221
105
|
throw new __1.DisTubeError("RESUMED");
|
|
@@ -224,24 +108,12 @@ class Queue extends core_1.DisTubeBase {
|
|
|
224
108
|
this.voice.unpause();
|
|
225
109
|
return this;
|
|
226
110
|
}
|
|
227
|
-
/**
|
|
228
|
-
* Set the guild stream's volume
|
|
229
|
-
* @param {number} percent The percentage of volume you want to set
|
|
230
|
-
* @returns {Queue} The guild queue
|
|
231
|
-
*/
|
|
232
111
|
setVolume(percent) {
|
|
233
112
|
this.volume = percent;
|
|
234
113
|
return this;
|
|
235
114
|
}
|
|
236
|
-
/**
|
|
237
|
-
* Skip the playing song if there is a next song in the queue.
|
|
238
|
-
* <info>If {@link Queue#autoplay} is `true` and there is no up next song,
|
|
239
|
-
* DisTube will add and play a related song.</info>
|
|
240
|
-
* @returns {Promise<Song>} The song will skip to
|
|
241
|
-
* @throws {Error}
|
|
242
|
-
*/
|
|
243
115
|
async skip() {
|
|
244
|
-
await this.
|
|
116
|
+
await this._taskQueue.queuing();
|
|
245
117
|
try {
|
|
246
118
|
if (this.songs.length <= 1) {
|
|
247
119
|
if (this.autoplay)
|
|
@@ -250,21 +122,16 @@ class Queue extends core_1.DisTubeBase {
|
|
|
250
122
|
throw new __1.DisTubeError("NO_UP_NEXT");
|
|
251
123
|
}
|
|
252
124
|
const song = this.songs[1];
|
|
253
|
-
this.
|
|
125
|
+
this._next = true;
|
|
254
126
|
this.voice.stop();
|
|
255
127
|
return song;
|
|
256
128
|
}
|
|
257
129
|
finally {
|
|
258
|
-
this.
|
|
130
|
+
this._taskQueue.resolve();
|
|
259
131
|
}
|
|
260
132
|
}
|
|
261
|
-
/**
|
|
262
|
-
* Play the previous song if exists
|
|
263
|
-
* @returns {Song} The guild queue
|
|
264
|
-
* @throws {Error}
|
|
265
|
-
*/
|
|
266
133
|
async previous() {
|
|
267
|
-
await this.
|
|
134
|
+
await this._taskQueue.queuing();
|
|
268
135
|
try {
|
|
269
136
|
if (!this.options.savePreviousSongs)
|
|
270
137
|
throw new __1.DisTubeError("DISABLED_OPTION", "savePreviousSongs");
|
|
@@ -272,20 +139,16 @@ class Queue extends core_1.DisTubeBase {
|
|
|
272
139
|
throw new __1.DisTubeError("NO_PREVIOUS");
|
|
273
140
|
}
|
|
274
141
|
const song = this.repeatMode === 2 ? this.songs[this.songs.length - 1] : this.previousSongs[this.previousSongs.length - 1];
|
|
275
|
-
this.
|
|
142
|
+
this._prev = true;
|
|
276
143
|
this.voice.stop();
|
|
277
144
|
return song;
|
|
278
145
|
}
|
|
279
146
|
finally {
|
|
280
|
-
this.
|
|
147
|
+
this._taskQueue.resolve();
|
|
281
148
|
}
|
|
282
149
|
}
|
|
283
|
-
/**
|
|
284
|
-
* Shuffle the queue's songs
|
|
285
|
-
* @returns {Promise<Queue>} The guild queue
|
|
286
|
-
*/
|
|
287
150
|
async shuffle() {
|
|
288
|
-
await this.
|
|
151
|
+
await this._taskQueue.queuing();
|
|
289
152
|
try {
|
|
290
153
|
const playing = this.songs.shift();
|
|
291
154
|
if (playing === undefined)
|
|
@@ -298,25 +161,18 @@ class Queue extends core_1.DisTubeBase {
|
|
|
298
161
|
return this;
|
|
299
162
|
}
|
|
300
163
|
finally {
|
|
301
|
-
this.
|
|
164
|
+
this._taskQueue.resolve();
|
|
302
165
|
}
|
|
303
166
|
}
|
|
304
|
-
/**
|
|
305
|
-
* Jump to the song position in the queue.
|
|
306
|
-
* The next one is 1, 2,...
|
|
307
|
-
* The previous one is -1, -2,...
|
|
308
|
-
* @param {number} position The song position to play
|
|
309
|
-
* @returns {Promise<Queue>} The guild queue
|
|
310
|
-
* @throws {Error} if `num` is invalid number
|
|
311
|
-
*/
|
|
312
167
|
async jump(position) {
|
|
313
|
-
await this.
|
|
168
|
+
await this._taskQueue.queuing();
|
|
314
169
|
try {
|
|
315
170
|
if (typeof position !== "number")
|
|
316
171
|
throw new __1.DisTubeError("INVALID_TYPE", "number", position, "position");
|
|
317
172
|
if (!position || position > this.songs.length || -position > this.previousSongs.length) {
|
|
318
173
|
throw new __1.DisTubeError("NO_SONG_POSITION");
|
|
319
174
|
}
|
|
175
|
+
let nextSong;
|
|
320
176
|
if (position > 0) {
|
|
321
177
|
const nextSongs = this.songs.splice(position - 1);
|
|
322
178
|
if (this.options.savePreviousSongs) {
|
|
@@ -326,29 +182,25 @@ class Queue extends core_1.DisTubeBase {
|
|
|
326
182
|
this.previousSongs.push(...this.songs.map(s => ({ id: s.id })));
|
|
327
183
|
}
|
|
328
184
|
this.songs = nextSongs;
|
|
329
|
-
this.
|
|
185
|
+
this._next = true;
|
|
186
|
+
nextSong = nextSongs[1];
|
|
330
187
|
}
|
|
331
188
|
else if (!this.options.savePreviousSongs) {
|
|
332
189
|
throw new __1.DisTubeError("DISABLED_OPTION", "savePreviousSongs");
|
|
333
190
|
}
|
|
334
191
|
else {
|
|
335
|
-
this.
|
|
192
|
+
this._prev = true;
|
|
336
193
|
if (position !== -1)
|
|
337
194
|
this.songs.unshift(...this.previousSongs.splice(position + 1));
|
|
195
|
+
nextSong = this.previousSongs[this.previousSongs.length - 1];
|
|
338
196
|
}
|
|
339
197
|
this.voice.stop();
|
|
340
|
-
return
|
|
198
|
+
return nextSong;
|
|
341
199
|
}
|
|
342
200
|
finally {
|
|
343
|
-
this.
|
|
201
|
+
this._taskQueue.resolve();
|
|
344
202
|
}
|
|
345
203
|
}
|
|
346
|
-
/**
|
|
347
|
-
* Set the repeat mode of the guild queue.\
|
|
348
|
-
* Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
|
|
349
|
-
* @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)
|
|
350
|
-
* @returns {RepeatMode} The new repeat mode
|
|
351
|
-
*/
|
|
352
204
|
setRepeatMode(mode) {
|
|
353
205
|
if (mode !== undefined && !Object.values(__1.RepeatMode).includes(mode)) {
|
|
354
206
|
throw new __1.DisTubeError("INVALID_TYPE", ["RepeatMode", "undefined"], mode, "mode");
|
|
@@ -361,51 +213,6 @@ class Queue extends core_1.DisTubeBase {
|
|
|
361
213
|
this.repeatMode = mode;
|
|
362
214
|
return this.repeatMode;
|
|
363
215
|
}
|
|
364
|
-
/**
|
|
365
|
-
* Enable or disable filter(s) of the queue.
|
|
366
|
-
* Available filters: {@link Filters}
|
|
367
|
-
* @param {string|string[]|false} filter A filter name, an array of filter name or `false` to clear all the filters
|
|
368
|
-
* @param {boolean} [force=false] Force enable the input filter(s) even if it's enabled
|
|
369
|
-
* @returns {Array<string>} Enabled filters.
|
|
370
|
-
* @throws {Error}
|
|
371
|
-
*/
|
|
372
|
-
setFilter(filter, force = false) {
|
|
373
|
-
if (Array.isArray(filter)) {
|
|
374
|
-
filter = filter.filter(f => Object.prototype.hasOwnProperty.call(this.distube.filters, f));
|
|
375
|
-
if (!filter.length)
|
|
376
|
-
throw new __1.DisTubeError("EMPTY_FILTERED_ARRAY", "filter", "filter name");
|
|
377
|
-
for (const f of filter) {
|
|
378
|
-
if (this.filters.includes(f)) {
|
|
379
|
-
if (!force)
|
|
380
|
-
this.filters.splice(this.filters.indexOf(f), 1);
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
this.filters.push(f);
|
|
384
|
-
}
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
else if (filter === false) {
|
|
388
|
-
this.filters = [];
|
|
389
|
-
}
|
|
390
|
-
else if (!Object.prototype.hasOwnProperty.call(this.distube.filters, filter)) {
|
|
391
|
-
throw new __1.DisTubeError("INVALID_TYPE", "filter name", filter, "filter");
|
|
392
|
-
}
|
|
393
|
-
else if (this.filters.includes(filter)) {
|
|
394
|
-
if (!force)
|
|
395
|
-
this.filters.splice(this.filters.indexOf(filter), 1);
|
|
396
|
-
}
|
|
397
|
-
else {
|
|
398
|
-
this.filters.push(filter);
|
|
399
|
-
}
|
|
400
|
-
this.beginTime = this.currentTime;
|
|
401
|
-
this.queues.playSong(this);
|
|
402
|
-
return this.filters;
|
|
403
|
-
}
|
|
404
|
-
/**
|
|
405
|
-
* Set the playing time to another position
|
|
406
|
-
* @param {number} time Time in seconds
|
|
407
|
-
* @returns {Queue} The guild queue
|
|
408
|
-
*/
|
|
409
216
|
seek(time) {
|
|
410
217
|
if (typeof time !== "number")
|
|
411
218
|
throw new __1.DisTubeError("INVALID_TYPE", "number", time, "time");
|
|
@@ -415,11 +222,6 @@ class Queue extends core_1.DisTubeBase {
|
|
|
415
222
|
this.queues.playSong(this);
|
|
416
223
|
return this;
|
|
417
224
|
}
|
|
418
|
-
/**
|
|
419
|
-
* Add a related song of the playing song to the queue
|
|
420
|
-
* @returns {Promise<Song>} The added song
|
|
421
|
-
* @throws {Error}
|
|
422
|
-
*/
|
|
423
225
|
async addRelatedSong() {
|
|
424
226
|
if (!this.songs?.[0])
|
|
425
227
|
throw new __1.DisTubeError("NO_PLAYING");
|
|
@@ -432,48 +234,39 @@ class Queue extends core_1.DisTubeBase {
|
|
|
432
234
|
this.addToQueue(song);
|
|
433
235
|
return song;
|
|
434
236
|
}
|
|
435
|
-
/**
|
|
436
|
-
* Stop the guild stream and delete the queue
|
|
437
|
-
*/
|
|
438
237
|
async stop() {
|
|
439
|
-
await this.
|
|
238
|
+
await this._taskQueue.queuing();
|
|
440
239
|
try {
|
|
240
|
+
this.playing = false;
|
|
241
|
+
this.paused = false;
|
|
441
242
|
this.stopped = true;
|
|
442
243
|
if (this.options.leaveOnStop)
|
|
443
244
|
this.voice.leave();
|
|
444
245
|
else
|
|
445
246
|
this.voice.stop();
|
|
446
|
-
this.
|
|
247
|
+
this.remove();
|
|
447
248
|
}
|
|
448
249
|
finally {
|
|
449
|
-
this.
|
|
250
|
+
this._taskQueue.resolve();
|
|
450
251
|
}
|
|
451
252
|
}
|
|
452
|
-
|
|
453
|
-
* Delete the queue from the manager
|
|
454
|
-
* (This does not leave the voice channel even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)
|
|
455
|
-
* @private
|
|
456
|
-
*/
|
|
457
|
-
delete() {
|
|
253
|
+
remove() {
|
|
458
254
|
this.stopped = true;
|
|
459
255
|
this.songs = [];
|
|
460
256
|
this.previousSongs = [];
|
|
461
|
-
if (this.
|
|
462
|
-
for (const event of Object.keys(this.
|
|
463
|
-
this.voice.removeListener(event, this.
|
|
257
|
+
if (this._listeners) {
|
|
258
|
+
for (const event of Object.keys(this._listeners)) {
|
|
259
|
+
this.voice.removeListener(event, this._listeners[event]);
|
|
464
260
|
}
|
|
465
261
|
}
|
|
466
|
-
this.queues.
|
|
262
|
+
this.queues.remove(this.id);
|
|
467
263
|
this.emit("deleteQueue", this);
|
|
468
264
|
}
|
|
469
|
-
/**
|
|
470
|
-
* Toggle autoplay mode
|
|
471
|
-
* @returns {boolean} Autoplay mode state
|
|
472
|
-
*/
|
|
473
265
|
toggleAutoplay() {
|
|
474
266
|
this.autoplay = !this.autoplay;
|
|
475
267
|
return this.autoplay;
|
|
476
268
|
}
|
|
477
269
|
}
|
|
478
270
|
exports.Queue = Queue;
|
|
271
|
+
_Queue_filters = new WeakMap();
|
|
479
272
|
//# sourceMappingURL=Queue.js.map
|
package/dist/struct/Queue.js.map
CHANGED
|
@@ -1 +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CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IACD;;;OAGG;IACH,cAAc;QACZ,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAvfD,sBAufC","sourcesContent":["import { DisTubeBase } from \"../core\";\nimport { DisTubeError, RepeatMode, Song, TaskQueue, formatDuration } from \"..\";\nimport type { DisTube, DisTubeVoice, DisTubeVoiceEvents } from \"..\";\nimport type { GuildMember, GuildTextBasedChannel, Snowflake } from \"discord.js\";\n\n/**\n * Represents a queue.\n * @extends DisTubeBase\n */\nexport class Queue extends DisTubeBase {\n readonly id: Snowflake;\n /**\n * Voice connection of this queue\n */\n voice: DisTubeVoice;\n /**\n * List of songs in the queue (The first one is the playing song)\n */\n songs: Song[];\n /**\n * List of the previous songs.\n */\n previousSongs: Song[];\n /**\n * Whether stream is currently stopped.\n * @private\n */\n stopped: boolean;\n /**\n * Whether or not the last song was skipped to next song.\n * @private\n */\n next: boolean;\n /**\n * Whether or not the last song was skipped to previous song.\n * @private\n */\n prev: boolean;\n /**\n * Whether or not the stream is currently playing.\n */\n playing: boolean;\n /**\n * Whether or not the stream is currently paused.\n */\n paused: boolean;\n /**\n * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).\n * Default value: `0` (disabled)\n */\n repeatMode: RepeatMode;\n /**\n * Whether or not the autoplay mode is enabled.\n * Default value: `false`\n */\n autoplay: boolean;\n /**\n * Enabled audio filters.\n * Available filters: {@link Filters}\n */\n filters: string[];\n /**\n * What time in the song to begin (in seconds).\n */\n beginTime: number;\n /**\n * The text channel of the Queue. (Default: where the first command is called).\n */\n textChannel?: GuildTextBasedChannel;\n /**\n * Timeout for checking empty channel\n * @private\n */\n emptyTimeout?: NodeJS.Timeout;\n /**\n * The client user as a `GuildMember` of this queue's guild\n */\n clientMember: GuildMember;\n /**\n * Task queuing system\n */\n taskQueue: TaskQueue;\n listeners?: DisTubeVoiceEvents;\n /**\n * Create a queue for the guild\n * @param {DisTube} distube DisTube\n * @param {DisTubeVoice} voice Voice connection\n * @param {Song|Song[]} song First song(s)\n * @param {Discord.BaseGuildTextChannel?} textChannel Default text channel\n */\n constructor(distube: DisTube, voice: DisTubeVoice, song: Song | Song[], textChannel?: GuildTextBasedChannel) {\n super(distube);\n /**\n * The client user as a `GuildMember` of this queue's guild\n * @type {Discord.GuildMember}\n */\n this.clientMember =\n voice.channel.guild?.me ??\n (() => {\n throw new DisTubeError(\"INVALID_TYPE\", \"GuildMember\", null, \"<VoiceChannel>.guild.me\");\n })();\n /**\n * Voice connection of this queue.\n * @type {DisTubeVoice}\n */\n this.voice = voice;\n /**\n * Queue id (Guild id)\n * @type {Discord.Snowflake}\n */\n this.id = voice.id;\n /**\n * Get or set the stream volume. Default value: `50`.\n * @type {number}\n */\n this.volume = 50;\n /**\n * List of songs in the queue (The first one is the playing song)\n * @type {Array<Song>}\n */\n this.songs = Array.isArray(song) ? [...song] : [song];\n /**\n * List of the previous songs.\n * @type {Array<Song>}\n */\n this.previousSongs = [];\n /**\n * Whether stream is currently stopped.\n * @type {boolean}\n * @private\n */\n this.stopped = false;\n /**\n * Whether or not the last song was skipped to next song.\n * @type {boolean}\n * @private\n */\n this.next = false;\n /**\n * Whether or not the last song was skipped to previous song.\n * @type {boolean}\n * @private\n */\n this.prev = false;\n /**\n * Whether or not the stream is currently playing.\n * @type {boolean}\n */\n this.playing = true;\n /**\n * Whether or not the stream is currently paused.\n * @type {boolean}\n */\n this.paused = false;\n /**\n * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).\n * Default value: `0` (disabled)\n * @type {RepeatMode}\n */\n this.repeatMode = RepeatMode.DISABLED;\n /**\n * Whether or not the autoplay mode is enabled.\n * Default value: `false`\n * @type {boolean}\n */\n this.autoplay = false;\n /**\n * Enabled audio filters.\n * Available filters: {@link Filters}\n * @type {Array<string>}\n */\n this.filters = [];\n /**\n * What time in the song to begin (in seconds).\n * @type {number}\n */\n this.beginTime = 0;\n /**\n * The text channel of the Queue. (Default: where the first command is called).\n * @type {Discord.TextChannel?}\n */\n this.textChannel = textChannel;\n /**\n * Timeout for checking empty channel\n * @type {*}\n * @private\n */\n this.emptyTimeout = undefined;\n /**\n * Task queuing system\n * @type {TaskQueue}\n * @private\n */\n this.taskQueue = new TaskQueue();\n /**\n * DisTubeVoice listener\n * @type {Object}\n * @private\n */\n this.listeners = undefined;\n }\n /**\n * Formatted duration string.\n * @type {string}\n */\n get formattedDuration() {\n return formatDuration(this.duration);\n }\n /**\n * Queue's duration.\n * @type {number}\n */\n get duration() {\n return this.songs.length ? this.songs.reduce((prev, next) => prev + next.duration, 0) : 0;\n }\n /**\n * What time in the song is playing (in seconds).\n * @type {number}\n */\n get currentTime() {\n return this.voice.playbackDuration + this.beginTime;\n }\n /**\n * Formatted {@link Queue#currentTime} string.\n * @type {string}\n */\n get formattedCurrentTime() {\n return formatDuration(this.currentTime);\n }\n /**\n * The voice channel playing in.\n * @type {Discord.VoiceChannel|Discord.StageChannel|null}\n */\n get voiceChannel() {\n return this.clientMember.voice.channel;\n }\n get volume() {\n return this.voice.volume;\n }\n set volume(value: number) {\n this.voice.volume = value;\n }\n /**\n * @private\n * Add a Song or an array of Song to the queue\n * @param {Song|Song[]} song Song to add\n * @param {number} [position=0] Position to add, <= 0 to add to the end of the queue\n * @throws {Error}\n * @returns {Queue} The guild queue\n */\n addToQueue(song: Song | Song[], position = 0): Queue {\n if (!song || (Array.isArray(song) && !song.length)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"Song\", \"Array<Song>\"], song, \"song\");\n }\n if (typeof position !== \"number\" || !Number.isInteger(position)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"integer\", position, \"position\");\n }\n if (position <= 0) {\n if (Array.isArray(song)) this.songs.push(...song);\n else this.songs.push(song);\n } else if (Array.isArray(song)) {\n this.songs.splice(position, 0, ...song);\n } else {\n this.songs.splice(position, 0, song);\n }\n if (Array.isArray(song)) song.map(s => delete s.formats);\n else delete song.formats;\n return this;\n }\n /**\n * Pause the guild stream\n * @returns {Queue} The guild queue\n */\n pause(): Queue {\n if (this.paused) throw new DisTubeError(\"PAUSED\");\n this.playing = false;\n this.paused = true;\n this.voice.pause();\n return this;\n }\n /**\n * Resume the guild stream\n * @returns {Queue} The guild queue\n */\n resume(): Queue {\n if (this.playing) throw new DisTubeError(\"RESUMED\");\n this.playing = true;\n this.paused = false;\n this.voice.unpause();\n return this;\n }\n /**\n * Set the guild stream's volume\n * @param {number} percent The percentage of volume you want to set\n * @returns {Queue} The guild queue\n */\n setVolume(percent: number): Queue {\n this.volume = percent;\n return this;\n }\n\n /**\n * Skip the playing song if there is a next song in the queue.\n * <info>If {@link Queue#autoplay} is `true` and there is no up next song,\n * DisTube will add and play a related song.</info>\n * @returns {Promise<Song>} The song will skip to\n * @throws {Error}\n */\n async skip(): Promise<Song> {\n await this.taskQueue.queuing();\n try {\n if (this.songs.length <= 1) {\n if (this.autoplay) await this.addRelatedSong();\n else throw new DisTubeError(\"NO_UP_NEXT\");\n }\n const song = this.songs[1];\n this.next = true;\n this.voice.stop();\n return song;\n } finally {\n this.taskQueue.resolve();\n }\n }\n\n /**\n * Play the previous song if exists\n * @returns {Song} The guild queue\n * @throws {Error}\n */\n async previous(): Promise<Song> {\n await this.taskQueue.queuing();\n try {\n if (!this.options.savePreviousSongs) throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n if (this.previousSongs?.length === 0 && this.repeatMode !== RepeatMode.QUEUE) {\n throw new DisTubeError(\"NO_PREVIOUS\");\n }\n const song =\n this.repeatMode === 2 ? this.songs[this.songs.length - 1] : this.previousSongs[this.previousSongs.length - 1];\n this.prev = true;\n this.voice.stop();\n return song;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Shuffle the queue's songs\n * @returns {Promise<Queue>} The guild queue\n */\n async shuffle(): Promise<Queue> {\n await this.taskQueue.queuing();\n try {\n const playing = this.songs.shift();\n if (playing === undefined) return this;\n for (let i = this.songs.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [this.songs[i], this.songs[j]] = [this.songs[j], this.songs[i]];\n }\n this.songs.unshift(playing);\n return this;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Jump to the song position in the queue.\n * The next one is 1, 2,...\n * The previous one is -1, -2,...\n * @param {number} position The song position to play\n * @returns {Promise<Queue>} The guild queue\n * @throws {Error} if `num` is invalid number\n */\n async jump(position: number): Promise<Queue> {\n await this.taskQueue.queuing();\n try {\n if (typeof position !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", position, \"position\");\n if (!position || position > this.songs.length || -position > this.previousSongs.length) {\n throw new DisTubeError(\"NO_SONG_POSITION\");\n }\n if (position > 0) {\n const nextSongs = this.songs.splice(position - 1);\n if (this.options.savePreviousSongs) {\n this.previousSongs.push(...this.songs);\n } else {\n this.previousSongs.push(...this.songs.map(s => ({ id: s.id } as Song)));\n }\n this.songs = nextSongs;\n this.next = true;\n } else if (!this.options.savePreviousSongs) {\n throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n } else {\n this.prev = true;\n if (position !== -1) this.songs.unshift(...this.previousSongs.splice(position + 1));\n }\n this.voice.stop();\n return this;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Set the repeat mode of the guild queue.\\\n * Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`\n * @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)\n * @returns {RepeatMode} The new repeat mode\n */\n setRepeatMode(mode?: RepeatMode): RepeatMode {\n if (mode !== undefined && !Object.values(RepeatMode).includes(mode)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"RepeatMode\", \"undefined\"], mode, \"mode\");\n }\n if (mode === undefined) this.repeatMode = (this.repeatMode + 1) % 3;\n else if (this.repeatMode === mode) this.repeatMode = RepeatMode.DISABLED;\n else this.repeatMode = mode;\n return this.repeatMode;\n }\n /**\n * Enable or disable filter(s) of the queue.\n * Available filters: {@link Filters}\n * @param {string|string[]|false} filter A filter name, an array of filter name or `false` to clear all the filters\n * @param {boolean} [force=false] Force enable the input filter(s) even if it's enabled\n * @returns {Array<string>} Enabled filters.\n * @throws {Error}\n */\n setFilter(filter: string | string[] | false, force = false): Array<string> {\n if (Array.isArray(filter)) {\n filter = filter.filter(f => Object.prototype.hasOwnProperty.call(this.distube.filters, f));\n if (!filter.length) throw new DisTubeError(\"EMPTY_FILTERED_ARRAY\", \"filter\", \"filter name\");\n for (const f of filter) {\n if (this.filters.includes(f)) {\n if (!force) this.filters.splice(this.filters.indexOf(f), 1);\n } else {\n this.filters.push(f);\n }\n }\n } else if (filter === false) {\n this.filters = [];\n } else if (!Object.prototype.hasOwnProperty.call(this.distube.filters, filter)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"filter name\", filter, \"filter\");\n } else if (this.filters.includes(filter)) {\n if (!force) this.filters.splice(this.filters.indexOf(filter), 1);\n } else {\n this.filters.push(filter);\n }\n this.beginTime = this.currentTime;\n this.queues.playSong(this);\n return this.filters;\n }\n /**\n * Set the playing time to another position\n * @param {number} time Time in seconds\n * @returns {Queue} The guild queue\n */\n seek(time: number): Queue {\n if (typeof time !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", time, \"time\");\n if (isNaN(time) || time < 0) throw new DisTubeError(\"NUMBER_COMPARE\", \"time\", \"bigger or equal to\", 0);\n this.beginTime = time;\n this.queues.playSong(this);\n return this;\n }\n /**\n * Add a related song of the playing song to the queue\n * @returns {Promise<Song>} The added song\n * @throws {Error}\n */\n async addRelatedSong(): Promise<Song> {\n if (!this.songs?.[0]) throw new DisTubeError(\"NO_PLAYING\");\n const related = this.songs[0].related.find(v => !this.previousSongs.map(s => s.id).includes(v.id));\n if (!related || !(related instanceof Song)) throw new DisTubeError(\"NO_RELATED\");\n const song = await this.handler.resolveSong(related, { member: this.clientMember, metadata: related.metadata });\n if (!(song instanceof Song)) throw new DisTubeError(\"CANNOT_PLAY_RELATED\");\n this.addToQueue(song);\n return song;\n }\n /**\n * Stop the guild stream and delete the queue\n */\n async stop() {\n await this.taskQueue.queuing();\n try {\n this.stopped = true;\n if (this.options.leaveOnStop) this.voice.leave();\n else this.voice.stop();\n this.delete();\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Delete the queue from the manager\n * (This does not leave the voice channel even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)\n * @private\n */\n delete() {\n this.stopped = true;\n this.songs = [];\n this.previousSongs = [];\n if (this.listeners) {\n for (const event of Object.keys(this.listeners) as (keyof DisTubeVoiceEvents)[]) {\n this.voice.removeListener(event, this.listeners[event]);\n }\n }\n this.queues.delete(this.id);\n this.emit(\"deleteQueue\", this);\n }\n /**\n * Toggle autoplay mode\n * @returns {boolean} Autoplay mode state\n */\n toggleAutoplay(): boolean {\n this.autoplay = !this.autoplay;\n return this.autoplay;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Queue.js","sourceRoot":"","sources":["../../src/struct/Queue.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kCAAqD;AACrD,0BAA+E;AAQ/E,MAAa,KAAM,SAAQ,kBAAW;IA0BpC,YAAY,OAAgB,EAAE,KAAmB,EAAE,IAAmB,EAAE,WAAmC;QACzG,KAAK,CAAC,OAAO,CAAC,CAAC;QAfjB,iCAAwB;QAoBtB,IAAI,CAAC,YAAY;YACf,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE;gBACvB,CAAC,GAAG,EAAE;oBACJ,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,aAAa,EAAE,IAAI,EAAE,yBAAyB,CAAC,CAAC;gBACzF,CAAC,CAAC,EAAE,CAAC;QAKP,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAKnB,IAAI,CA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ACxB,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAiC,EAAE;gBAChF,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;aAC1D;SACF;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IAKD,cAAc;QACZ,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AA7aD,sBA6aC","sourcesContent":["import { DisTubeBase, FilterManager } from \"../core\";\nimport { DisTubeError, RepeatMode, Song, TaskQueue, formatDuration } from \"..\";\nimport type { DisTube, DisTubeVoice, DisTubeVoiceEvents } from \"..\";\nimport type { GuildMember, GuildTextBasedChannel, Snowflake } from \"discord.js\";\n\n/**\n * Represents a queue.\n * @extends DisTubeBase\n */\nexport class Queue extends DisTubeBase {\n readonly id: Snowflake;\n voice: DisTubeVoice;\n songs: Song[];\n previousSongs: Song[];\n stopped: boolean;\n _next: boolean;\n _prev: boolean;\n playing: boolean;\n paused: boolean;\n repeatMode: RepeatMode;\n autoplay: boolean;\n #filters: FilterManager;\n beginTime: number;\n textChannel?: GuildTextBasedChannel;\n _emptyTimeout?: NodeJS.Timeout;\n clientMember: GuildMember;\n _taskQueue: TaskQueue;\n _listeners?: DisTubeVoiceEvents;\n /**\n * Create a queue for the guild\n * @param {DisTube} distube DisTube\n * @param {DisTubeVoice} voice Voice connection\n * @param {Song|Song[]} song First song(s)\n * @param {Discord.BaseGuildTextChannel?} textChannel Default text channel\n */\n constructor(distube: DisTube, voice: DisTubeVoice, song: Song | Song[], textChannel?: GuildTextBasedChannel) {\n super(distube);\n /**\n * The client user as a `GuildMember` of this queue's guild\n * @type {Discord.GuildMember}\n */\n this.clientMember =\n voice.channel.guild?.me ??\n (() => {\n throw new DisTubeError(\"INVALID_TYPE\", \"GuildMember\", null, \"<VoiceChannel>.guild.me\");\n })();\n /**\n * Voice connection of this queue.\n * @type {DisTubeVoice}\n */\n this.voice = voice;\n /**\n * Queue id (Guild id)\n * @type {Discord.Snowflake}\n */\n this.id = voice.id;\n /**\n * Get or set the stream volume. Default value: `50`.\n * @type {number}\n */\n this.volume = 50;\n /**\n * List of songs in the queue (The first one is the playing song)\n * @type {Array<Song>}\n */\n this.songs = Array.isArray(song) ? [...song] : [song];\n /**\n * List of the previous songs.\n * @type {Array<Song>}\n */\n this.previousSongs = [];\n /**\n * Whether stream is currently stopped.\n * @type {boolean}\n * @private\n */\n this.stopped = false;\n /**\n * Whether or not the last song was skipped to next song.\n * @type {boolean}\n * @private\n */\n this._next = false;\n /**\n * Whether or not the last song was skipped to previous song.\n * @type {boolean}\n * @private\n */\n this._prev = false;\n /**\n * Whether or not the stream is currently playing.\n * @type {boolean}\n */\n this.playing = true;\n /**\n * Whether or not the stream is currently paused.\n * @type {boolean}\n */\n this.paused = false;\n /**\n * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).\n * Default value: `0` (disabled)\n * @type {RepeatMode}\n */\n this.repeatMode = RepeatMode.DISABLED;\n /**\n * Whether or not the autoplay mode is enabled.\n * Default value: `false`\n * @type {boolean}\n */\n this.autoplay = false;\n this.#filters = new FilterManager(distube, this);\n /**\n * What time in the song to begin (in seconds).\n * @type {number}\n */\n this.beginTime = 0;\n /**\n * The text channel of the Queue. (Default: where the first command is called).\n * @type {Discord.TextChannel?}\n */\n this.textChannel = textChannel;\n /**\n * Timeout for checking empty channel\n * @type {*}\n * @private\n */\n this._emptyTimeout = undefined;\n /**\n * Task queuing system\n * @type {TaskQueue}\n * @private\n */\n this._taskQueue = new TaskQueue();\n /**\n * DisTubeVoice listener\n * @type {Object}\n * @private\n */\n this._listeners = undefined;\n }\n /**\n * The filter manager of the queue\n * @type {FilterManager}\n * @readonly\n */\n get filters() {\n return this.#filters;\n }\n /**\n * Formatted duration string.\n * @type {string}\n * @readonly\n */\n get formattedDuration() {\n return formatDuration(this.duration);\n }\n /**\n * Queue's duration.\n * @type {number}\n * @readonly\n */\n get duration() {\n return this.songs.length ? this.songs.reduce((prev, next) => prev + next.duration, 0) : 0;\n }\n /**\n * What time in the song is playing (in seconds).\n * @type {number}\n * @readonly\n */\n get currentTime() {\n return this.voice.playbackDuration + this.beginTime;\n }\n /**\n * Formatted {@link Queue#currentTime} string.\n * @type {string}\n * @readonly\n */\n get formattedCurrentTime() {\n return formatDuration(this.currentTime);\n }\n /**\n * The voice channel playing in.\n * @type {Discord.VoiceChannel|Discord.StageChannel|null}\n * @readonly\n */\n get voiceChannel() {\n return this.clientMember.voice.channel;\n }\n get volume() {\n return this.voice.volume;\n }\n set volume(value: number) {\n this.voice.volume = value;\n }\n /**\n * @private\n * Add a Song or an array of Song to the queue\n * @param {Song|Song[]} song Song to add\n * @param {number} [position=0] Position to add, <= 0 to add to the end of the queue\n * @throws {Error}\n * @returns {Queue} The guild queue\n */\n addToQueue(song: Song | Song[], position = 0): Queue {\n if (!song || (Array.isArray(song) && !song.length)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"Song\", \"Array<Song>\"], song, \"song\");\n }\n if (typeof position !== \"number\" || !Number.isInteger(position)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"integer\", position, \"position\");\n }\n if (position <= 0) {\n if (Array.isArray(song)) this.songs.push(...song);\n else this.songs.push(song);\n } else if (Array.isArray(song)) {\n this.songs.splice(position, 0, ...song);\n } else {\n this.songs.splice(position, 0, song);\n }\n if (Array.isArray(song)) song.map(s => delete s.formats);\n else delete song.formats;\n return this;\n }\n /**\n * Pause the guild stream\n * @returns {Queue} The guild queue\n */\n pause(): Queue {\n if (this.paused) throw new DisTubeError(\"PAUSED\");\n this.playing = false;\n this.paused = true;\n this.voice.pause();\n return this;\n }\n /**\n * Resume the guild stream\n * @returns {Queue} The guild queue\n */\n resume(): Queue {\n if (this.playing) throw new DisTubeError(\"RESUMED\");\n this.playing = true;\n this.paused = false;\n this.voice.unpause();\n return this;\n }\n /**\n * Set the guild stream's volume\n * @param {number} percent The percentage of volume you want to set\n * @returns {Queue} The guild queue\n */\n setVolume(percent: number): Queue {\n this.volume = percent;\n return this;\n }\n\n /**\n * Skip the playing song if there is a next song in the queue.\n * <info>If {@link Queue#autoplay} is `true` and there is no up next song,\n * DisTube will add and play a related song.</info>\n * @returns {Promise<Song>} The song will skip to\n * @throws {Error}\n */\n async skip(): Promise<Song> {\n await this._taskQueue.queuing();\n try {\n if (this.songs.length <= 1) {\n if (this.autoplay) await this.addRelatedSong();\n else throw new DisTubeError(\"NO_UP_NEXT\");\n }\n const song = this.songs[1];\n this._next = true;\n this.voice.stop();\n return song;\n } finally {\n this._taskQueue.resolve();\n }\n }\n\n /**\n * Play the previous song if exists\n * @returns {Song} The guild queue\n * @throws {Error}\n */\n async previous(): Promise<Song> {\n await this._taskQueue.queuing();\n try {\n if (!this.options.savePreviousSongs) throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n if (this.previousSongs?.length === 0 && this.repeatMode !== RepeatMode.QUEUE) {\n throw new DisTubeError(\"NO_PREVIOUS\");\n }\n const song =\n this.repeatMode === 2 ? this.songs[this.songs.length - 1] : this.previousSongs[this.previousSongs.length - 1];\n this._prev = true;\n this.voice.stop();\n return song;\n } finally {\n this._taskQueue.resolve();\n }\n }\n /**\n * Shuffle the queue's songs\n * @returns {Promise<Queue>} The guild queue\n */\n async shuffle(): Promise<Queue> {\n await this._taskQueue.queuing();\n try {\n const playing = this.songs.shift();\n if (playing === undefined) return this;\n for (let i = this.songs.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [this.songs[i], this.songs[j]] = [this.songs[j], this.songs[i]];\n }\n this.songs.unshift(playing);\n return this;\n } finally {\n this._taskQueue.resolve();\n }\n }\n /**\n * Jump to the song position in the queue.\n * The next one is 1, 2,...\n * The previous one is -1, -2,...\n * @param {number} position The song position to play\n * @returns {Promise<Song>} The new Song will be played\n * @throws {Error} if `num` is invalid number\n */\n async jump(position: number): Promise<Song> {\n await this._taskQueue.queuing();\n try {\n if (typeof position !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", position, \"position\");\n if (!position || position > this.songs.length || -position > this.previousSongs.length) {\n throw new DisTubeError(\"NO_SONG_POSITION\");\n }\n let nextSong: Song;\n if (position > 0) {\n const nextSongs = this.songs.splice(position - 1);\n if (this.options.savePreviousSongs) {\n this.previousSongs.push(...this.songs);\n } else {\n this.previousSongs.push(...this.songs.map(s => ({ id: s.id } as Song)));\n }\n this.songs = nextSongs;\n this._next = true;\n nextSong = nextSongs[1];\n } else if (!this.options.savePreviousSongs) {\n throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n } else {\n this._prev = true;\n if (position !== -1) this.songs.unshift(...this.previousSongs.splice(position + 1));\n nextSong = this.previousSongs[this.previousSongs.length - 1];\n }\n this.voice.stop();\n return nextSong;\n } finally {\n this._taskQueue.resolve();\n }\n }\n /**\n * Set the repeat mode of the guild queue.\\\n * Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`\n * @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)\n * @returns {RepeatMode} The new repeat mode\n */\n setRepeatMode(mode?: RepeatMode): RepeatMode {\n if (mode !== undefined && !Object.values(RepeatMode).includes(mode)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"RepeatMode\", \"undefined\"], mode, \"mode\");\n }\n if (mode === undefined) this.repeatMode = (this.repeatMode + 1) % 3;\n else if (this.repeatMode === mode) this.repeatMode = RepeatMode.DISABLED;\n else this.repeatMode = mode;\n return this.repeatMode;\n }\n /**\n * Set the playing time to another position\n * @param {number} time Time in seconds\n * @returns {Queue} The guild queue\n */\n seek(time: number): Queue {\n if (typeof time !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", time, \"time\");\n if (isNaN(time) || time < 0) throw new DisTubeError(\"NUMBER_COMPARE\", \"time\", \"bigger or equal to\", 0);\n this.beginTime = time;\n this.queues.playSong(this);\n return this;\n }\n /**\n * Add a related song of the playing song to the queue\n * @returns {Promise<Song>} The added song\n * @throws {Error}\n */\n async addRelatedSong(): Promise<Song> {\n if (!this.songs?.[0]) throw new DisTubeError(\"NO_PLAYING\");\n const related = this.songs[0].related.find(v => !this.previousSongs.map(s => s.id).includes(v.id));\n if (!related || !(related instanceof Song)) throw new DisTubeError(\"NO_RELATED\");\n const song = await this.handler.resolveSong(related, { member: this.clientMember, metadata: related.metadata });\n if (!(song instanceof Song)) throw new DisTubeError(\"CANNOT_PLAY_RELATED\");\n this.addToQueue(song);\n return song;\n }\n /**\n * Stop the guild stream and delete the queue\n */\n async stop() {\n await this._taskQueue.queuing();\n try {\n this.playing = false;\n this.paused = false;\n this.stopped = true;\n if (this.options.leaveOnStop) this.voice.leave();\n else this.voice.stop();\n this.remove();\n } finally {\n this._taskQueue.resolve();\n }\n }\n /**\n * Remove the queue from the manager\n * (This does not leave the voice channel even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)\n * @private\n */\n remove() {\n this.stopped = true;\n this.songs = [];\n this.previousSongs = [];\n if (this._listeners) {\n for (const event of Object.keys(this._listeners) as (keyof DisTubeVoiceEvents)[]) {\n this.voice.removeListener(event, this._listeners[event]);\n }\n }\n this.queues.remove(this.id);\n this.emit(\"deleteQueue\", this);\n }\n /**\n * Toggle autoplay mode\n * @returns {boolean} Autoplay mode state\n */\n toggleAutoplay(): boolean {\n this.autoplay = !this.autoplay;\n return this.autoplay;\n }\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { Playlist, Video } from "@distube/ytsr";
|
|
2
|
-
/** Class representing a search result. */
|
|
3
2
|
export declare class SearchResult {
|
|
4
3
|
source: "youtube";
|
|
5
4
|
type: "video" | "playlist";
|
|
@@ -11,17 +10,10 @@ export declare class SearchResult {
|
|
|
11
10
|
duration?: number;
|
|
12
11
|
formattedDuration?: string;
|
|
13
12
|
thumbnail?: string;
|
|
14
|
-
/** Video or playlist uploader */
|
|
15
13
|
uploader: {
|
|
16
|
-
/** Uploader name */
|
|
17
14
|
name?: string;
|
|
18
|
-
/** Uploader url */
|
|
19
15
|
url?: string;
|
|
20
16
|
};
|
|
21
|
-
/**
|
|
22
|
-
* Create a search result
|
|
23
|
-
* @param {Object} info ytsr result
|
|
24
|
-
*/
|
|
25
17
|
constructor(info: Video | Playlist);
|
|
26
18
|
}
|
|
27
19
|
//# sourceMappingURL=SearchResult.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchResult.d.ts","sourceRoot":"","sources":["../../src/struct/SearchResult.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"SearchResult.d.ts","sourceRoot":"","sources":["../../src/struct/SearchResult.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAGrD,qBAAa,YAAY;IACvB,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,QAAQ,EAAE;QAER,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;gBAKU,IAAI,EAAE,KAAK,GAAG,QAAQ;CA+DnC"}
|