distube 3.2.3 → 3.3.0
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/DisTube.d.ts +28 -20
- package/dist/DisTube.d.ts.map +1 -1
- package/dist/DisTube.js +32 -5
- package/dist/DisTube.js.map +1 -1
- package/dist/core/DisTubeHandler.d.ts +7 -0
- package/dist/core/DisTubeHandler.d.ts.map +1 -1
- package/dist/core/DisTubeHandler.js +10 -11
- package/dist/core/DisTubeHandler.js.map +1 -1
- package/dist/core/DisTubeOptions.d.ts.map +1 -1
- package/dist/core/DisTubeOptions.js +3 -1
- package/dist/core/DisTubeOptions.js.map +1 -1
- package/dist/struct/CustomPlugin.d.ts +18 -20
- package/dist/struct/CustomPlugin.d.ts.map +1 -1
- package/dist/struct/CustomPlugin.js +14 -6
- 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 -1
- package/dist/struct/DisTubeError.js.map +1 -1
- package/dist/struct/Queue.d.ts +3 -3
- package/dist/struct/Queue.d.ts.map +1 -1
- package/dist/struct/Queue.js +21 -19
- package/dist/struct/Queue.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/type.d.ts +11 -0
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/package.json +1 -1
package/dist/DisTube.d.ts
CHANGED
|
@@ -43,8 +43,12 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
43
43
|
* @param {string|Song|SearchResult|Playlist} song URL | Search string |
|
|
44
44
|
* {@link Song} | {@link SearchResult} | {@link Playlist}
|
|
45
45
|
* @param {Object} [options] Optional options
|
|
46
|
-
* @param {boolean} [options.skip=false]
|
|
47
|
-
*
|
|
46
|
+
* @param {boolean} [options.skip=false]
|
|
47
|
+
* Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
|
|
48
|
+
* If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
|
|
49
|
+
* @param {number} [options.position=0] Position of the song/playlist to add to the queue,
|
|
50
|
+
* <= 0 to add to the end of the queue.
|
|
51
|
+
* @param {boolean} [options.unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
|
|
48
52
|
* (after the playing song if exists)
|
|
49
53
|
* @param {Discord.GuildMember} [options.member] Requested user (default is your bot)
|
|
50
54
|
* @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}
|
|
@@ -68,32 +72,29 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
68
72
|
*/
|
|
69
73
|
play(voiceChannel: VoiceBasedChannel, song: string | Song | SearchResult | Playlist | null, options?: {
|
|
70
74
|
skip?: boolean;
|
|
71
|
-
|
|
75
|
+
position?: number;
|
|
72
76
|
member?: GuildMember;
|
|
73
77
|
textChannel?: GuildTextBasedChannel;
|
|
74
78
|
message?: Message;
|
|
75
79
|
metadata?: any;
|
|
76
80
|
}): Promise<void>;
|
|
77
|
-
/**
|
|
78
|
-
* Play / add a song or playlist from url. Search and play a song if it is not a valid url.
|
|
79
|
-
*
|
|
80
|
-
* @param {Discord.Message} message A message from guild channel
|
|
81
|
-
* @param {string|Song|SearchResult|Playlist} song URL | Search string |
|
|
82
|
-
* {@link Song} | {@link SearchResult} | {@link Playlist}
|
|
83
|
-
* @param {Object} [options] Optional options
|
|
84
|
-
* @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly
|
|
85
|
-
* @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue
|
|
86
|
-
* (after the playing song if exists)
|
|
87
|
-
* @param {*} [options.metadata] Optional metadata that can be attached to the song/playlist will be played,
|
|
88
|
-
* This is useful for identification purposes when the song/playlist is passed around in events.
|
|
89
|
-
* See {@link Song#metadata} or {@link Playlist#metadata}
|
|
90
|
-
* @deprecated Message parameter is deprecated, use VoiceChannel instead. See {@link DisTube#play}
|
|
91
|
-
*/
|
|
81
|
+
/** @deprecated Message parameter is deprecated, use VoiceChannel instead. */
|
|
92
82
|
play(message: Message<true>, song: string | Song | SearchResult | Playlist, options?: {
|
|
93
83
|
skip?: boolean;
|
|
94
84
|
unshift?: boolean;
|
|
95
85
|
metadata?: any;
|
|
96
86
|
}): Promise<void>;
|
|
87
|
+
/** @deprecated `options.unshift` is deprecated, use `options.position` instead */
|
|
88
|
+
play(voiceChannel: VoiceBasedChannel, song: string | Song | SearchResult | Playlist | null, options?: {
|
|
89
|
+
skip?: boolean;
|
|
90
|
+
/** @deprecated Use `options.position` instead */
|
|
91
|
+
unshift?: boolean;
|
|
92
|
+
position?: number;
|
|
93
|
+
member?: GuildMember;
|
|
94
|
+
textChannel?: GuildTextBasedChannel;
|
|
95
|
+
message?: Message;
|
|
96
|
+
metadata?: any;
|
|
97
|
+
}): Promise<void>;
|
|
97
98
|
/**
|
|
98
99
|
* Play / add a song or playlist from url. Search and play a song if it is not a valid url.
|
|
99
100
|
*
|
|
@@ -102,8 +103,12 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
102
103
|
* @param {string|Song|SearchResult|Playlist} song URL | Search string |
|
|
103
104
|
* {@link Song} | {@link SearchResult} | {@link Playlist}
|
|
104
105
|
* @param {Object} [options] Optional options
|
|
105
|
-
* @param {boolean} [options.skip=false]
|
|
106
|
-
*
|
|
106
|
+
* @param {boolean} [options.skip=false]
|
|
107
|
+
* Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
|
|
108
|
+
* If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
|
|
109
|
+
* @param {number} [options.position=0] Position of the song/playlist to add to the queue,
|
|
110
|
+
* <= 0 to add to the end of the queue.
|
|
111
|
+
* @param {boolean} [options.unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
|
|
107
112
|
* (after the playing song if exists)
|
|
108
113
|
* @param {Discord.GuildMember} [options.member] Requested user (default is your bot)
|
|
109
114
|
* @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}
|
|
@@ -116,6 +121,7 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
116
121
|
playVoiceChannel(voiceChannel: VoiceBasedChannel, song: string | Song | SearchResult | Playlist | null, options?: {
|
|
117
122
|
skip?: boolean;
|
|
118
123
|
unshift?: boolean;
|
|
124
|
+
position?: number;
|
|
119
125
|
member?: GuildMember;
|
|
120
126
|
textChannel?: GuildTextBasedChannel;
|
|
121
127
|
message?: Message;
|
|
@@ -168,7 +174,9 @@ export declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
168
174
|
*/
|
|
169
175
|
playCustomPlaylist(message: Message<true>, songs: Array<string | Song | SearchResult>, properties?: Record<string, any>, options?: {
|
|
170
176
|
skip?: boolean;
|
|
177
|
+
/** @deprecated */
|
|
171
178
|
unshift?: boolean;
|
|
179
|
+
position?: number;
|
|
172
180
|
parallel?: boolean;
|
|
173
181
|
metadata?: any;
|
|
174
182
|
}): Promise<void>;
|
package/dist/DisTube.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTube.d.ts","sourceRoot":"","sources":["../src/DisTube.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAEL,cAAc,EACd,mBAAmB,EAGnB,OAAO,EACP,QAAQ,EACR,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,IAAI,EAQL,MAAM,GAAG,CAAC;AACX,OAAO,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,OAAO,EAAe,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACtH,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,GAAG,CAAC;AAMlH,eAAO,MAAQ,OAAO,QAAoD,CAAC;AAE3E;;;GAGG;AACH,q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;;;;;;;;GAkBG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;GAQG;AAEH;;;;;GAKG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG"}
|
package/dist/DisTube.js
CHANGED
|
@@ -114,6 +114,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
114
114
|
const vc = member.voice.channel;
|
|
115
115
|
if (!vc)
|
|
116
116
|
throw new _1.DisTubeError("NOT_IN_VOICE");
|
|
117
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
117
118
|
return this.play(vc, song, {
|
|
118
119
|
member,
|
|
119
120
|
textChannel,
|
|
@@ -129,11 +130,23 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
129
130
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
130
131
|
throw new _1.DisTubeError("INVALID_TYPE", "object", options, "options");
|
|
131
132
|
}
|
|
133
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
132
134
|
const { textChannel, member, skip, message, unshift, metadata } = Object.assign({
|
|
133
135
|
member: voiceChannel.guild.me,
|
|
134
136
|
skip: false,
|
|
135
137
|
unshift: false,
|
|
136
138
|
}, options);
|
|
139
|
+
let position = Number(options.position);
|
|
140
|
+
if (!position) {
|
|
141
|
+
if (skip && position !== 0)
|
|
142
|
+
position = 1;
|
|
143
|
+
else
|
|
144
|
+
position = 0;
|
|
145
|
+
}
|
|
146
|
+
if (unshift) {
|
|
147
|
+
process.emitWarning("'unshift' option in DisTube#play is deprecated, use 'position' instead.", "DeprecationWarning");
|
|
148
|
+
position = 1;
|
|
149
|
+
}
|
|
137
150
|
if (message && !(0, _1.isMessageInstance)(message)) {
|
|
138
151
|
throw new _1.DisTubeError("INVALID_TYPE", ["Discord.Message", "a falsy value"], message, "options.message");
|
|
139
152
|
}
|
|
@@ -165,7 +178,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
165
178
|
if (!song)
|
|
166
179
|
return;
|
|
167
180
|
if (song instanceof _1.Playlist) {
|
|
168
|
-
await this.handler.handlePlaylist(voiceChannel, song, { textChannel, skip,
|
|
181
|
+
await this.handler.handlePlaylist(voiceChannel, song, { textChannel, skip, position });
|
|
169
182
|
}
|
|
170
183
|
else if (!this.options.nsfw && song.age_restricted && !textChannel?.nsfw) {
|
|
171
184
|
throw new _1.DisTubeError("NON_NSFW");
|
|
@@ -173,7 +186,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
173
186
|
else {
|
|
174
187
|
queue = this.getQueue(voiceChannel);
|
|
175
188
|
if (queue) {
|
|
176
|
-
queue.addToQueue(song,
|
|
189
|
+
queue.addToQueue(song, position);
|
|
177
190
|
if (skip)
|
|
178
191
|
queue.skip();
|
|
179
192
|
else
|
|
@@ -213,8 +226,12 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
213
226
|
* @param {string|Song|SearchResult|Playlist} song URL | Search string |
|
|
214
227
|
* {@link Song} | {@link SearchResult} | {@link Playlist}
|
|
215
228
|
* @param {Object} [options] Optional options
|
|
216
|
-
* @param {boolean} [options.skip=false]
|
|
217
|
-
*
|
|
229
|
+
* @param {boolean} [options.skip=false]
|
|
230
|
+
* Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
|
|
231
|
+
* If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
|
|
232
|
+
* @param {number} [options.position=0] Position of the song/playlist to add to the queue,
|
|
233
|
+
* <= 0 to add to the end of the queue.
|
|
234
|
+
* @param {boolean} [options.unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
|
|
218
235
|
* (after the playing song if exists)
|
|
219
236
|
* @param {Discord.GuildMember} [options.member] Requested user (default is your bot)
|
|
220
237
|
* @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}
|
|
@@ -301,11 +318,21 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
301
318
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
302
319
|
throw new _1.DisTubeError("INVALID_TYPE", "object", options, "options");
|
|
303
320
|
}
|
|
321
|
+
// eslint-disable-next-line deprecation/deprecation
|
|
304
322
|
const { skip, unshift, parallel, metadata } = Object.assign({
|
|
305
323
|
skip: false,
|
|
306
324
|
unshift: false,
|
|
307
325
|
parallel: true,
|
|
308
326
|
}, options);
|
|
327
|
+
let position = Number(options.position);
|
|
328
|
+
if (!position) {
|
|
329
|
+
if (skip && position !== 0)
|
|
330
|
+
position = 1;
|
|
331
|
+
else
|
|
332
|
+
position = 0;
|
|
333
|
+
}
|
|
334
|
+
if (unshift)
|
|
335
|
+
position = 1;
|
|
309
336
|
const queue = this.getQueue(message);
|
|
310
337
|
const queuing = queue && !queue.taskQueue.hasResolveTask;
|
|
311
338
|
if (queuing)
|
|
@@ -320,7 +347,7 @@ class DisTube extends tiny_typed_emitter_1.TypedEmitter {
|
|
|
320
347
|
const voice = message.member?.voice?.channel;
|
|
321
348
|
if (!voice)
|
|
322
349
|
throw new _1.DisTubeError("NOT_IN_VOICE");
|
|
323
|
-
await this.play(voice, playlist, { textChannel: message.channel, skip,
|
|
350
|
+
await this.play(voice, playlist, { textChannel: message.channel, skip, position, metadata });
|
|
324
351
|
}
|
|
325
352
|
finally {
|
|
326
353
|
if (queuing)
|
package/dist/DisTube.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTube.js","sourceRoot":"","sources":["../src/DisTube.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAiC;AACjC,yDAAiC;AACjC,iCAA6C;AAC7C,2DAAkD;AAClD,wBAmBW;AAIX,0DAA0D;AAE1D,mDAAmD;AACnD,qGAAqG;AACtF,eAAO,GAA0B,OAAO,CAAC,iBAAiB,CAAC,SAAC;AAE3E;;;GAGG;AACH,MAAa,OAAQ,SAAQ,iCAA2B;IAStD;;;;;;;;;;;;OAYG;IACH,YAAY,MAAc,EAAE,MAAsB,EAAE;QAClD,KAAK,EA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AEH;;;;;;;;;;GAUG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;GAQG;AAEH;;;;;GAKG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG","sourcesContent":["import ytpl from \"@distube/ytpl\";\nimport ytsr from \"@distube/ytsr\";\nimport { checkIntents, isURL } from \"./util\";\nimport { TypedEmitter } from \"tiny-typed-emitter\";\nimport {\n DisTubeError,\n DisTubeHandler,\n DisTubeVoiceManager,\n HTTPPlugin,\n HTTPSPlugin,\n Options,\n Playlist,\n Queue,\n QueueManager,\n SearchResult,\n Song,\n YouTubeDLPlugin,\n defaultFilters,\n isClientInstance,\n isMemberInstance,\n isMessageInstance,\n isSupportedVoiceChannel,\n isTextChannelInstance,\n} from \".\";\nimport type { Client, GuildMember, GuildTextBasedChannel, Message, TextChannel, VoiceBasedChannel } from \"discord.js\";\nimport type { CustomPlugin, DisTubeEvents, DisTubeOptions, ExtractorPlugin, Filters, GuildIdResolvable } from \".\";\n\n// TODO: remove deprecated stuff on the next major version\n\n// Cannot be `import` as it's not under TS root dir\n// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports\nexport const { version }: { version: string } = require(\"../package.json\");\n\n/**\n * DisTube class\n * @extends EventEmitter\n */\nexport class DisTube extends TypedEmitter<DisTubeEvents> {\n readonly handler: DisTubeHandler;\n readonly options: Options;\n readonly client: Client;\n readonly queues: QueueManager;\n readonly voices: DisTubeVoiceManager;\n readonly extractorPlugins: ExtractorPlugin[];\n readonly customPlugins: CustomPlugin[];\n readonly filters: Filters;\n /**\n * Create a new DisTube class.\n * @param {Discord.Client} client Discord.JS client\n * @param {DisTubeOptions} [otp] Custom DisTube options\n * @example\n * const Discord = require('discord.js'),\n * DisTube = require('distube'),\n * client = new Discord.Client();\n * // Create a new DisTube\n * const distube = new DisTube.default(client, { searchSongs: 10 });\n * // client.DisTube = distube // make it access easily\n * client.login(\"Your Discord Bot Token\")\n */\n constructor(client: Client, otp: DisTubeOptions = {}) {\n super();\n this.setMaxListeners(1);\n if (!isClientInstance(client)) throw new DisTubeError(\"INVALID_TYPE\", \"Discord.Client\", client, \"client\");\n /**\n * Discord.JS client\n * @type {Discord.Client}\n */\n this.client = client;\n checkIntents(client.options);\n /**\n * DisTube options\n * @type {DisTubeOptions}\n */\n this.options = new Options(otp);\n /**\n * Voice connections manager\n * @type {DisTubeVoiceManager}\n */\n this.voices = new DisTubeVoiceManager(this);\n /**\n * DisTube's Handler\n * @type {DisTubeHandler}\n * @private\n */\n this.handler = new DisTubeHandler(this);\n /**\n * Queues manager\n * @type {QueueManager}\n */\n this.queues = new QueueManager(this);\n /**\n * DisTube filters\n * @type {Filters}\n */\n this.filters = defaultFilters;\n Object.assign(this.filters, this.options.customFilters);\n // Default plugin\n this.options.plugins.push(new HTTPPlugin(), new HTTPSPlugin());\n if (this.options.youtubeDL) this.options.plugins.push(new YouTubeDLPlugin(this.options.updateYouTubeDL));\n this.options.plugins.map(p => p.init(this));\n /**\n * Extractor Plugins\n * @type {ExtractorPlugin[]}\n * @private\n */\n this.extractorPlugins = this.options.plugins.filter((p): p is ExtractorPlugin => p.type === \"extractor\");\n /**\n * Custom Plugins\n * @type {CustomPlugin[]}\n * @private\n */\n this.customPlugins = this.options.plugins.filter((p): p is CustomPlugin => p.type === \"custom\");\n }\n\n static get version() {\n return version;\n }\n\n /**\n * DisTube version\n * @type {string}\n */\n get version() {\n return version;\n }\n\n /**\n * Play / add a song or playlist from url. Search and play a song if it is not a valid url.\n *\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string|Song|SearchResult|Playlist} song URL | Search string |\n * {@link Song} | {@link SearchResult} | {@link Playlist}\n * @param {Object} [options] Optional options\n * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly\n * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue\n * (after the playing song if exists)\n * @param {Discord.GuildMember} [options.member] Requested user (default is your bot)\n * @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}\n * @param {Discord.Message} [options.message] Called message (For built-in search events. If this is a {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy|falsy value}, it will play the first result instead)\n * @param {*} [options.metadata] Optional metadata that can be attached to the song/playlist will be played,\n * This is useful for identification purposes when the song/playlist is passed around in events.\n * See {@link Song#metadata} or {@link Playlist#metadata}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"play\")\n * distube.play(message.member.voice?.channel, args.join(\" \"), {\n * member: message.member,\n * textChannel: message.channel,\n * message\n * });\n * });\n * @returns {Promise<void>}\n */\n async play(\n voiceChannel: VoiceBasedChannel,\n song: string | Song | SearchResult | Playlist | null,\n options?: {\n skip?: boolean;\n unshift?: boolean;\n member?: GuildMember;\n textChannel?: GuildTextBasedChannel;\n message?: Message;\n metadata?: any;\n },\n ): Promise<void>;\n /**\n * Play / add a song or playlist from url. Search and play a song if it is not a valid url.\n *\n * @param {Discord.Message} message A message from guild channel\n * @param {string|Song|SearchResult|Playlist} song URL | Search string |\n * {@link Song} | {@link SearchResult} | {@link Playlist}\n * @param {Object} [options] Optional options\n * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly\n * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue\n * (after the playing song if exists)\n * @param {*} [options.metadata] Optional metadata that can be attached to the song/playlist will be played,\n * This is useful for identification purposes when the song/playlist is passed around in events.\n * See {@link Song#metadata} or {@link Playlist#metadata}\n * @deprecated Message parameter is deprecated, use VoiceChannel instead. See {@link DisTube#play}\n */\n async play(\n message: Message<true>,\n song: string | Song | SearchResult | Playlist,\n options?: { skip?: boolean; unshift?: boolean; metadata?: any },\n ): Promise<void>;\n async play(\n voiceChannel: Message<true> | VoiceBasedChannel,\n song: string | Song | SearchResult | Playlist | null,\n options: {\n skip?: boolean;\n unshift?: boolean;\n member?: GuildMember;\n textChannel?: GuildTextBasedChannel;\n message?: Message;\n metadata?: any;\n } = {},\n ): Promise<void> {\n if (isMessageInstance(voiceChannel)) {\n process.emitWarning(\n \"Passing Message for DisTube#play is deprecated, use BaseGuildVoiceChannel instead.\",\n \"DeprecationWarning\",\n );\n const message = voiceChannel;\n if (!song) throw new DisTubeError(\"INVALID_TYPE\", [\"string\", \"Song\", \"SearchResult\", \"Playlist\"], song, \"song\");\n if (!isMessageInstance(message)) throw new DisTubeError(\"INVALID_TYPE\", \"Discord.Message\", message, \"message\");\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options, \"options\");\n }\n\n const textChannel = message.channel;\n const { skip, unshift, metadata } = Object.assign({ skip: false, unshift: false }, options);\n const member = message.member as GuildMember;\n const vc = member.voice.channel;\n if (!vc) throw new DisTubeError(\"NOT_IN_VOICE\");\n return this.play(vc, song, {\n member,\n textChannel,\n skip,\n message,\n unshift,\n metadata,\n });\n }\n\n if (!isSupportedVoiceChannel(voiceChannel)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"BaseGuildVoiceChannel\", voiceChannel, \"voiceChannel\");\n }\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options, \"options\");\n }\n const { textChannel, member, skip, message, unshift, metadata } = Object.assign(\n {\n member: voiceChannel.guild.me,\n skip: false,\n unshift: false,\n },\n options,\n );\n if (message && !isMessageInstance(message)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"Discord.Message\", \"a falsy value\"], message, \"options.message\");\n }\n try {\n if (typeof song === \"string\") {\n for (const plugin of this.customPlugins) {\n if (await plugin.validate(song)) {\n return plugin.play(voiceChannel, song, options);\n }\n }\n }\n let queue = this.getQueue(voiceChannel);\n const queuing = !!queue && !queue.taskQueue.hasResolveTask;\n if (queuing) await queue?.taskQueue.queuing(true);\n try {\n if (song instanceof SearchResult && song.type === \"playlist\") song = song.url;\n if (typeof song === \"string\" && ytpl.validateID(song)) {\n song = await this.handler.resolvePlaylist(song, { member, metadata });\n }\n if (typeof song === \"string\" && !isURL(song)) {\n if (!message) song = (await this.search(song, { limit: 1 }))[0];\n else song = await this.handler.searchSong(message, song);\n }\n song = await this.handler.resolveSong(song, { member, metadata });\n if (!song) return;\n if (song instanceof Playlist) {\n await this.handler.handlePlaylist(voiceChannel, song, { textChannel, skip, unshift });\n } else if (!this.options.nsfw && song.age_restricted && !(textChannel as TextChannel)?.nsfw) {\n throw new DisTubeError(\"NON_NSFW\");\n } else {\n queue = this.getQueue(voiceChannel);\n if (queue) {\n queue.addToQueue(song, skip || unshift ? 1 : -1);\n if (skip) queue.skip();\n else this.emit(\"addSong\", queue, song);\n } else {\n const newQueue = await this.queues.create(voiceChannel, song, textChannel);\n if (newQueue instanceof Queue) {\n if (this.options.emitAddSongWhenCreatingQueue) this.emit(\"addSong\", newQueue, song);\n this.emit(\"playSong\", newQueue, song);\n }\n }\n }\n } finally {\n if (queuing) queue?.taskQueue.resolve();\n }\n } catch (e: any) {\n if (!(e instanceof DisTubeError)) {\n try {\n e.name = \"PlayError\";\n e.message = `${(song as Song)?.url || song}\\n${e.message}`;\n } catch {}\n }\n this.emitError(e, textChannel);\n }\n }\n\n /**\n * Play / add a song or playlist from url. Search and play a song if it is not a valid url.\n *\n * @returns {Promise<void>}\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string|Song|SearchResult|Playlist} song URL | Search string |\n * {@link Song} | {@link SearchResult} | {@link Playlist}\n * @param {Object} [options] Optional options\n * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly\n * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue\n * (after the playing song if exists)\n * @param {Discord.GuildMember} [options.member] Requested user (default is your bot)\n * @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}\n * @param {Discord.Message} [options.message] Called message (For built-in search events. If this is a {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy|falsy value}, it will play the first result instead)\n * @param {*} [options.metadata] Optional metadata that can be attached to the song/playlist will be played,\n * This is useful for identification purposes when the song/playlist is passed around in events.\n * See {@link Song#metadata} or {@link Playlist#metadata}\n * @deprecated Use {@link DisTube#play} instead\n */\n async playVoiceChannel(\n voiceChannel: VoiceBasedChannel,\n song: string | Song | SearchResult | Playlist | null,\n options: {\n skip?: boolean;\n unshift?: boolean;\n member?: GuildMember;\n textChannel?: GuildTextBasedChannel;\n message?: Message;\n metadata?: any;\n } = {},\n ): Promise<void> {\n process.emitWarning(\"DisTube#playVoiceChannel is deprecated, use DisTube#play instead.\", \"DeprecationWarning\");\n return this.play(voiceChannel, song, options);\n }\n\n /**\n * Create a custom playlist\n * @returns {Promise<Playlist>}\n * @param {Array<string|Song|SearchResult>} songs Array of url, Song or SearchResult\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.message] A message from guild channel | A guild member\n * @param {Object} [options.properties={}] Additional properties such as `name`\n * @param {boolean} [options.parallel=true] Whether or not fetch the songs in parallel\n * @param {*} [options.metadata] Metadata\n * @example\n * const songs = [\"https://www.youtube.com/watch?v=xxx\", \"https://www.youtube.com/watch?v=yyy\"];\n * const playlist = await distube.createCustomPlaylist(songs, {\n * member: message.member,\n * properties: { name: \"My playlist name\" },\n * parallel: true\n * });\n * distube.play(voiceChannel, playlist, { ... });\n */\n async createCustomPlaylist(\n songs: (string | Song | SearchResult)[],\n options: {\n member?: GuildMember;\n properties?: Record<string, any>;\n parallel?: boolean;\n metadata?: any;\n } = {},\n ): Promise<Playlist> {\n const { member, properties, parallel, metadata } = Object.assign({ parallel: true }, options);\n if (!Array.isArray(songs)) throw new DisTubeError(\"INVALID_TYPE\", \"Array\", songs, \"songs\");\n if (!songs.length) throw new DisTubeError(\"EMPTY_ARRAY\", \"songs\");\n const filteredSongs = songs.filter(\n song => song instanceof Song || (song instanceof SearchResult && song.type === \"video\") || isURL(song),\n );\n if (!filteredSongs.length) throw new DisTubeError(\"NO_VALID_SONG\");\n if (member && !isMemberInstance(member)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"Discord.Member\", member, \"options.member\");\n }\n if (!filteredSongs.length) throw new DisTubeError(\"NO_VALID_SONG\");\n let resolvedSongs: Song[];\n if (parallel) {\n const promises = filteredSongs.map((song: string | Song | SearchResult) =>\n this.handler.resolveSong(song, { member, metadata }).catch(() => undefined),\n );\n resolvedSongs = (await Promise.all(promises)).filter((s: any): s is Song => !!s);\n } else {\n const resolved = [];\n for (const song of filteredSongs) {\n resolved.push(await this.handler.resolveSong(song, { member, metadata }).catch(() => undefined));\n }\n resolvedSongs = resolved.filter((s: any): s is Song => !!s);\n }\n return new Playlist(resolvedSongs, { member, properties, metadata });\n }\n\n /**\n * <info>Shorthand method of {@link DisTube#createCustomPlaylist} and {@link DisTube#play}\n *\n * If you doesn't have a user message (interaction,...),\n * see {@link DisTube#createCustomPlaylist} example</info>\n *\n * Play or add array of video urls.\n * {@link DisTube#event:playSong} or {@link DisTube#event:addList} will be emitted\n * with `playlist`'s properties include `properties` parameter's properties such as\n * `user`, `songs`, `duration`, `formattedDuration`, `thumbnail` like {@link Playlist}\n * @returns {Promise<void>}\n * @param {Discord.Message} message A message from guild channel\n * @param {Array<string|Song|SearchResult>} songs Array of url, Song or SearchResult\n * @param {Object} [properties={}] Additional properties for playlist such as `name`\n * @param {Object} [options] Optional options\n * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly\n * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue\n * (after the playing song if exists)\n * @param {boolean} [options.parallel=true] Whether or not fetch the songs in parallel\n * @deprecated Use {@link DisTube#createCustomPlaylist} and {@link DisTube#play} instead\n */\n async playCustomPlaylist(\n message: Message<true>,\n songs: Array<string | Song | SearchResult>,\n properties: Record<string, any> = {},\n options: { skip?: boolean; unshift?: boolean; parallel?: boolean; metadata?: any } = {},\n ): Promise<void> {\n process.emitWarning(\n \"DisTube#playCustomPlaylist is deprecated, use DisTube#createCustomPlaylist and DisTube#play instead.\",\n \"DeprecationWarning\",\n );\n try {\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options, \"options\");\n }\n const { skip, unshift, parallel, metadata } = Object.assign(\n {\n skip: false,\n unshift: false,\n parallel: true,\n },\n options,\n );\n const queue = this.getQueue(message);\n const queuing = queue && !queue.taskQueue.hasResolveTask;\n if (queuing) await queue?.taskQueue.queuing(true);\n try {\n const playlist = await this.createCustomPlaylist(songs, {\n member: message.member ?? undefined,\n properties,\n parallel,\n metadata,\n });\n const voice = message.member?.voice?.channel;\n if (!voice) throw new DisTubeError(\"NOT_IN_VOICE\");\n await this.play(voice, playlist, { textChannel: message.channel, skip, unshift, metadata });\n } finally {\n if (queuing) queue?.taskQueue.resolve();\n }\n } catch (e: any) {\n this.emitError(e, message.channel);\n }\n }\n\n /**\n * Search for a song. You can customize how user answers instead of send a number.\n * Then use {@link DisTube#play} to play it.\n *\n * @param {string} string The string search for\n * @param {Object} options Search options\n * @param {number} [options.limit=10] Limit the results\n * @param {'video'|'playlist'} [options.type='video'] Type of results (`video` or `playlist`).\n * @param {boolean} [options.safeSearch=false] Whether or not use safe search (YouTube restricted mode)\n * @throws {Error}\n * @returns {Promise<Array<SearchResult>>} Array of results\n */\n async search(\n string: string,\n options: { type?: \"video\" | \"playlist\"; limit?: number; safeSearch?: boolean; retried?: boolean } = {},\n ): Promise<Array<SearchResult>> {\n const opts = Object.assign({ type: \"video\", limit: 10, safeSearch: false }, options);\n if (typeof opts.type !== \"string\" || ![\"video\", \"playlist\"].includes(opts.type)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"video\", \"playlist\"], opts.type, \"options.type\");\n }\n if (typeof opts.limit !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", opts.limit, \"options.limit\");\n if (opts.limit < 1) throw new DisTubeError(\"NUMBER_COMPARE\", \"option.limit\", \"bigger or equal to\", 1);\n if (typeof opts.safeSearch !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", opts.safeSearch, \"options.safeSearch\");\n }\n\n try {\n const search = await ytsr(string, opts);\n const results = search.items.map(i => new SearchResult(i));\n if (results.length === 0) throw new DisTubeError(\"NO_RESULT\");\n return results;\n } catch (e) {\n if (options.retried) throw e;\n options.retried = true;\n return this.search(string, options);\n }\n }\n\n /**\n * Get the guild queue\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Queue?}\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"queue\") {\n * const queue = distube.getQueue(message);\n * message.channel.send('Current queue:\\n' + queue.songs.map((song, id) =>\n * `**${id+1}**. [${song.name}](${song.url}) - \\`${song.formattedDuration}\\``\n * ).join(\"\\n\"));\n * }\n * });\n */\n getQueue(queue: GuildIdResolvable): Queue | undefined {\n return this.queues.get(queue);\n }\n\n /**\n * Pause the guild stream\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Queue} The guild queue\n * @throws {Error}\n */\n pause(queue: GuildIdResolvable): Queue {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.pause();\n }\n\n /**\n * Resume the guild stream\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Queue} The guild queue\n * @throws {Error}\n */\n resume(queue: GuildIdResolvable): Queue {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.resume();\n }\n\n /**\n * Stop the guild stream\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Promise<void>}\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"stop\") {\n * distube.stop(message);\n * message.channel.send(\"Stopped the queue!\");\n * }\n * });\n */\n stop(queue: GuildIdResolvable): Promise<void> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.stop();\n }\n\n /**\n * Set the guild stream's volume\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @param {number} percent The percentage of volume you want to set\n * @returns {Queue} The guild queue\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"volume\")\n * distube.setVolume(message, Number(args[0]));\n * });\n */\n setVolume(queue: GuildIdResolvable, percent: number): Queue {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.setVolume(percent);\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 * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Promise<Song>} The new Song will be played\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"skip\")\n * distube.skip(message);\n * });\n */\n skip(queue: GuildIdResolvable): Promise<Song> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.skip();\n }\n\n /**\n * Play the previous song\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Promise<Song>} The new Song will be played\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"previous\")\n * distube.previous(message);\n * });\n */\n previous(queue: GuildIdResolvable): Promise<Song> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.previous();\n }\n\n /**\n * Shuffle the guild queue songs\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Promise<Queue>} The guild queue\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"shuffle\")\n * distube.shuffle(message);\n * });\n */\n shuffle(queue: GuildIdResolvable): Promise<Queue> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.shuffle();\n }\n\n /**\n * Jump to the song number in the queue.\n * The next one is 1, 2,...\n * The previous one is -1, -2,...\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @param {number} num The song number to play\n * @returns {Promise<Queue>} The guild queue\n * @throws {Error} if `num` is invalid number (0 < num < {@link Queue#songs}.length)\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"jump\")\n * distube.jump(message, parseInt(args[0]))\n * .catch(err => message.channel.send(\"Invalid song number.\"));\n * });\n */\n jump(queue: GuildIdResolvable, num: number): Promise<Queue> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.jump(num);\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 {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)\n * @returns {RepeatMode} The new repeat mode\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"repeat\") {\n * let mode = distube.setRepeatMode(message, parseInt(args[0]));\n * mode = mode ? mode == 2 ? \"Repeat queue\" : \"Repeat song\" : \"Off\";\n * message.channel.send(\"Set repeat mode to `\" + mode + \"`\");\n * }\n * });\n * @example\n * const { RepeatMode } = require(\"distube\");\n * let mode;\n * switch(distube.setRepeatMode(message, parseInt(args[0]))) {\n * case RepeatMode.DISABLED:\n * mode = \"Off\";\n * break;\n * case RepeatMode.SONG:\n * mode = \"Repeat a song\";\n * break;\n * case RepeatMode.QUEUE:\n * mode = \"Repeat all queue\";\n * break;\n * }\n * message.channel.send(\"Set repeat mode to `\" + mode + \"`\");\n */\n setRepeatMode(queue: GuildIdResolvable, mode?: number): number {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.setRepeatMode(mode);\n }\n\n /**\n * Toggle autoplay mode\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {boolean} Autoplay mode state\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"autoplay\") {\n * const mode = distube.toggleAutoplay(message);\n * message.channel.send(\"Set autoplay mode to `\" + (mode ? \"On\" : \"Off\") + \"`\");\n * }\n * });\n */\n toggleAutoplay(queue: GuildIdResolvable): boolean {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n q.autoplay = !q.autoplay;\n return q.autoplay;\n }\n\n /**\n * Add related song to the queue\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Promise<Song>} The guild queue\n */\n addRelatedSong(queue: GuildIdResolvable): Promise<Song> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.addRelatedSong();\n }\n\n /**\n * Enable or disable filter(s) of the queue.\n * Available filters: {@link Filters}\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @param {string|false} filter A filter name, `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 * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if ([`3d`, `bassboost`, `echo`, `karaoke`, `nightcore`, `vaporwave`].includes(command)) {\n * const filter = distube.setFilter(message, command);\n * message.channel.send(\"Current queue filter: \" + (filter.join(\", \") || \"Off\"));\n * }\n * });\n */\n setFilter(queue: GuildIdResolvable, filter: string | false, force = false): Array<string> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.setFilter(filter, force);\n }\n\n /**\n * Set the playing time to another position\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @param {number} time Time in seconds\n * @returns {Queue} Seeked queue\n * @example\n * client.on('message', message => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command = 'seek')\n * distube.seek(message, Number(args[0]));\n * });\n */\n seek(queue: GuildIdResolvable, time: number): Queue {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.seek(time);\n }\n\n /* eslint-disable no-console */\n /**\n * Emit error event\n * @param {Error} error error\n * @param {Discord.BaseGuildTextChannel} [channel] Text channel where the error is encountered.\n * @private\n */\n emitError(error: Error, channel?: GuildTextBasedChannel): void {\n if (!channel || !isTextChannelInstance(channel)) {\n console.error(error);\n console.warn(\"This is logged because <Queue>.textChannel is undefined\");\n } else if (this.listeners(\"error\").length) {\n this.emit(\"error\", channel, error);\n } else {\n console.error(error);\n console.warn(\"Unhandled 'error' event.\");\n console.warn(\n \"See: https://distube.js.org/#/docs/DisTube/stable/class/DisTube?scrollTo=e-error and https://nodejs.org/api/events.html#events_error_events\",\n );\n }\n }\n /* eslint-enable no-console */\n}\n\nexport default DisTube;\n\n/**\n * Emitted after DisTube add a new playlist to the playing {@link Queue}.\n *\n * @event DisTube#addList\n * @param {Queue} queue The guild queue\n * @param {Playlist} playlist Playlist info\n * @example\n * distube.on(\"addList\", (queue, playlist) => queue.textChannel.send(\n * `Added \\`${playlist.name}\\` playlist (${playlist.songs.length} songs) to the queue!`\n * ));\n */\n\n/**\n * Emitted after DisTube add a new song to the playing {@link Queue}.\n *\n * @event DisTube#addSong\n * @param {Queue} queue The guild queue\n * @param {Song} song Added song\n * @example\n * distube.on(\"addSong\", (queue, song) => queue.textChannel.send(\n * `Added ${song.name} - \\`${song.formattedDuration}\\` to the queue by ${song.user}.`\n * ));\n */\n\n/**\n * Emitted when there is no user in the voice channel,\n * {@link DisTubeOptions}.leaveOnEmpty is `true` and there is a playing queue.\n *\n * If there is no playing queue (stopped and {@link DisTubeOptions}.leaveOnStop is `false`),\n * it will leave the channel without emitting this event.\n * @event DisTube#empty\n * @param {Queue} queue The guild queue\n * @example\n * distube.on(\"empty\", queue => queue.textChannel.send(\"Channel is empty. Leaving the channel\"))\n */\n\n/**\n * Emitted when DisTube encounters an error.\n *\n * @event DisTube#error\n * @param {Discord.BaseGuildTextChannel} channel Text channel where the error is encountered.\n * @param {Error} error The error encountered\n * @example\n * distube.on(\"error\", (channel, error) => channel.send(\n * \"An error encountered: \" + error\n * ));\n */\n\n/**\n * Emitted when there is no more song in the queue and {@link Queue#autoplay} is `false`.\n * DisTube will leave voice channel if {@link DisTubeOptions}.leaveOnFinish is `true`.\n *\n * @event DisTube#finish\n * @param {Queue} queue The guild queue\n * @example\n * distube.on(\"finish\", queue => queue.textChannel.send(\"No more song in queue\"));\n */\n\n/**\n * Emitted when DisTube initialize a queue to change queue default properties.\n *\n * @event DisTube#initQueue\n * @param {Queue} queue The guild queue\n * @example\n * distube.on(\"initQueue\", queue => {\n * queue.autoplay = false;\n * queue.volume = 100;\n * });\n */\n\n/**\n * Emitted when {@link Queue#autoplay} is `true`, {@link Queue#songs} is empty,\n * and DisTube cannot find related songs to play.\n *\n * @event DisTube#noRelated\n * @param {Queue} queue The guild queue\n * @example\n * distube.on(\"noRelated\", queue => queue.textChannel.send(\"Can't find related video to play.\"));\n */\n\n/**\n * Emitted when DisTube play a song.\n *\n * If {@link DisTubeOptions}.emitNewSongOnly is `true`,\n * this event is not emitted when looping a song or next song is the previous one.\n *\n * @event DisTube#playSong\n * @param {Queue} queue The guild queue\n * @param {Song} song Playing song\n * @example\n * distube.on(\"playSong\", (queue, song) => queue.textChannel.send(\n * `Playing \\`${song.name}\\` - \\`${song.formattedDuration}\\`\\nRequested by: ${song.user}`\n * ));\n */\n\n/**\n * Emitted when DisTube cannot find any results for the query.\n *\n * @event DisTube#searchNoResult\n * @param {Discord.Message} message The user message called play method\n * @param {string} query The search query\n * @example\n * distube.on(\"searchNoResult\", (message, query) => message.channel.send(`No result found for ${query}!`));\n */\n\n/**\n * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,\n * and song param of {@link DisTube#play} is invalid url.\n * DisTube will wait for user's next message to choose a song manually.\n * <info>{@link https://support.google.com/youtube/answer/7354993|Safe search} is enabled\n * if {@link DisTubeOptions}.nsfw is disabled and the message's channel is not a nsfw channel.</info>\n *\n * @event DisTube#searchResult\n * @param {Discord.Message} message The user message called play method\n * @param {Array<SearchResult>} results Searched results\n * @param {string} query The search query\n * @example\n * // DisTubeOptions.searchSongs > 0\n * distube.on(\"searchResult\", (message, results) => {\n * message.channel.send(`**Choose an option from below**\\n${\n * results.map((song, i) => `**${i + 1}**. ${song.name} - \\`${song.formattedDuration}\\``).join(\"\\n\")\n * }\\n*Enter anything else or wait 60 seconds to cancel*`);\n * });\n */\n\n/**\n * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,\n * and the search canceled due to {@link DisTubeOptions|DisTubeOptions.searchTimeout}.\n *\n * @event DisTube#searchCancel\n * @param {Discord.Message} message The user message called play method\n * @param {string} query The search query\n * @example\n * // DisTubeOptions.searchSongs > 0\n * distube.on(\"searchCancel\", (message) => message.channel.send(`Searching canceled`));\n */\n\n/**\n * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,\n * and the search canceled due to user's next message is not a number or out of results range.\n *\n * @event DisTube#searchInvalidAnswer\n * @param {Discord.Message} message The user message called play method\n * @param {Discord.Message} answer The answered message of user\n * @param {string} query The search query\n * @example\n * // DisTubeOptions.searchSongs > 0\n * distube.on(\"searchInvalidAnswer\", (message) => message.channel.send(`You answered an invalid number!`));\n */\n\n/**\n * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,\n * and after the user chose a search result to play.\n *\n * @event DisTube#searchDone\n * @param {Discord.Message} message The user message called play method\n * @param {Discord.Message} answer The answered message of user\n * @param {string} query The search query\n */\n\n/**\n * Emitted when the bot is disconnected to a voice channel.\n *\n * @event DisTube#disconnect\n * @param {Queue} queue The guild queue\n */\n\n/**\n * Emitted when a {@link Queue} is deleted with any reasons.\n *\n * @event DisTube#deleteQueue\n * @param {Queue} queue The guild queue\n */\n\n/**\n * Emitted when DisTube finished a song.\n *\n * @event DisTube#finishSong\n * @param {Queue} queue The guild queue\n * @param {Song} song Finished song\n */\n"]}
|
|
1
|
+
{"version":3,"file":"DisTube.js","sourceRoot":"","sources":["../src/DisTube.ts"],"names":[],"mappings":";;;;;;AAAA,yDAAiC;AACjC,yDAAiC;AACjC,iCAA6C;AAC7C,2DAAkD;AAClD,wBAmBW;AAIX,0DAA0D;AAE1D,mDAAmD;AACnD,qGAAqG;AACtF,eAAO,GAA0B,OAAO,CAAC,iBAAiB,CAAC,SAAC;AAE3E;;;GAGG;AACH,MAAa,OAAQ,SAAQ,iCAA2B;IAStD;;;;;;;;;;;;OAYG;IACH,YAAY,MAAc,EAAE,MAAsB,EAAE;QAClD,KA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AC,EAAE;YAC/C,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,yDAAyD,CAAC,CAAC;SACzE;aAAM,IAAI,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE;YACzC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;SACpC;aAAM;YACL,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACrB,OAAO,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;YACzC,OAAO,CAAC,IAAI,CACV,6IAA6I,CAC9I,CAAC;SACH;IACH,CAAC;CAEF;AA1yBD,0BA0yBC;AAED,kBAAe,OAAO,CAAC;AAEvB;;;;;;;;;;GAUG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;GAaG;AAEH;;;;;;;;GAQG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;GAWG;AAEH;;;;;;;;GAQG;AAEH;;;;;GAKG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG","sourcesContent":["import ytpl from \"@distube/ytpl\";\nimport ytsr from \"@distube/ytsr\";\nimport { checkIntents, isURL } from \"./util\";\nimport { TypedEmitter } from \"tiny-typed-emitter\";\nimport {\n DisTubeError,\n DisTubeHandler,\n DisTubeVoiceManager,\n HTTPPlugin,\n HTTPSPlugin,\n Options,\n Playlist,\n Queue,\n QueueManager,\n SearchResult,\n Song,\n YouTubeDLPlugin,\n defaultFilters,\n isClientInstance,\n isMemberInstance,\n isMessageInstance,\n isSupportedVoiceChannel,\n isTextChannelInstance,\n} from \".\";\nimport type { Client, GuildMember, GuildTextBasedChannel, Message, TextChannel, VoiceBasedChannel } from \"discord.js\";\nimport type { CustomPlugin, DisTubeEvents, DisTubeOptions, ExtractorPlugin, Filters, GuildIdResolvable } from \".\";\n\n// TODO: remove deprecated stuff on the next major version\n\n// Cannot be `import` as it's not under TS root dir\n// eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports\nexport const { version }: { version: string } = require(\"../package.json\");\n\n/**\n * DisTube class\n * @extends EventEmitter\n */\nexport class DisTube extends TypedEmitter<DisTubeEvents> {\n readonly handler: DisTubeHandler;\n readonly options: Options;\n readonly client: Client;\n readonly queues: QueueManager;\n readonly voices: DisTubeVoiceManager;\n readonly extractorPlugins: ExtractorPlugin[];\n readonly customPlugins: CustomPlugin[];\n readonly filters: Filters;\n /**\n * Create a new DisTube class.\n * @param {Discord.Client} client Discord.JS client\n * @param {DisTubeOptions} [otp] Custom DisTube options\n * @example\n * const Discord = require('discord.js'),\n * DisTube = require('distube'),\n * client = new Discord.Client();\n * // Create a new DisTube\n * const distube = new DisTube.default(client, { searchSongs: 10 });\n * // client.DisTube = distube // make it access easily\n * client.login(\"Your Discord Bot Token\")\n */\n constructor(client: Client, otp: DisTubeOptions = {}) {\n super();\n this.setMaxListeners(1);\n if (!isClientInstance(client)) throw new DisTubeError(\"INVALID_TYPE\", \"Discord.Client\", client, \"client\");\n /**\n * Discord.JS client\n * @type {Discord.Client}\n */\n this.client = client;\n checkIntents(client.options);\n /**\n * DisTube options\n * @type {DisTubeOptions}\n */\n this.options = new Options(otp);\n /**\n * Voice connections manager\n * @type {DisTubeVoiceManager}\n */\n this.voices = new DisTubeVoiceManager(this);\n /**\n * DisTube's Handler\n * @type {DisTubeHandler}\n * @private\n */\n this.handler = new DisTubeHandler(this);\n /**\n * Queues manager\n * @type {QueueManager}\n */\n this.queues = new QueueManager(this);\n /**\n * DisTube filters\n * @type {Filters}\n */\n this.filters = defaultFilters;\n Object.assign(this.filters, this.options.customFilters);\n // Default plugin\n this.options.plugins.push(new HTTPPlugin(), new HTTPSPlugin());\n if (this.options.youtubeDL) this.options.plugins.push(new YouTubeDLPlugin(this.options.updateYouTubeDL));\n this.options.plugins.map(p => p.init(this));\n /**\n * Extractor Plugins\n * @type {ExtractorPlugin[]}\n * @private\n */\n this.extractorPlugins = this.options.plugins.filter((p): p is ExtractorPlugin => p.type === \"extractor\");\n /**\n * Custom Plugins\n * @type {CustomPlugin[]}\n * @private\n */\n this.customPlugins = this.options.plugins.filter((p): p is CustomPlugin => p.type === \"custom\");\n }\n\n static get version() {\n return version;\n }\n\n /**\n * DisTube version\n * @type {string}\n */\n get version() {\n return version;\n }\n\n /**\n * Play / add a song or playlist from url. Search and play a song if it is not a valid url.\n *\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string|Song|SearchResult|Playlist} song URL | Search string |\n * {@link Song} | {@link SearchResult} | {@link Playlist}\n * @param {Object} [options] Optional options\n * @param {boolean} [options.skip=false]\n * Skip the playing song (if exists) and play the added song/playlist if `position` is 1.\n * If `position` is defined and not equal to 1, it will skip to the next song instead of the added song\n * @param {number} [options.position=0] Position of the song/playlist to add to the queue,\n * <= 0 to add to the end of the queue.\n * @param {boolean} [options.unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue\n * (after the playing song if exists)\n * @param {Discord.GuildMember} [options.member] Requested user (default is your bot)\n * @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}\n * @param {Discord.Message} [options.message] Called message (For built-in search events. If this is a {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy|falsy value}, it will play the first result instead)\n * @param {*} [options.metadata] Optional metadata that can be attached to the song/playlist will be played,\n * This is useful for identification purposes when the song/playlist is passed around in events.\n * See {@link Song#metadata} or {@link Playlist#metadata}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"play\")\n * distube.play(message.member.voice?.channel, args.join(\" \"), {\n * member: message.member,\n * textChannel: message.channel,\n * message\n * });\n * });\n * @returns {Promise<void>}\n */\n async play(\n voiceChannel: VoiceBasedChannel,\n song: string | Song | SearchResult | Playlist | null,\n options?: {\n skip?: boolean;\n position?: number;\n member?: GuildMember;\n textChannel?: GuildTextBasedChannel;\n message?: Message;\n metadata?: any;\n },\n ): Promise<void>;\n /** @deprecated Message parameter is deprecated, use VoiceChannel instead. */\n async play(\n message: Message<true>,\n song: string | Song | SearchResult | Playlist,\n options?: { skip?: boolean; unshift?: boolean; metadata?: any },\n ): Promise<void>;\n /** @deprecated `options.unshift` is deprecated, use `options.position` instead */\n async play(\n voiceChannel: VoiceBasedChannel,\n song: string | Song | SearchResult | Playlist | null,\n options?: {\n skip?: boolean;\n /** @deprecated Use `options.position` instead */\n unshift?: boolean;\n position?: number;\n member?: GuildMember;\n textChannel?: GuildTextBasedChannel;\n message?: Message;\n metadata?: any;\n },\n ): Promise<void>;\n async play(\n voiceChannel: Message<true> | VoiceBasedChannel,\n song: string | Song | SearchResult | Playlist | null,\n options: {\n skip?: boolean;\n unshift?: boolean;\n position?: number;\n member?: GuildMember;\n textChannel?: GuildTextBasedChannel;\n message?: Message;\n metadata?: any;\n } = {},\n ): Promise<void> {\n if (isMessageInstance(voiceChannel)) {\n process.emitWarning(\n \"Passing Message for DisTube#play is deprecated, use BaseGuildVoiceChannel instead.\",\n \"DeprecationWarning\",\n );\n const message = voiceChannel;\n if (!song) throw new DisTubeError(\"INVALID_TYPE\", [\"string\", \"Song\", \"SearchResult\", \"Playlist\"], song, \"song\");\n if (!isMessageInstance(message)) throw new DisTubeError(\"INVALID_TYPE\", \"Discord.Message\", message, \"message\");\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options, \"options\");\n }\n\n const textChannel = message.channel;\n const { skip, unshift, metadata } = Object.assign({ skip: false, unshift: false }, options);\n const member = message.member as GuildMember;\n const vc = member.voice.channel;\n if (!vc) throw new DisTubeError(\"NOT_IN_VOICE\");\n // eslint-disable-next-line deprecation/deprecation\n return this.play(vc, song, {\n member,\n textChannel,\n skip,\n message,\n unshift,\n metadata,\n });\n }\n\n if (!isSupportedVoiceChannel(voiceChannel)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"BaseGuildVoiceChannel\", voiceChannel, \"voiceChannel\");\n }\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options, \"options\");\n }\n // eslint-disable-next-line deprecation/deprecation\n const { textChannel, member, skip, message, unshift, metadata } = Object.assign(\n {\n member: voiceChannel.guild.me,\n skip: false,\n unshift: false,\n },\n options,\n );\n\n let position = Number(options.position);\n if (!position) {\n if (skip && position !== 0) position = 1;\n else position = 0;\n }\n\n if (unshift) {\n process.emitWarning(\n \"'unshift' option in DisTube#play is deprecated, use 'position' instead.\",\n \"DeprecationWarning\",\n );\n position = 1;\n }\n\n if (message && !isMessageInstance(message)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"Discord.Message\", \"a falsy value\"], message, \"options.message\");\n }\n try {\n if (typeof song === \"string\") {\n for (const plugin of this.customPlugins) {\n if (await plugin.validate(song)) {\n return plugin.play(voiceChannel, song, options);\n }\n }\n }\n let queue = this.getQueue(voiceChannel);\n const queuing = !!queue && !queue.taskQueue.hasResolveTask;\n if (queuing) await queue?.taskQueue.queuing(true);\n try {\n if (song instanceof SearchResult && song.type === \"playlist\") song = song.url;\n if (typeof song === \"string\" && ytpl.validateID(song)) {\n song = await this.handler.resolvePlaylist(song, { member, metadata });\n }\n if (typeof song === \"string\" && !isURL(song)) {\n if (!message) song = (await this.search(song, { limit: 1 }))[0];\n else song = await this.handler.searchSong(message, song);\n }\n song = await this.handler.resolveSong(song, { member, metadata });\n if (!song) return;\n if (song instanceof Playlist) {\n await this.handler.handlePlaylist(voiceChannel, song, { textChannel, skip, position });\n } else if (!this.options.nsfw && song.age_restricted && !(textChannel as TextChannel)?.nsfw) {\n throw new DisTubeError(\"NON_NSFW\");\n } else {\n queue = this.getQueue(voiceChannel);\n if (queue) {\n queue.addToQueue(song, position);\n if (skip) queue.skip();\n else this.emit(\"addSong\", queue, song);\n } else {\n const newQueue = await this.queues.create(voiceChannel, song, textChannel);\n if (newQueue instanceof Queue) {\n if (this.options.emitAddSongWhenCreatingQueue) this.emit(\"addSong\", newQueue, song);\n this.emit(\"playSong\", newQueue, song);\n }\n }\n }\n } finally {\n if (queuing) queue?.taskQueue.resolve();\n }\n } catch (e: any) {\n if (!(e instanceof DisTubeError)) {\n try {\n e.name = \"PlayError\";\n e.message = `${(song as Song)?.url || song}\\n${e.message}`;\n } catch {}\n }\n this.emitError(e, textChannel);\n }\n }\n\n /**\n * Play / add a song or playlist from url. Search and play a song if it is not a valid url.\n *\n * @returns {Promise<void>}\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string|Song|SearchResult|Playlist} song URL | Search string |\n * {@link Song} | {@link SearchResult} | {@link Playlist}\n * @param {Object} [options] Optional options\n * @param {boolean} [options.skip=false]\n * Skip the playing song (if exists) and play the added song/playlist if `position` is 1.\n * If `position` is defined and not equal to 1, it will skip to the next song instead of the added song\n * @param {number} [options.position=0] Position of the song/playlist to add to the queue,\n * <= 0 to add to the end of the queue.\n * @param {boolean} [options.unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue\n * (after the playing song if exists)\n * @param {Discord.GuildMember} [options.member] Requested user (default is your bot)\n * @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}\n * @param {Discord.Message} [options.message] Called message (For built-in search events. If this is a {@link https://developer.mozilla.org/en-US/docs/Glossary/Falsy|falsy value}, it will play the first result instead)\n * @param {*} [options.metadata] Optional metadata that can be attached to the song/playlist will be played,\n * This is useful for identification purposes when the song/playlist is passed around in events.\n * See {@link Song#metadata} or {@link Playlist#metadata}\n * @deprecated Use {@link DisTube#play} instead\n */\n async playVoiceChannel(\n voiceChannel: VoiceBasedChannel,\n song: string | Song | SearchResult | Playlist | null,\n options: {\n skip?: boolean;\n unshift?: boolean;\n position?: number;\n member?: GuildMember;\n textChannel?: GuildTextBasedChannel;\n message?: Message;\n metadata?: any;\n } = {},\n ): Promise<void> {\n process.emitWarning(\"DisTube#playVoiceChannel is deprecated, use DisTube#play instead.\", \"DeprecationWarning\");\n return this.play(voiceChannel, song, options);\n }\n\n /**\n * Create a custom playlist\n * @returns {Promise<Playlist>}\n * @param {Array<string|Song|SearchResult>} songs Array of url, Song or SearchResult\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.message] A message from guild channel | A guild member\n * @param {Object} [options.properties={}] Additional properties such as `name`\n * @param {boolean} [options.parallel=true] Whether or not fetch the songs in parallel\n * @param {*} [options.metadata] Metadata\n * @example\n * const songs = [\"https://www.youtube.com/watch?v=xxx\", \"https://www.youtube.com/watch?v=yyy\"];\n * const playlist = await distube.createCustomPlaylist(songs, {\n * member: message.member,\n * properties: { name: \"My playlist name\" },\n * parallel: true\n * });\n * distube.play(voiceChannel, playlist, { ... });\n */\n async createCustomPlaylist(\n songs: (string | Song | SearchResult)[],\n options: {\n member?: GuildMember;\n properties?: Record<string, any>;\n parallel?: boolean;\n metadata?: any;\n } = {},\n ): Promise<Playlist> {\n const { member, properties, parallel, metadata } = Object.assign({ parallel: true }, options);\n if (!Array.isArray(songs)) throw new DisTubeError(\"INVALID_TYPE\", \"Array\", songs, \"songs\");\n if (!songs.length) throw new DisTubeError(\"EMPTY_ARRAY\", \"songs\");\n const filteredSongs = songs.filter(\n song => song instanceof Song || (song instanceof SearchResult && song.type === \"video\") || isURL(song),\n );\n if (!filteredSongs.length) throw new DisTubeError(\"NO_VALID_SONG\");\n if (member && !isMemberInstance(member)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"Discord.Member\", member, \"options.member\");\n }\n if (!filteredSongs.length) throw new DisTubeError(\"NO_VALID_SONG\");\n let resolvedSongs: Song[];\n if (parallel) {\n const promises = filteredSongs.map((song: string | Song | SearchResult) =>\n this.handler.resolveSong(song, { member, metadata }).catch(() => undefined),\n );\n resolvedSongs = (await Promise.all(promises)).filter((s: any): s is Song => !!s);\n } else {\n const resolved = [];\n for (const song of filteredSongs) {\n resolved.push(await this.handler.resolveSong(song, { member, metadata }).catch(() => undefined));\n }\n resolvedSongs = resolved.filter((s: any): s is Song => !!s);\n }\n return new Playlist(resolvedSongs, { member, properties, metadata });\n }\n\n /**\n * <info>Shorthand method of {@link DisTube#createCustomPlaylist} and {@link DisTube#play}\n *\n * If you doesn't have a user message (interaction,...),\n * see {@link DisTube#createCustomPlaylist} example</info>\n *\n * Play or add array of video urls.\n * {@link DisTube#event:playSong} or {@link DisTube#event:addList} will be emitted\n * with `playlist`'s properties include `properties` parameter's properties such as\n * `user`, `songs`, `duration`, `formattedDuration`, `thumbnail` like {@link Playlist}\n * @returns {Promise<void>}\n * @param {Discord.Message} message A message from guild channel\n * @param {Array<string|Song|SearchResult>} songs Array of url, Song or SearchResult\n * @param {Object} [properties={}] Additional properties for playlist such as `name`\n * @param {Object} [options] Optional options\n * @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added song/playlist instantly\n * @param {boolean} [options.unshift=false] Add the song/playlist to the beginning of the queue\n * (after the playing song if exists)\n * @param {boolean} [options.parallel=true] Whether or not fetch the songs in parallel\n * @deprecated Use {@link DisTube#createCustomPlaylist} and {@link DisTube#play} instead\n */\n async playCustomPlaylist(\n message: Message<true>,\n songs: Array<string | Song | SearchResult>,\n properties: Record<string, any> = {},\n options: {\n skip?: boolean;\n /** @deprecated */\n unshift?: boolean;\n position?: number;\n parallel?: boolean;\n metadata?: any;\n } = {},\n ): Promise<void> {\n process.emitWarning(\n \"DisTube#playCustomPlaylist is deprecated, use DisTube#createCustomPlaylist and DisTube#play instead.\",\n \"DeprecationWarning\",\n );\n try {\n if (typeof options !== \"object\" || Array.isArray(options)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", options, \"options\");\n }\n // eslint-disable-next-line deprecation/deprecation\n const { skip, unshift, parallel, metadata } = Object.assign(\n {\n skip: false,\n unshift: false,\n parallel: true,\n },\n options,\n );\n\n let position = Number(options.position);\n if (!position) {\n if (skip && position !== 0) position = 1;\n else position = 0;\n }\n\n if (unshift) position = 1;\n\n const queue = this.getQueue(message);\n const queuing = queue && !queue.taskQueue.hasResolveTask;\n if (queuing) await queue?.taskQueue.queuing(true);\n try {\n const playlist = await this.createCustomPlaylist(songs, {\n member: message.member ?? undefined,\n properties,\n parallel,\n metadata,\n });\n const voice = message.member?.voice?.channel;\n if (!voice) throw new DisTubeError(\"NOT_IN_VOICE\");\n await this.play(voice, playlist, { textChannel: message.channel, skip, position, metadata });\n } finally {\n if (queuing) queue?.taskQueue.resolve();\n }\n } catch (e: any) {\n this.emitError(e, message.channel);\n }\n }\n\n /**\n * Search for a song. You can customize how user answers instead of send a number.\n * Then use {@link DisTube#play} to play it.\n *\n * @param {string} string The string search for\n * @param {Object} options Search options\n * @param {number} [options.limit=10] Limit the results\n * @param {'video'|'playlist'} [options.type='video'] Type of results (`video` or `playlist`).\n * @param {boolean} [options.safeSearch=false] Whether or not use safe search (YouTube restricted mode)\n * @throws {Error}\n * @returns {Promise<Array<SearchResult>>} Array of results\n */\n async search(\n string: string,\n options: { type?: \"video\" | \"playlist\"; limit?: number; safeSearch?: boolean; retried?: boolean } = {},\n ): Promise<Array<SearchResult>> {\n const opts = Object.assign({ type: \"video\", limit: 10, safeSearch: false }, options);\n if (typeof opts.type !== \"string\" || ![\"video\", \"playlist\"].includes(opts.type)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"video\", \"playlist\"], opts.type, \"options.type\");\n }\n if (typeof opts.limit !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", opts.limit, \"options.limit\");\n if (opts.limit < 1) throw new DisTubeError(\"NUMBER_COMPARE\", \"option.limit\", \"bigger or equal to\", 1);\n if (typeof opts.safeSearch !== \"boolean\") {\n throw new DisTubeError(\"INVALID_TYPE\", \"boolean\", opts.safeSearch, \"options.safeSearch\");\n }\n\n try {\n const search = await ytsr(string, opts);\n const results = search.items.map(i => new SearchResult(i));\n if (results.length === 0) throw new DisTubeError(\"NO_RESULT\");\n return results;\n } catch (e) {\n if (options.retried) throw e;\n options.retried = true;\n return this.search(string, options);\n }\n }\n\n /**\n * Get the guild queue\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Queue?}\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"queue\") {\n * const queue = distube.getQueue(message);\n * message.channel.send('Current queue:\\n' + queue.songs.map((song, id) =>\n * `**${id+1}**. [${song.name}](${song.url}) - \\`${song.formattedDuration}\\``\n * ).join(\"\\n\"));\n * }\n * });\n */\n getQueue(queue: GuildIdResolvable): Queue | undefined {\n return this.queues.get(queue);\n }\n\n /**\n * Pause the guild stream\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Queue} The guild queue\n * @throws {Error}\n */\n pause(queue: GuildIdResolvable): Queue {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.pause();\n }\n\n /**\n * Resume the guild stream\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Queue} The guild queue\n * @throws {Error}\n */\n resume(queue: GuildIdResolvable): Queue {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.resume();\n }\n\n /**\n * Stop the guild stream\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Promise<void>}\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"stop\") {\n * distube.stop(message);\n * message.channel.send(\"Stopped the queue!\");\n * }\n * });\n */\n stop(queue: GuildIdResolvable): Promise<void> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.stop();\n }\n\n /**\n * Set the guild stream's volume\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @param {number} percent The percentage of volume you want to set\n * @returns {Queue} The guild queue\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"volume\")\n * distube.setVolume(message, Number(args[0]));\n * });\n */\n setVolume(queue: GuildIdResolvable, percent: number): Queue {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.setVolume(percent);\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 * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Promise<Song>} The new Song will be played\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"skip\")\n * distube.skip(message);\n * });\n */\n skip(queue: GuildIdResolvable): Promise<Song> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.skip();\n }\n\n /**\n * Play the previous song\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Promise<Song>} The new Song will be played\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"previous\")\n * distube.previous(message);\n * });\n */\n previous(queue: GuildIdResolvable): Promise<Song> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.previous();\n }\n\n /**\n * Shuffle the guild queue songs\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Promise<Queue>} The guild queue\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"shuffle\")\n * distube.shuffle(message);\n * });\n */\n shuffle(queue: GuildIdResolvable): Promise<Queue> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.shuffle();\n }\n\n /**\n * Jump to the song number in the queue.\n * The next one is 1, 2,...\n * The previous one is -1, -2,...\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @param {number} num The song number to play\n * @returns {Promise<Queue>} The guild queue\n * @throws {Error} if `num` is invalid number (0 < num < {@link Queue#songs}.length)\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"jump\")\n * distube.jump(message, parseInt(args[0]))\n * .catch(err => message.channel.send(\"Invalid song number.\"));\n * });\n */\n jump(queue: GuildIdResolvable, num: number): Promise<Queue> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.jump(num);\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 {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)\n * @returns {RepeatMode} The new repeat mode\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"repeat\") {\n * let mode = distube.setRepeatMode(message, parseInt(args[0]));\n * mode = mode ? mode == 2 ? \"Repeat queue\" : \"Repeat song\" : \"Off\";\n * message.channel.send(\"Set repeat mode to `\" + mode + \"`\");\n * }\n * });\n * @example\n * const { RepeatMode } = require(\"distube\");\n * let mode;\n * switch(distube.setRepeatMode(message, parseInt(args[0]))) {\n * case RepeatMode.DISABLED:\n * mode = \"Off\";\n * break;\n * case RepeatMode.SONG:\n * mode = \"Repeat a song\";\n * break;\n * case RepeatMode.QUEUE:\n * mode = \"Repeat all queue\";\n * break;\n * }\n * message.channel.send(\"Set repeat mode to `\" + mode + \"`\");\n */\n setRepeatMode(queue: GuildIdResolvable, mode?: number): number {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.setRepeatMode(mode);\n }\n\n /**\n * Toggle autoplay mode\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {boolean} Autoplay mode state\n * @throws {Error}\n * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command == \"autoplay\") {\n * const mode = distube.toggleAutoplay(message);\n * message.channel.send(\"Set autoplay mode to `\" + (mode ? \"On\" : \"Off\") + \"`\");\n * }\n * });\n */\n toggleAutoplay(queue: GuildIdResolvable): boolean {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n q.autoplay = !q.autoplay;\n return q.autoplay;\n }\n\n /**\n * Add related song to the queue\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @returns {Promise<Song>} The guild queue\n */\n addRelatedSong(queue: GuildIdResolvable): Promise<Song> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.addRelatedSong();\n }\n\n /**\n * Enable or disable filter(s) of the queue.\n * Available filters: {@link Filters}\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @param {string|false} filter A filter name, `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 * @example\n * client.on('message', (message) => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if ([`3d`, `bassboost`, `echo`, `karaoke`, `nightcore`, `vaporwave`].includes(command)) {\n * const filter = distube.setFilter(message, command);\n * message.channel.send(\"Current queue filter: \" + (filter.join(\", \") || \"Off\"));\n * }\n * });\n */\n setFilter(queue: GuildIdResolvable, filter: string | false, force = false): Array<string> {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.setFilter(filter, force);\n }\n\n /**\n * Set the playing time to another position\n * @param {GuildIdResolvable} queue The type can be resolved to give a {@link Queue}\n * @param {number} time Time in seconds\n * @returns {Queue} Seeked queue\n * @example\n * client.on('message', message => {\n * if (!message.content.startsWith(config.prefix)) return;\n * const args = message.content.slice(config.prefix.length).trim().split(/ +/g);\n * const command = args.shift();\n * if (command = 'seek')\n * distube.seek(message, Number(args[0]));\n * });\n */\n seek(queue: GuildIdResolvable, time: number): Queue {\n const q = this.getQueue(queue);\n if (!q) throw new DisTubeError(\"NO_QUEUE\");\n return q.seek(time);\n }\n\n /* eslint-disable no-console */\n /**\n * Emit error event\n * @param {Error} error error\n * @param {Discord.BaseGuildTextChannel} [channel] Text channel where the error is encountered.\n * @private\n */\n emitError(error: Error, channel?: GuildTextBasedChannel): void {\n if (!channel || !isTextChannelInstance(channel)) {\n console.error(error);\n console.warn(\"This is logged because <Queue>.textChannel is undefined\");\n } else if (this.listeners(\"error\").length) {\n this.emit(\"error\", channel, error);\n } else {\n console.error(error);\n console.warn(\"Unhandled 'error' event.\");\n console.warn(\n \"See: https://distube.js.org/#/docs/DisTube/stable/class/DisTube?scrollTo=e-error and https://nodejs.org/api/events.html#events_error_events\",\n );\n }\n }\n /* eslint-enable no-console */\n}\n\nexport default DisTube;\n\n/**\n * Emitted after DisTube add a new playlist to the playing {@link Queue}.\n *\n * @event DisTube#addList\n * @param {Queue} queue The guild queue\n * @param {Playlist} playlist Playlist info\n * @example\n * distube.on(\"addList\", (queue, playlist) => queue.textChannel.send(\n * `Added \\`${playlist.name}\\` playlist (${playlist.songs.length} songs) to the queue!`\n * ));\n */\n\n/**\n * Emitted after DisTube add a new song to the playing {@link Queue}.\n *\n * @event DisTube#addSong\n * @param {Queue} queue The guild queue\n * @param {Song} song Added song\n * @example\n * distube.on(\"addSong\", (queue, song) => queue.textChannel.send(\n * `Added ${song.name} - \\`${song.formattedDuration}\\` to the queue by ${song.user}.`\n * ));\n */\n\n/**\n * Emitted when there is no user in the voice channel,\n * {@link DisTubeOptions}.leaveOnEmpty is `true` and there is a playing queue.\n *\n * If there is no playing queue (stopped and {@link DisTubeOptions}.leaveOnStop is `false`),\n * it will leave the channel without emitting this event.\n * @event DisTube#empty\n * @param {Queue} queue The guild queue\n * @example\n * distube.on(\"empty\", queue => queue.textChannel.send(\"Channel is empty. Leaving the channel\"))\n */\n\n/**\n * Emitted when DisTube encounters an error.\n *\n * @event DisTube#error\n * @param {Discord.BaseGuildTextChannel} channel Text channel where the error is encountered.\n * @param {Error} error The error encountered\n * @example\n * distube.on(\"error\", (channel, error) => channel.send(\n * \"An error encountered: \" + error\n * ));\n */\n\n/**\n * Emitted when there is no more song in the queue and {@link Queue#autoplay} is `false`.\n * DisTube will leave voice channel if {@link DisTubeOptions}.leaveOnFinish is `true`.\n *\n * @event DisTube#finish\n * @param {Queue} queue The guild queue\n * @example\n * distube.on(\"finish\", queue => queue.textChannel.send(\"No more song in queue\"));\n */\n\n/**\n * Emitted when DisTube initialize a queue to change queue default properties.\n *\n * @event DisTube#initQueue\n * @param {Queue} queue The guild queue\n * @example\n * distube.on(\"initQueue\", queue => {\n * queue.autoplay = false;\n * queue.volume = 100;\n * });\n */\n\n/**\n * Emitted when {@link Queue#autoplay} is `true`, {@link Queue#songs} is empty,\n * and DisTube cannot find related songs to play.\n *\n * @event DisTube#noRelated\n * @param {Queue} queue The guild queue\n * @example\n * distube.on(\"noRelated\", queue => queue.textChannel.send(\"Can't find related video to play.\"));\n */\n\n/**\n * Emitted when DisTube play a song.\n *\n * If {@link DisTubeOptions}.emitNewSongOnly is `true`,\n * this event is not emitted when looping a song or next song is the previous one.\n *\n * @event DisTube#playSong\n * @param {Queue} queue The guild queue\n * @param {Song} song Playing song\n * @example\n * distube.on(\"playSong\", (queue, song) => queue.textChannel.send(\n * `Playing \\`${song.name}\\` - \\`${song.formattedDuration}\\`\\nRequested by: ${song.user}`\n * ));\n */\n\n/**\n * Emitted when DisTube cannot find any results for the query.\n *\n * @event DisTube#searchNoResult\n * @param {Discord.Message} message The user message called play method\n * @param {string} query The search query\n * @example\n * distube.on(\"searchNoResult\", (message, query) => message.channel.send(`No result found for ${query}!`));\n */\n\n/**\n * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,\n * and song param of {@link DisTube#play} is invalid url.\n * DisTube will wait for user's next message to choose a song manually.\n * <info>{@link https://support.google.com/youtube/answer/7354993|Safe search} is enabled\n * if {@link DisTubeOptions}.nsfw is disabled and the message's channel is not a nsfw channel.</info>\n *\n * @event DisTube#searchResult\n * @param {Discord.Message} message The user message called play method\n * @param {Array<SearchResult>} results Searched results\n * @param {string} query The search query\n * @example\n * // DisTubeOptions.searchSongs > 0\n * distube.on(\"searchResult\", (message, results) => {\n * message.channel.send(`**Choose an option from below**\\n${\n * results.map((song, i) => `**${i + 1}**. ${song.name} - \\`${song.formattedDuration}\\``).join(\"\\n\")\n * }\\n*Enter anything else or wait 60 seconds to cancel*`);\n * });\n */\n\n/**\n * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,\n * and the search canceled due to {@link DisTubeOptions|DisTubeOptions.searchTimeout}.\n *\n * @event DisTube#searchCancel\n * @param {Discord.Message} message The user message called play method\n * @param {string} query The search query\n * @example\n * // DisTubeOptions.searchSongs > 0\n * distube.on(\"searchCancel\", (message) => message.channel.send(`Searching canceled`));\n */\n\n/**\n * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,\n * and the search canceled due to user's next message is not a number or out of results range.\n *\n * @event DisTube#searchInvalidAnswer\n * @param {Discord.Message} message The user message called play method\n * @param {Discord.Message} answer The answered message of user\n * @param {string} query The search query\n * @example\n * // DisTubeOptions.searchSongs > 0\n * distube.on(\"searchInvalidAnswer\", (message) => message.channel.send(`You answered an invalid number!`));\n */\n\n/**\n * Emitted when {@link DisTubeOptions|DisTubeOptions.searchSongs} bigger than 0,\n * and after the user chose a search result to play.\n *\n * @event DisTube#searchDone\n * @param {Discord.Message} message The user message called play method\n * @param {Discord.Message} answer The answered message of user\n * @param {string} query The search query\n */\n\n/**\n * Emitted when the bot is disconnected to a voice channel.\n *\n * @event DisTube#disconnect\n * @param {Queue} queue The guild queue\n */\n\n/**\n * Emitted when a {@link Queue} is deleted with any reasons.\n *\n * @event DisTube#deleteQueue\n * @param {Queue} queue The guild queue\n */\n\n/**\n * Emitted when DisTube finished a song.\n *\n * @event DisTube#finishSong\n * @param {Queue} queue The guild queue\n * @param {Song} song Finished song\n */\n"]}
|
|
@@ -77,6 +77,13 @@ export declare class DisTubeHandler extends DisTubeBase {
|
|
|
77
77
|
handlePlaylist(voice: VoiceBasedChannel, playlist: Playlist, options?: {
|
|
78
78
|
textChannel?: GuildTextBasedChannel;
|
|
79
79
|
skip?: boolean;
|
|
80
|
+
position?: number;
|
|
81
|
+
}): Promise<void>;
|
|
82
|
+
/** @deprecated `options.unshift` is deprecated, use `options.position` instead */
|
|
83
|
+
handlePlaylist(voice: VoiceBasedChannel, playlist: Playlist, options?: {
|
|
84
|
+
textChannel?: GuildTextBasedChannel;
|
|
85
|
+
skip?: boolean;
|
|
86
|
+
position?: number;
|
|
80
87
|
unshift?: boolean;
|
|
81
88
|
}): Promise<void>;
|
|
82
89
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeHandler.d.ts","sourceRoot":"","sources":["../../src/core/DisTubeHandler.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,M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ACxB,QAAQ,EAAE,QAAQ,EAClB,OAAO,CAAC,EAAE;QACR,WAAW,CAAC,EAAE,qBAAqB,CAAC;QACpC,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,GACA,OAAO,CAAC,IAAI,CAAC;IA2ChB;;;;;OAKG;IACG,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC;IAqBrF;;;;;;;;;OASG;IACG,4BAA4B,CAAC,CAAC,SAAS,YAAY,GAAG,IAAI,GAAG,QAAQ,EACzE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,EACtB,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EACjB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IA6DpB;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa;CAW1C"}
|
|
@@ -181,18 +181,17 @@ class DisTubeHandler extends _1.DisTubeBase {
|
|
|
181
181
|
metadata,
|
|
182
182
|
});
|
|
183
183
|
}
|
|
184
|
-
/**
|
|
185
|
-
* Play / add a playlist
|
|
186
|
-
* @returns {Promise<void>}
|
|
187
|
-
* @param {Discord.BaseGuildVoiceChannel} voice A voice channel
|
|
188
|
-
* @param {Playlist|string} playlist A YouTube playlist url | a Playlist
|
|
189
|
-
* @param {Object} [options] Optional options
|
|
190
|
-
* @param {Discord.BaseGuildTextChannel} [options.textChannel] The default text channel of the queue
|
|
191
|
-
* @param {boolean} [options.skip=false] Skip the playing song (if exists) and play the added playlist instantly
|
|
192
|
-
* @param {boolean} [options.unshift=false] Add the playlist after the playing song if exists
|
|
193
|
-
*/
|
|
194
184
|
async handlePlaylist(voice, playlist, options = {}) {
|
|
195
185
|
const { textChannel, skip, unshift } = Object.assign({ skip: false, unshift: false }, options);
|
|
186
|
+
let position = Number(options.position);
|
|
187
|
+
if (!position) {
|
|
188
|
+
if (skip && position !== 0)
|
|
189
|
+
position = 1;
|
|
190
|
+
else
|
|
191
|
+
position = 0;
|
|
192
|
+
}
|
|
193
|
+
if (unshift)
|
|
194
|
+
position = 1;
|
|
196
195
|
if (!(playlist instanceof __1.Playlist))
|
|
197
196
|
throw new __1.DisTubeError("INVALID_TYPE", "Playlist", playlist, "playlist");
|
|
198
197
|
if (!this.options.nsfw && !textChannel?.nsfw) {
|
|
@@ -206,7 +205,7 @@ class DisTubeHandler extends _1.DisTubeBase {
|
|
|
206
205
|
const songs = playlist.songs;
|
|
207
206
|
const queue = this.queues.get(voice);
|
|
208
207
|
if (queue) {
|
|
209
|
-
queue.addToQueue(songs,
|
|
208
|
+
queue.addToQueue(songs, position);
|
|
210
209
|
if (skip)
|
|
211
210
|
queue.skip();
|
|
212
211
|
else
|