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
|
@@ -5,29 +5,7 @@ const _1 = require(".");
|
|
|
5
5
|
const __1 = require("../..");
|
|
6
6
|
const manager_1 = require("../manager");
|
|
7
7
|
const voice_1 = require("@discordjs/voice");
|
|
8
|
-
|
|
9
|
-
* Manages voice connections for {@link DisTube}
|
|
10
|
-
* @extends BaseManager
|
|
11
|
-
*/
|
|
12
|
-
class DisTubeVoiceManager extends manager_1.BaseManager {
|
|
13
|
-
/**
|
|
14
|
-
* Get a {@link DisTubeVoice}.
|
|
15
|
-
* @method get
|
|
16
|
-
* @memberof DisTubeVoiceManager#
|
|
17
|
-
* @param {GuildIdResolvable} queue The queue resolvable to resolve
|
|
18
|
-
* @returns {DisTubeVoice?}
|
|
19
|
-
*/
|
|
20
|
-
/**
|
|
21
|
-
* Collection of {@link DisTubeVoice}.
|
|
22
|
-
* @name DisTubeVoiceManager#collection
|
|
23
|
-
* @type {Discord.Collection<string, DisTubeVoice>}
|
|
24
|
-
*/
|
|
25
|
-
/**
|
|
26
|
-
* Create a {@link DisTubeVoice}
|
|
27
|
-
* @param {Discord.BaseGuildVoiceChannel} channel A voice channel to join
|
|
28
|
-
* @returns {DisTubeVoice}
|
|
29
|
-
* @private
|
|
30
|
-
*/
|
|
8
|
+
class DisTubeVoiceManager extends manager_1.GuildIdManager {
|
|
31
9
|
create(channel) {
|
|
32
10
|
const existing = this.get(channel.guild.id);
|
|
33
11
|
if (existing) {
|
|
@@ -35,21 +13,12 @@ class DisTubeVoiceManager extends manager_1.BaseManager {
|
|
|
35
13
|
}
|
|
36
14
|
return new _1.DisTubeVoice(this, channel);
|
|
37
15
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Join a voice channel
|
|
40
|
-
* @param {Discord.BaseGuildVoiceChannel} channel A voice channel to join
|
|
41
|
-
* @returns {Promise<DisTubeVoice>}
|
|
42
|
-
*/
|
|
43
16
|
join(channel) {
|
|
44
17
|
const existing = this.get(channel.guild.id);
|
|
45
18
|
if (existing)
|
|
46
19
|
return existing.join(channel);
|
|
47
20
|
return this.create(channel).join();
|
|
48
21
|
}
|
|
49
|
-
/**
|
|
50
|
-
* Leave the connected voice channel in a guild
|
|
51
|
-
* @param {GuildIdResolvable} guild Queue Resolvable
|
|
52
|
-
*/
|
|
53
22
|
leave(guild) {
|
|
54
23
|
const voice = this.get(guild);
|
|
55
24
|
if (voice) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeVoiceManager.js","sourceRoot":"","sources":["../../../src/core/voice/DisTubeVoiceManager.ts"],"names":[],"mappings":";;;AAAA,wBAAiC;AACjC,6BAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"DisTubeVoiceManager.js","sourceRoot":"","sources":["../../../src/core/voice/DisTubeVoiceManager.ts"],"names":[],"mappings":";;;AAAA,wBAAiC;AACjC,6BAAuC;AACvC,wCAA4C;AAC5C,4CAA6E;AAQ7E,MAAa,mBAAoB,SAAQ,wBAA4B;IAmBnE,MAAM,CAAC,OAA0B;QAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5C,IAAI,QAAQ,EAAE;YACZ,OAAO,QAAQ,CAAC;SACjB;QACD,OAAO,IAAI,eAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IAMD,IAAI,CAAC,OAA0B;QAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5C,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IACrC,CAAC;IAKD,KAAK,CAAC,KAAwB;QAC5B,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC9B,IAAI,KAAK,EAAE;YACT,KAAK,CAAC,KAAK,EAAE,CAAC;SACf;aAAM;YACL,MAAM,UAAU,GAAG,IAAA,0BAAkB,EAAC,IAAA,kBAAc,EAAC,KAAK,CAAC,CAAC,CAAC;YAC7D,IAAI,UAAU,IAAI,UAAU,CAAC,KAAK,CAAC,MAAM,KAAK,6BAAqB,CAAC,SAAS,EAAE;gBAC7E,UAAU,CAAC,OAAO,EAAE,CAAC;aACtB;SACF;IACH,CAAC;CACF;AAnDD,kDAmDC","sourcesContent":["import { DisTubeVoice } from \".\";\nimport { resolveGuildId } from \"../..\";\nimport { GuildIdManager } from \"../manager\";\nimport { VoiceConnectionStatus, getVoiceConnection } from \"@discordjs/voice\";\nimport type { GuildIdResolvable } from \"../..\";\nimport type { VoiceBasedChannel } from \"discord.js\";\n\n/**\n * Manages voice connections for {@link DisTube}\n * @extends BaseManager\n */\nexport class DisTubeVoiceManager extends GuildIdManager<DisTubeVoice> {\n /**\n * Get a {@link DisTubeVoice}.\n * @method get\n * @memberof DisTubeVoiceManager#\n * @param {GuildIdResolvable} guild The queue resolvable to resolve\n * @returns {DisTubeVoice?}\n */\n /**\n * Collection of {@link DisTubeVoice}.\n * @name DisTubeVoiceManager#collection\n * @type {Discord.Collection<string, DisTubeVoice>}\n */\n /**\n * Create a {@link DisTubeVoice}\n * @param {Discord.BaseGuildVoiceChannel} channel A voice channel to join\n * @returns {DisTubeVoice}\n * @private\n */\n create(channel: VoiceBasedChannel): DisTubeVoice {\n const existing = this.get(channel.guild.id);\n if (existing) {\n return existing;\n }\n return new DisTubeVoice(this, channel);\n }\n /**\n * Join a voice channel\n * @param {Discord.BaseGuildVoiceChannel} channel A voice channel to join\n * @returns {Promise<DisTubeVoice>}\n */\n join(channel: VoiceBasedChannel): Promise<DisTubeVoice> {\n const existing = this.get(channel.guild.id);\n if (existing) return existing.join(channel);\n return this.create(channel).join();\n }\n /**\n * Leave the connected voice channel in a guild\n * @param {GuildIdResolvable} guild Queue Resolvable\n */\n leave(guild: GuildIdResolvable) {\n const voice = this.get(guild);\n if (voice) {\n voice.leave();\n } else {\n const connection = getVoiceConnection(resolveGuildId(guild));\n if (connection && connection.state.status !== VoiceConnectionStatus.Destroyed) {\n connection.destroy();\n }\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/voice/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/voice/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
package/dist/core/voice/index.js
CHANGED
|
@@ -10,7 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
__exportStar(require("./DJSAdapter"), exports);
|
|
14
13
|
__exportStar(require("./DisTubeVoice"), exports);
|
|
15
14
|
__exportStar(require("./DisTubeVoiceManager"), exports);
|
|
16
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/voice/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/voice/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAA+B;AAC/B,wDAAsC","sourcesContent":["export * from \"./DisTubeVoice\";\nexport * from \"./DisTubeVoiceManager\";\n"]}
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
package/dist/plugin/index.js
CHANGED
|
@@ -12,5 +12,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./http"), exports);
|
|
14
14
|
__exportStar(require("./https"), exports);
|
|
15
|
-
__exportStar(require("./youtube-dl"), exports);
|
|
16
15
|
//# sourceMappingURL=index.js.map
|
package/dist/plugin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,0CAAwB
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/plugin/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuB;AACvB,0CAAwB","sourcesContent":["export * from \"./http\";\nexport * from \"./https\";\n"]}
|
|
@@ -2,50 +2,9 @@ import { Plugin } from ".";
|
|
|
2
2
|
import { PluginType } from "..";
|
|
3
3
|
import type { VoiceBasedChannel } from "discord.js";
|
|
4
4
|
import type { Awaitable, CustomPluginPlayOptions } from "..";
|
|
5
|
-
/**
|
|
6
|
-
* Custom Plugin
|
|
7
|
-
* @extends Plugin
|
|
8
|
-
* @abstract
|
|
9
|
-
*/
|
|
10
5
|
export declare abstract class CustomPlugin extends Plugin {
|
|
11
6
|
type: PluginType;
|
|
12
|
-
/**
|
|
13
|
-
* This method will be executed if the `song` string is validated.
|
|
14
|
-
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
|
|
15
|
-
* @param {string} song Validated `song`
|
|
16
|
-
* @param {CustomPluginPlayOptions} [options] Optional options
|
|
17
|
-
* @returns {Promise<void>}
|
|
18
|
-
* @abstract
|
|
19
|
-
*/
|
|
20
7
|
abstract play(voiceChannel: VoiceBasedChannel, song: string, options: CustomPluginPlayOptions): Awaitable<void>;
|
|
21
|
-
/**
|
|
22
|
-
* Check if the {@link DisTube#play} `song` parameter is working with this plugin
|
|
23
|
-
* @param {string} song String need to validate
|
|
24
|
-
* @returns {boolean|Promise<boolean>}
|
|
25
|
-
*/
|
|
26
8
|
validate(song: string): Awaitable<boolean>;
|
|
27
9
|
}
|
|
28
|
-
/**
|
|
29
|
-
* @typedef {Object} CustomPluginPlayOptions
|
|
30
|
-
* @param {Discord.GuildMember} [member] Requested user
|
|
31
|
-
* @param {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}
|
|
32
|
-
* @param {boolean} [skip=false]
|
|
33
|
-
* Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
|
|
34
|
-
* If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
|
|
35
|
-
* @param {number} [position=0] Position of the song/playlist to add to the queue,
|
|
36
|
-
* <= 0 to add to the end of the queue.
|
|
37
|
-
* @param {boolean} [unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
|
|
38
|
-
* (after the playing song if exists)
|
|
39
|
-
* @param {*} [metadata] Optional metadata that can be attached to the song/playlist will be played.
|
|
40
|
-
*/
|
|
41
|
-
/**
|
|
42
|
-
* This method will be executed if the url is validated.
|
|
43
|
-
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
|
|
44
|
-
* @param {string} song Validated `song`
|
|
45
|
-
* @param {CustomPluginPlayOptions} [options] Optional options
|
|
46
|
-
* @returns {Promise<void>}
|
|
47
|
-
* @abstract
|
|
48
|
-
* @method play
|
|
49
|
-
* @memberof CustomPlugin#
|
|
50
|
-
*/
|
|
51
10
|
//# sourceMappingURL=CustomPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,uBAAuB,EAAgC,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"CustomPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACpD,OAAO,KAAK,EAAE,SAAS,EAAE,uBAAuB,EAAgC,MAAM,IAAI,CAAC;AAO3F,8BAAsB,YAAa,SAAQ,MAAM;IAC/C,IAAI,aAAqB;IASzB,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB,GAAG,SAAS,CAAC,IAAI,CAAC;IAM/G,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;CAG3C"}
|
|
@@ -1,50 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CustomPlugin = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
4
|
const _1 = require(".");
|
|
6
5
|
const __1 = require("..");
|
|
7
|
-
/**
|
|
8
|
-
* Custom Plugin
|
|
9
|
-
* @extends Plugin
|
|
10
|
-
* @abstract
|
|
11
|
-
*/
|
|
12
6
|
class CustomPlugin extends _1.Plugin {
|
|
13
7
|
constructor() {
|
|
14
8
|
super(...arguments);
|
|
15
9
|
this.type = __1.PluginType.CUSTOM;
|
|
16
10
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Check if the {@link DisTube#play} `song` parameter is working with this plugin
|
|
19
|
-
* @param {string} song String need to validate
|
|
20
|
-
* @returns {boolean|Promise<boolean>}
|
|
21
|
-
*/
|
|
22
11
|
validate(song) {
|
|
23
12
|
return false;
|
|
24
13
|
}
|
|
25
14
|
}
|
|
26
15
|
exports.CustomPlugin = CustomPlugin;
|
|
27
|
-
/**
|
|
28
|
-
* @typedef {Object} CustomPluginPlayOptions
|
|
29
|
-
* @param {Discord.GuildMember} [member] Requested user
|
|
30
|
-
* @param {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}
|
|
31
|
-
* @param {boolean} [skip=false]
|
|
32
|
-
* Skip the playing song (if exists) and play the added song/playlist if `position` is 1.
|
|
33
|
-
* If `position` is defined and not equal to 1, it will skip to the next song instead of the added song
|
|
34
|
-
* @param {number} [position=0] Position of the song/playlist to add to the queue,
|
|
35
|
-
* <= 0 to add to the end of the queue.
|
|
36
|
-
* @param {boolean} [unshift=false] (DEPRECATED) Add the song/playlist to the beginning of the queue
|
|
37
|
-
* (after the playing song if exists)
|
|
38
|
-
* @param {*} [metadata] Optional metadata that can be attached to the song/playlist will be played.
|
|
39
|
-
*/
|
|
40
|
-
/**
|
|
41
|
-
* This method will be executed if the url is validated.
|
|
42
|
-
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
|
|
43
|
-
* @param {string} song Validated `song`
|
|
44
|
-
* @param {CustomPluginPlayOptions} [options] Optional options
|
|
45
|
-
* @returns {Promise<void>}
|
|
46
|
-
* @abstract
|
|
47
|
-
* @method play
|
|
48
|
-
* @memberof CustomPlugin#
|
|
49
|
-
*/
|
|
50
16
|
//# sourceMappingURL=CustomPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomPlugin.js","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"CustomPlugin.js","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":";;;AACA,wBAA2B;AAC3B,0BAAgC;AAShC,MAAsB,YAAa,SAAQ,SAAM;IAAjD;;QACE,SAAI,GAAG,cAAU,CAAC,MAAM,CAAC;IAkB3B,CAAC;IAHC,QAAQ,CAAC,IAAY;QACnB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAnBD,oCAmBC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { Plugin } from \".\";\nimport { PluginType } from \"..\";\nimport type { VoiceBasedChannel } from \"discord.js\";\nimport type { Awaitable, CustomPluginPlayOptions, Playlist, SearchResult, Song } from \"..\";\n\n/**\n * Custom Plugin\n * @extends Plugin\n * @abstract\n */\nexport abstract class CustomPlugin extends Plugin {\n type = PluginType.CUSTOM;\n /**\n * This method will be executed if the `song` string is validated.\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string} song Validated `song`\n * @param {CustomPluginPlayOptions} [options] Optional options\n * @returns {Promise<void>}\n * @abstract\n */\n abstract play(voiceChannel: VoiceBasedChannel, song: string, options: CustomPluginPlayOptions): Awaitable<void>;\n /**\n * Check if the {@link DisTube#play} `song` parameter is working with this plugin\n * @param {string} song String need to validate\n * @returns {boolean|Promise<boolean>}\n */\n validate(song: string): Awaitable<boolean> {\n return false;\n }\n}\n\n/**\n * @typedef {Object} CustomPluginPlayOptions\n * @param {Discord.GuildMember} [member] Requested user\n * @param {Discord.BaseGuildTextChannel} [textChannel] Default {@link Queue#textChannel}\n * @param {boolean} [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} [position=0] Position of the song/playlist to add to the queue,\n * <= 0 to add to the end of the queue.\n * @param {*} [metadata] Optional metadata that can be attached to the song/playlist will be played.\n */\n\n/**\n * This method will be executed if the url is validated.\n * @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined\n * @param {string} song Validated `song`\n * @param {CustomPluginPlayOptions} [options] Optional options\n * @returns {Promise<void>}\n * @abstract\n * @method play\n * @memberof CustomPlugin#\n */\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeError.d.ts","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,cAAc;6BACO,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,GAAG;2BAI5D,MAAM,YAAY,MAAM,SAAS,MAAM;wBAC1C,MAAM;iCACG,MAAM,QAAQ,MAAM;yBAC5B,MAAM;uBACR,MAAM,OAAO,MAAM;uBACnB,MAAM,OAAO,MAAM;wBAClB,MAAM,OAAO,MAAM,EAAE,OAAO,OAAO;yBAGlC,MAAM;yBACN,MAAM;wBACP,MAAM;;;8BAIA,MAAM
|
|
1
|
+
{"version":3,"file":"DisTubeError.d.ts","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,cAAc;6BACO,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,OAAO,GAAG;2BAI5D,MAAM,YAAY,MAAM,SAAS,MAAM;wBAC1C,MAAM;iCACG,MAAM,QAAQ,MAAM;yBAC5B,MAAM;uBACR,MAAM,OAAO,MAAM;uBACnB,MAAM,OAAO,MAAM;wBAClB,MAAM,OAAO,MAAM,EAAE,OAAO,OAAO;yBAGlC,MAAM;yBACN,MAAM;wBACP,MAAM;;;8BAIA,MAAM;;;;;;;;;;;;;;;;;;;6BAqBP,GAAG;;;;CAM7B,CAAC;AAEF,aAAK,aAAa,GAAG,OAAO,cAAc,CAAC;AAC3C,aAAK,UAAU,GAAG,MAAM,aAAa,CAAC;AACtC,aAAK,SAAS,GAAG;KAAG,CAAC,IAAI,UAAU,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,CAAC,GAAG,KAAK;CAAE,CAAC,UAAU,CAAC,CAAC;AAClG,aAAK,iBAAiB,GAAG,OAAO,CAAC,MAAM,OAAO,cAAc,EAAE,SAAS,CAAC,CAAC;AAMzE,qBAAa,YAAY,CAAC,CAAC,SAAS,MAAM,CAAE,SAAQ,KAAK;IACvD,SAAS,EAAE,MAAM,CAAC;gBACN,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,CAAC,SAAS,iBAAiB,GAAG,CAAC,GAAG,KAAK,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,aAAa,CAAC,OAAO,IAAI,CAAC,CAAC;gBAC9F,IAAI,EAAE,iBAAiB,EAAE,CAAC,EAAE,KAAK;gBACjC,IAAI,EAAE,CAAC,SAAS,UAAU,GAAG,6BAA6B,GAAG,CAAC,EAAE,OAAO,EAAE,MAAM;IAS3F,IAAI,IAAI,WAEP;IAED,IAAI,IAAI,WAEP;CACF"}
|
|
@@ -20,8 +20,6 @@ const ERROR_MESSAGES = {
|
|
|
20
20
|
VOICE_MISSING_PERMS: "You do not have permission to join this voice channel",
|
|
21
21
|
VOICE_RECONNECT_FAILED: "Cannot reconnect to the voice channel",
|
|
22
22
|
VOICE_CHANGE_GUILD: "Cannot join a channel in a different guild",
|
|
23
|
-
VOICE_DEPRECATED_CONNECTION: "Cannot connect to the voice channel due to a deprecated connection is created.\n" +
|
|
24
|
-
"Read more: https://distube.js.org/guide/additional-info/update.html#voice",
|
|
25
23
|
NO_QUEUE: "There is no playing queue in this guild",
|
|
26
24
|
QUEUE_EXIST: "This guild has a Queue already",
|
|
27
25
|
PAUSED: "The queue has been paused already",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeError.js","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AAEpC,MAAM,cAAc,GAAG;IACrB,YAAY,EAAE,CAAC,QAA0D,EAAE,GAAQ,EAAE,IAAa,EAAE,EAAE,CACpG,YACE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,QAAQ,C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2B;IAC9C,mBAAmB,EAAE,CAAC,CAAM,EAAE,EAAE,CAAC,kBAAkB,IAAA,mBAAO,EAAC,CAAC,CAAC,YAAY;IACzE,aAAa,EAAE,iEAAiE;IAChF,uBAAuB,EACrB,2CAA2C;QAC3C,+EAA+E;IACjF,cAAc,EAAE,yCAAyC;CAC1D,CAAC;AAOF,MAAM,MAAM,GAAG,CAAC,GAAqC,EAAE,GAAG,IAAS,EAAE,EAAE,CAAC,CAAC,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAEvH,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAsB,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAElG,MAAa,YAA+B,SAAQ,KAAK;IAMvD,YAAY,IAAY,EAAE,GAAG,IAAS;QACpC,IAAI,QAAQ,CAAC,IAAI,CAAC;YAAE,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;;YAC5D,KAAK,CAAC,GAAG,IAAI,CAAC,CAAC;QAEpB,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,KAAK,CAAC,iBAAiB;YAAE,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC3E,CAAC;IAED,IAAI,IAAI;QACN,OAAO,iBAAiB,IAAI,CAAC,SAAS,GAAG,CAAC;IAC5C,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;CACF;AArBD,oCAqBC","sourcesContent":["import { inspect } from \"node:util\";\n\nconst ERROR_MESSAGES = {\n INVALID_TYPE: (expected: (number | string) | readonly (number | string)[], got: any, name?: string) =>\n `Expected ${\n Array.isArray(expected) ? expected.map(e => (typeof e === \"number\" ? e : `'${e}'`)).join(\" or \") : `'${expected}'`\n }${name ? ` for '${name}'` : \"\"}, but got ${inspect(got)}`,\n NUMBER_COMPARE: (name: string, expected: string, value: number) => `'${name}' must be ${expected} ${value}`,\n EMPTY_ARRAY: (name: string) => `'${name}' is an empty array`,\n EMPTY_FILTERED_ARRAY: (name: string, type: string) => `There is no valid '${type}' in the '${name}' array`,\n EMPTY_STRING: (name: string) => `'${name}' string must not be empty`,\n INVALID_KEY: (obj: string, key: string) => `'${key}' does not need to be provided in ${obj}`,\n MISSING_KEY: (obj: string, key: string) => `'${key}' needs to be provided in ${obj}`,\n MISSING_KEYS: (obj: string, key: string[], all: boolean) =>\n `${key.map(k => `'${k}'`).join(all ? \" and \" : \" or \")} need to be provided in ${obj}`,\n\n MISSING_INTENTS: (i: string) => `${i} intent must be provided for the Client`,\n DISABLED_OPTION: (o: string) => `DisTubeOptions.${o} is disabled`,\n ENABLED_OPTION: (o: string) => `DisTubeOptions.${o} is enabled`,\n\n NOT_IN_VOICE: \"User is not in any voice channel\",\n VOICE_FULL: \"The voice channel is full\",\n VOICE_CONNECT_FAILED: (s: number) => `Cannot connect to the voice channel after ${s} seconds`,\n VOICE_MISSING_PERMS: \"You do not have permission to join this voice channel\",\n VOICE_RECONNECT_FAILED: \"Cannot reconnect to the voice channel\",\n VOICE_CHANGE_GUILD: \"Cannot join a channel in a different guild\",\n\n NO_QUEUE: \"There is no playing queue in this guild\",\n QUEUE_EXIST: \"This guild has a Queue already\",\n PAUSED: \"The queue has been paused already\",\n RESUMED: \"The queue has been playing already\",\n NO_PREVIOUS: \"There is no previous song in this queue\",\n NO_UP_NEXT: \"There is no up next song\",\n NO_SONG_POSITION: \"Does not have any song at this position\",\n NO_PLAYING: \"There is no playing song in the queue\",\n\n NO_RESULT: \"No result found\",\n NO_RELATED: \"Cannot find any related songs\",\n CANNOT_PLAY_RELATED: \"Cannot play the related song\",\n UNAVAILABLE_VIDEO: \"This video is unavailable\",\n UNPLAYABLE_FORMATS: \"No playable format found\",\n NON_NSFW: \"Cannot play age-restricted content in non-NSFW channel\",\n NOT_SUPPORTED_URL: \"This url is not supported\",\n CANNOT_RESOLVE_SONG: (t: any) => `Cannot resolve ${inspect(t)} to a Song`,\n NO_VALID_SONG: \"'songs' array does not have any valid Song, SearchResult or url\",\n EMPTY_FILTERED_PLAYLIST:\n \"There is no valid video in the playlist\\n\" +\n \"Maybe age-restricted contents is filtered because you are in non-NSFW channel\",\n EMPTY_PLAYLIST: \"There is no valid video in the playlist\",\n};\n\ntype ErrorMessages = typeof ERROR_MESSAGES;\ntype ErrorCodes = keyof ErrorMessages;\ntype ErrorCode = { [K in ErrorCodes]-?: ErrorMessages[K] extends string ? K : never }[ErrorCodes];\ntype ErrorCodeTemplate = Exclude<keyof typeof ERROR_MESSAGES, ErrorCode>;\n\nconst errMsg = (msg: string | ((...x: any) => string), ...args: any) => (typeof msg === \"string\" ? msg : msg(...args));\n\nconst haveCode = (code: string): code is ErrorCodes => Object.keys(ERROR_MESSAGES).includes(code);\n\nexport class DisTubeError<T extends string> extends Error {\n errorCode: string;\n constructor(code: ErrorCode);\n constructor(code: T extends ErrorCodeTemplate ? T : never, ...args: Parameters<ErrorMessages[typeof code]>);\n constructor(code: ErrorCodeTemplate, _: never);\n constructor(code: T extends ErrorCodes ? \"This is built-in error code\" : T, message: string);\n constructor(code: string, ...args: any) {\n if (haveCode(code)) super(errMsg(ERROR_MESSAGES[code], ...args));\n else super(...args);\n\n this.errorCode = code;\n if (Error.captureStackTrace) Error.captureStackTrace(this, DisTubeError);\n }\n\n get name() {\n return `DisTubeError [${this.errorCode}]`;\n }\n\n get code() {\n return this.errorCode;\n }\n}\n"]}
|
|
@@ -2,44 +2,12 @@ import { Plugin } from ".";
|
|
|
2
2
|
import { PluginType } from "..";
|
|
3
3
|
import type { GuildMember } from "discord.js";
|
|
4
4
|
import type { Awaitable, Playlist, Song } from "..";
|
|
5
|
-
/**
|
|
6
|
-
* Extractor Plugin
|
|
7
|
-
* @extends Plugin
|
|
8
|
-
* @abstract
|
|
9
|
-
*/
|
|
10
5
|
export declare abstract class ExtractorPlugin extends Plugin {
|
|
11
6
|
type: PluginType;
|
|
12
|
-
/**
|
|
13
|
-
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
14
|
-
*
|
|
15
|
-
* @param {string} url URL
|
|
16
|
-
* @param {Object} [options] Optional options
|
|
17
|
-
* @param {Discord.GuildMember} [options.member] Requested user
|
|
18
|
-
* @param {*} [options.metadata] Metadata
|
|
19
|
-
* @returns {Song|Playlist|Promise<Song|Playlist>}
|
|
20
|
-
* @abstract
|
|
21
|
-
*/
|
|
22
7
|
abstract resolve<T = unknown>(url: string, options: {
|
|
23
8
|
member?: GuildMember;
|
|
24
9
|
metadata?: T;
|
|
25
10
|
}): Awaitable<Song<T> | Playlist<T>>;
|
|
26
|
-
/**
|
|
27
|
-
* Check if the url is working with this plugin
|
|
28
|
-
* @param {string} url Input url
|
|
29
|
-
* @returns {boolean|Promise<boolean>}
|
|
30
|
-
*/
|
|
31
11
|
validate(url: string): Awaitable<boolean>;
|
|
32
12
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
35
|
-
*
|
|
36
|
-
* @param {string} url URL
|
|
37
|
-
* @param {Object} [options] Optional options
|
|
38
|
-
* @param {Discord.GuildMember} [options.member] Requested user
|
|
39
|
-
* @param {*} [options.metadata] Metadata
|
|
40
|
-
* @returns {Song|Playlist|Promise<Song|Playlist>}
|
|
41
|
-
* @method resolve
|
|
42
|
-
* @memberof ExtractorPlugin#
|
|
43
|
-
* @abstract
|
|
44
|
-
*/
|
|
45
13
|
//# sourceMappingURL=ExtractorPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtractorPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"ExtractorPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAOpD,8BAAsB,eAAgB,SAAQ,MAAM;IAClD,IAAI,aAAwB;IAW5B,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,OAAO,EAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;KAAE,GAC9C,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;IAMnC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,OAAO,CAAC;CAG1C"}
|
|
@@ -1,39 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ExtractorPlugin = void 0;
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
5
4
|
const _1 = require(".");
|
|
6
5
|
const __1 = require("..");
|
|
7
|
-
/**
|
|
8
|
-
* Extractor Plugin
|
|
9
|
-
* @extends Plugin
|
|
10
|
-
* @abstract
|
|
11
|
-
*/
|
|
12
6
|
class ExtractorPlugin extends _1.Plugin {
|
|
13
7
|
constructor() {
|
|
14
8
|
super(...arguments);
|
|
15
9
|
this.type = __1.PluginType.EXTRACTOR;
|
|
16
10
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Check if the url is working with this plugin
|
|
19
|
-
* @param {string} url Input url
|
|
20
|
-
* @returns {boolean|Promise<boolean>}
|
|
21
|
-
*/
|
|
22
11
|
validate(url) {
|
|
23
12
|
return false;
|
|
24
13
|
}
|
|
25
14
|
}
|
|
26
15
|
exports.ExtractorPlugin = ExtractorPlugin;
|
|
27
|
-
/**
|
|
28
|
-
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
29
|
-
*
|
|
30
|
-
* @param {string} url URL
|
|
31
|
-
* @param {Object} [options] Optional options
|
|
32
|
-
* @param {Discord.GuildMember} [options.member] Requested user
|
|
33
|
-
* @param {*} [options.metadata] Metadata
|
|
34
|
-
* @returns {Song|Playlist|Promise<Song|Playlist>}
|
|
35
|
-
* @method resolve
|
|
36
|
-
* @memberof ExtractorPlugin#
|
|
37
|
-
* @abstract
|
|
38
|
-
*/
|
|
39
16
|
//# sourceMappingURL=ExtractorPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtractorPlugin.js","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ExtractorPlugin.js","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":";;;AACA,wBAA2B;AAC3B,0BAAgC;AAShC,MAAsB,eAAgB,SAAQ,SAAM;IAApD;;QACE,SAAI,GAAG,cAAU,CAAC,SAAS,CAAC;IAuB9B,CAAC;IAHC,QAAQ,CAAC,GAAW;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAxBD,0CAwBC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport { Plugin } from \".\";\nimport { PluginType } from \"..\";\nimport type { GuildMember } from \"discord.js\";\nimport type { Awaitable, Playlist, Song } from \"..\";\n\n/**\n * Extractor Plugin\n * @extends Plugin\n * @abstract\n */\nexport abstract class ExtractorPlugin extends Plugin {\n type = PluginType.EXTRACTOR;\n /**\n * Resolve the validated url to a {@link Song} or a {@link Playlist}.\n *\n * @param {string} url URL\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {*} [options.metadata] Metadata\n * @returns {Song|Playlist|Promise<Song|Playlist>}\n * @abstract\n */\n abstract resolve<T = unknown>(\n url: string,\n options: { member?: GuildMember; metadata?: T },\n ): Awaitable<Song<T> | Playlist<T>>;\n /**\n * Check if the url is working with this plugin\n * @param {string} url Input url\n * @returns {boolean|Promise<boolean>}\n */\n validate(url: string): Awaitable<boolean> {\n return false;\n }\n}\n\n/**\n * Resolve the validated url to a {@link Song} or a {@link Playlist}.\n *\n * @param {string} url URL\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {*} [options.metadata] Metadata\n * @returns {Song|Playlist|Promise<Song|Playlist>}\n * @method resolve\n * @memberof ExtractorPlugin#\n * @abstract\n */\n"]}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import type ytpl from "@distube/ytpl";
|
|
2
2
|
import type { PlaylistInfo, Song } from "..";
|
|
3
3
|
import type { GuildMember } from "discord.js";
|
|
4
|
-
/**
|
|
5
|
-
* Class representing a playlist.
|
|
6
|
-
* @prop {string} source Playlist source
|
|
7
|
-
* @template T - The type for the metadata (if any) of the playlist
|
|
8
|
-
*/
|
|
9
4
|
export declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
10
5
|
#private;
|
|
11
6
|
source: string;
|
|
@@ -14,47 +9,16 @@ export declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
|
14
9
|
url?: string;
|
|
15
10
|
thumbnail?: string;
|
|
16
11
|
[x: string]: any;
|
|
17
|
-
constructor(playlist: Song[] | ytpl.result | PlaylistInfo);
|
|
18
|
-
/** @deprecated Passing GuildMember for DisTube#Playlist() is deprecated. */
|
|
19
|
-
constructor(playlist: Song[] | ytpl.result | PlaylistInfo, member?: GuildMember, properties?: Record<string, any>, metadata?: T);
|
|
20
|
-
/**
|
|
21
|
-
* Create a playlist
|
|
22
|
-
* @param {Song[]|PlaylistInfo} playlist Playlist
|
|
23
|
-
* @param {Object} [options] Optional options
|
|
24
|
-
* @param {Discord.GuildMember} [options.member] Requested user
|
|
25
|
-
* @param {Object} [options.properties] Custom properties
|
|
26
|
-
* @param {T} [options.metadata] Playlist metadata
|
|
27
|
-
*/
|
|
28
12
|
constructor(playlist: Song[] | ytpl.result | PlaylistInfo, options?: {
|
|
29
13
|
member?: GuildMember;
|
|
30
14
|
properties?: Record<string, any>;
|
|
31
15
|
metadata?: T;
|
|
32
16
|
});
|
|
33
|
-
/**
|
|
34
|
-
* Playlist duration in second.
|
|
35
|
-
* @type {number}
|
|
36
|
-
*/
|
|
37
17
|
get duration(): number;
|
|
38
|
-
/**
|
|
39
|
-
* Formatted duration string `hh:mm:ss`.
|
|
40
|
-
* @type {string}
|
|
41
|
-
*/
|
|
42
18
|
get formattedDuration(): string;
|
|
43
|
-
/**
|
|
44
|
-
* User requested.
|
|
45
|
-
* @type {Discord.GuildMember?}
|
|
46
|
-
*/
|
|
47
19
|
get member(): GuildMember | undefined;
|
|
48
20
|
set member(member: GuildMember | undefined);
|
|
49
|
-
/**
|
|
50
|
-
* User requested.
|
|
51
|
-
* @type {Discord.User?}
|
|
52
|
-
*/
|
|
53
21
|
get user(): import("discord.js").User | undefined;
|
|
54
|
-
/**
|
|
55
|
-
* Optional metadata that can be used to identify the playlist.
|
|
56
|
-
* @type {T}
|
|
57
|
-
*/
|
|
58
22
|
get metadata(): T;
|
|
59
23
|
set metadata(metadata: T);
|
|
60
24
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Playlist.d.ts","sourceRoot":"","sources":["../../src/struct/Playlist.ts"],"names":[],"mappings":"AACA,OAAO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107 +14,56 @@ var _Playlist_metadata, _Playlist_member;
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.Playlist = void 0;
|
|
16
16
|
const __1 = require("..");
|
|
17
|
-
// TODO: Remove ! on the next major version
|
|
18
|
-
/**
|
|
19
|
-
* Class representing a playlist.
|
|
20
|
-
* @prop {string} source Playlist source
|
|
21
|
-
* @template T - The type for the metadata (if any) of the playlist
|
|
22
|
-
*/
|
|
23
17
|
class Playlist {
|
|
24
|
-
constructor(playlist, options = {}
|
|
18
|
+
constructor(playlist, options = {}) {
|
|
25
19
|
_Playlist_metadata.set(this, void 0);
|
|
26
20
|
_Playlist_member.set(this, void 0);
|
|
27
|
-
if ((0, __1.isMemberInstance)(options)) {
|
|
28
|
-
process.emitWarning("Passing GuildMember for DisTube#Playlist() is deprecated, read the docs for more.", "DeprecationWarning");
|
|
29
|
-
return new Playlist(playlist, { member: options, properties: props, metadata: meta });
|
|
30
|
-
}
|
|
31
21
|
const { member, properties, metadata } = options;
|
|
32
22
|
if (typeof playlist !== "object") {
|
|
33
23
|
throw new __1.DisTubeError("INVALID_TYPE", ["Array<Song>", "object"], playlist, "playlist");
|
|
34
24
|
}
|
|
35
|
-
if (
|
|
25
|
+
if (typeof properties !== "undefined" && !(0, __1.isRecord)(properties)) {
|
|
36
26
|
throw new __1.DisTubeError("INVALID_TYPE", "object", properties, "properties");
|
|
37
27
|
}
|
|
38
|
-
// FIXME
|
|
39
28
|
const info = playlist;
|
|
40
|
-
/**
|
|
41
|
-
* The source of the playlist
|
|
42
|
-
* @type {string}
|
|
43
|
-
*/
|
|
44
29
|
this.source = (info.source || properties?.source || "youtube").toLowerCase();
|
|
45
|
-
/**
|
|
46
|
-
* Playlist songs.
|
|
47
|
-
* @type {Array<Song>}
|
|
48
|
-
*/
|
|
49
30
|
this.songs = Array.isArray(info) ? info : info.items || info.songs;
|
|
50
31
|
if (!Array.isArray(this.songs) || !this.songs.length) {
|
|
51
32
|
throw new __1.DisTubeError("EMPTY_PLAYLIST");
|
|
52
33
|
}
|
|
53
34
|
this.songs.map(s => s.constructor.name === "Song" && (s.playlist = this));
|
|
54
35
|
this.member = member || info.member || undefined;
|
|
55
|
-
/**
|
|
56
|
-
* Playlist name.
|
|
57
|
-
* @type {string}
|
|
58
|
-
*/
|
|
59
36
|
this.name =
|
|
60
37
|
info.name ||
|
|
61
38
|
info.title ||
|
|
62
39
|
(this.songs[0].name
|
|
63
40
|
? `${this.songs[0].name} and ${this.songs.length - 1} more songs.`
|
|
64
41
|
: `${this.songs.length} songs playlist`);
|
|
65
|
-
/**
|
|
66
|
-
* Playlist URL.
|
|
67
|
-
* @type {string}
|
|
68
|
-
*/
|
|
69
42
|
this.url = info.url || info.webpage_url;
|
|
70
|
-
/**
|
|
71
|
-
* Playlist thumbnail.
|
|
72
|
-
* @type {string?}
|
|
73
|
-
*/
|
|
74
43
|
this.thumbnail = info.thumbnail?.url || info.thumbnail || this.songs[0].thumbnail;
|
|
75
44
|
if (properties)
|
|
76
45
|
for (const [key, value] of Object.entries(properties))
|
|
77
46
|
this[key] = value;
|
|
78
47
|
this.metadata = metadata;
|
|
79
48
|
}
|
|
80
|
-
/**
|
|
81
|
-
* Playlist duration in second.
|
|
82
|
-
* @type {number}
|
|
83
|
-
*/
|
|
84
49
|
get duration() {
|
|
85
50
|
return this.songs?.reduce((prev, next) => prev + (next.duration || 0), 0) || 0;
|
|
86
51
|
}
|
|
87
|
-
/**
|
|
88
|
-
* Formatted duration string `hh:mm:ss`.
|
|
89
|
-
* @type {string}
|
|
90
|
-
*/
|
|
91
52
|
get formattedDuration() {
|
|
92
53
|
return (0, __1.formatDuration)(this.duration);
|
|
93
54
|
}
|
|
94
|
-
/**
|
|
95
|
-
* User requested.
|
|
96
|
-
* @type {Discord.GuildMember?}
|
|
97
|
-
*/
|
|
98
55
|
get member() {
|
|
99
56
|
return __classPrivateFieldGet(this, _Playlist_member, "f");
|
|
100
57
|
}
|
|
101
58
|
set member(member) {
|
|
102
|
-
if (!member)
|
|
59
|
+
if (!(0, __1.isMemberInstance)(member))
|
|
103
60
|
return;
|
|
104
61
|
__classPrivateFieldSet(this, _Playlist_member, member, "f");
|
|
105
62
|
this.songs.map(s => s.constructor.name === "Song" && (s.member = this.member));
|
|
106
63
|
}
|
|
107
|
-
/**
|
|
108
|
-
* User requested.
|
|
109
|
-
* @type {Discord.User?}
|
|
110
|
-
*/
|
|
111
64
|
get user() {
|
|
112
65
|
return this.member?.user;
|
|
113
66
|
}
|
|
114
|
-
/**
|
|
115
|
-
* Optional metadata that can be used to identify the playlist.
|
|
116
|
-
* @type {T}
|
|
117
|
-
*/
|
|
118
67
|
get metadata() {
|
|
119
68
|
return __classPrivateFieldGet(this, _Playlist_metadata, "f");
|
|
120
69
|
}
|