distube 3.0.6 → 3.2.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 +133 -65
- package/dist/DisTube.d.ts.map +1 -1
- package/dist/DisTube.js +161 -103
- package/dist/DisTube.js.map +1 -1
- package/dist/constant.d.ts +13 -14
- package/dist/constant.d.ts.map +1 -1
- package/dist/constant.js +13 -14
- package/dist/constant.js.map +1 -1
- package/dist/core/DisTubeBase.d.ts +3 -4
- package/dist/core/DisTubeBase.d.ts.map +1 -1
- package/dist/core/DisTubeBase.js +1 -2
- package/dist/core/DisTubeBase.js.map +1 -1
- package/dist/core/DisTubeHandler.d.ts +37 -25
- package/dist/core/DisTubeHandler.d.ts.map +1 -1
- package/dist/core/DisTubeHandler.js +72 -68
- package/dist/core/DisTubeHandler.js.map +1 -1
- package/dist/core/DisTubeOptions.d.ts +1 -2
- package/dist/core/DisTubeOptions.d.ts.map +1 -1
- package/dist/core/DisTubeOptions.js +64 -58
- package/dist/core/DisTubeOptions.js.map +1 -1
- package/dist/core/DisTubeStream.d.ts +1 -1
- package/dist/core/DisTubeStream.d.ts.map +1 -1
- package/dist/core/DisTubeStream.js +0 -1
- package/dist/core/DisTubeStream.js.map +1 -1
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +2 -2
- package/dist/core/index.js.map +1 -1
- package/dist/core/manager/BaseManager.d.ts +11 -7
- package/dist/core/manager/BaseManager.d.ts.map +1 -1
- package/dist/core/manager/BaseManager.js +11 -13
- package/dist/core/manager/BaseManager.js.map +1 -1
- package/dist/core/manager/QueueManager.d.ts +11 -38
- package/dist/core/manager/QueueManager.d.ts.map +1 -1
- package/dist/core/manager/QueueManager.js +115 -129
- package/dist/core/manager/QueueManager.js.map +1 -1
- package/dist/core/voice/DJSAdapter.js +4 -7
- package/dist/core/voice/DJSAdapter.js.map +1 -1
- package/dist/core/voice/DisTubeVoice.d.ts +10 -13
- package/dist/core/voice/DisTubeVoice.d.ts.map +1 -1
- package/dist/core/voice/DisTubeVoice.js +39 -28
- package/dist/core/voice/DisTubeVoice.js.map +1 -1
- package/dist/core/voice/DisTubeVoiceManager.d.ts +10 -10
- package/dist/core/voice/DisTubeVoiceManager.d.ts.map +1 -1
- package/dist/core/voice/DisTubeVoiceManager.js +5 -5
- package/dist/core/voice/DisTubeVoiceManager.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin/http.d.ts +5 -3
- package/dist/plugin/http.d.ts.map +1 -1
- package/dist/plugin/http.js +3 -5
- package/dist/plugin/http.js.map +1 -1
- package/dist/plugin/https.d.ts +10 -5
- package/dist/plugin/https.d.ts.map +1 -1
- package/dist/plugin/https.js +6 -9
- package/dist/plugin/https.js.map +1 -1
- package/dist/plugin/youtube-dl.d.ts +5 -4
- package/dist/plugin/youtube-dl.d.ts.map +1 -1
- package/dist/plugin/youtube-dl.js +6 -11
- package/dist/plugin/youtube-dl.js.map +1 -1
- package/dist/struct/CustomPlugin.d.ts +37 -17
- package/dist/struct/CustomPlugin.d.ts.map +1 -1
- package/dist/struct/CustomPlugin.js +18 -19
- package/dist/struct/CustomPlugin.js.map +1 -1
- package/dist/struct/DisTubeError.d.ts +4 -3
- package/dist/struct/DisTubeError.d.ts.map +1 -1
- package/dist/struct/DisTubeError.js +5 -7
- package/dist/struct/DisTubeError.js.map +1 -1
- package/dist/struct/ExtractorPlugin.d.ts +25 -15
- package/dist/struct/ExtractorPlugin.d.ts.map +1 -1
- package/dist/struct/ExtractorPlugin.js +14 -16
- package/dist/struct/ExtractorPlugin.js.map +1 -1
- package/dist/struct/Playlist.d.ts +24 -8
- package/dist/struct/Playlist.d.ts.map +1 -1
- package/dist/struct/Playlist.js +27 -14
- package/dist/struct/Playlist.js.map +1 -1
- package/dist/struct/Plugin.d.ts +4 -12
- package/dist/struct/Plugin.d.ts.map +1 -1
- package/dist/struct/Plugin.js +1 -11
- package/dist/struct/Plugin.js.map +1 -1
- package/dist/struct/Queue.d.ts +5 -6
- package/dist/struct/Queue.d.ts.map +1 -1
- package/dist/struct/Queue.js +5 -9
- package/dist/struct/Queue.js.map +1 -1
- package/dist/struct/SearchResult.d.ts +0 -1
- package/dist/struct/SearchResult.d.ts.map +1 -1
- package/dist/struct/SearchResult.js +2 -4
- package/dist/struct/SearchResult.js.map +1 -1
- package/dist/struct/Song.d.ts +26 -10
- package/dist/struct/Song.d.ts.map +1 -1
- package/dist/struct/Song.js +37 -25
- package/dist/struct/Song.js.map +1 -1
- package/dist/struct/TaskQueue.d.ts +1 -6
- package/dist/struct/TaskQueue.d.ts.map +1 -1
- package/dist/struct/TaskQueue.js +13 -7
- package/dist/struct/TaskQueue.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/type.d.ts +12 -12
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/dist/util.d.ts +6 -6
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +9 -15
- package/dist/util.js.map +1 -1
- package/package.json +5 -6
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import ExtractorPlugin from "
|
|
2
|
-
import { Playlist, Song } from "../struct";
|
|
1
|
+
import { ExtractorPlugin, Playlist, Song } from "..";
|
|
3
2
|
import type { GuildMember } from "discord.js";
|
|
4
3
|
export declare class YouTubeDLPlugin extends ExtractorPlugin {
|
|
5
4
|
constructor(updateYouTubeDL?: boolean);
|
|
6
5
|
validate(): Promise<boolean>;
|
|
7
|
-
resolve(url: string, member
|
|
6
|
+
resolve(url: string, { member, metadata }: {
|
|
7
|
+
member?: GuildMember;
|
|
8
|
+
metadata?: any;
|
|
9
|
+
}): Promise<Playlist<any> | Song<any>>;
|
|
8
10
|
getStreamURL(url: string): Promise<string>;
|
|
9
11
|
}
|
|
10
|
-
export default YouTubeDLPlugin;
|
|
11
12
|
//# sourceMappingURL=youtube-dl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"youtube-dl.d.ts","sourceRoot":"","sources":["../../src/plugin/youtube-dl.ts"],"names":[],"mappings":"AACA,OAAO,eAAe,
|
|
1
|
+
{"version":3,"file":"youtube-dl.d.ts","sourceRoot":"","sources":["../../src/plugin/youtube-dl.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAG9C,qBAAa,eAAgB,SAAQ,eAAe;gBACtC,eAAe,UAAO;IAY5B,QAAQ;IAIR,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAC;QAAC,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAE;IAkBnF,YAAY,CAAC,GAAG,EAAE,MAAM;CAW/B"}
|
|
@@ -18,15 +18,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
-
};
|
|
24
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
22
|
exports.YouTubeDLPlugin = void 0;
|
|
26
23
|
const youtube_dl_1 = __importStar(require("@distube/youtube-dl"));
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
class YouTubeDLPlugin extends ExtractorPlugin_1.default {
|
|
24
|
+
const __1 = require("..");
|
|
25
|
+
class YouTubeDLPlugin extends __1.ExtractorPlugin {
|
|
30
26
|
constructor(updateYouTubeDL = true) {
|
|
31
27
|
super();
|
|
32
28
|
if (updateYouTubeDL) {
|
|
@@ -42,7 +38,7 @@ class YouTubeDLPlugin extends ExtractorPlugin_1.default {
|
|
|
42
38
|
async validate() {
|
|
43
39
|
return true;
|
|
44
40
|
}
|
|
45
|
-
async resolve(url, member) {
|
|
41
|
+
async resolve(url, { member, metadata }) {
|
|
46
42
|
const info = await (0, youtube_dl_1.default)(url, {
|
|
47
43
|
dumpSingleJson: true,
|
|
48
44
|
noWarnings: true,
|
|
@@ -53,10 +49,10 @@ class YouTubeDLPlugin extends ExtractorPlugin_1.default {
|
|
|
53
49
|
});
|
|
54
50
|
if (Array.isArray(info.entries) && info.entries.length > 0) {
|
|
55
51
|
info.source = info.extractor.match(/\w+/)[0];
|
|
56
|
-
info.songs = info.entries.map((i) => new
|
|
57
|
-
return new
|
|
52
|
+
info.songs = info.entries.map((i) => new __1.Song(i, { member, source: i.extractor, metadata }));
|
|
53
|
+
return new __1.Playlist(info, { member, metadata, properties: { source: info.songs[0]?.source } });
|
|
58
54
|
}
|
|
59
|
-
return new
|
|
55
|
+
return new __1.Song(info, { member, source: info.extractor, metadata });
|
|
60
56
|
}
|
|
61
57
|
async getStreamURL(url) {
|
|
62
58
|
const info = await (0, youtube_dl_1.default)(url, {
|
|
@@ -71,5 +67,4 @@ class YouTubeDLPlugin extends ExtractorPlugin_1.default {
|
|
|
71
67
|
}
|
|
72
68
|
}
|
|
73
69
|
exports.YouTubeDLPlugin = YouTubeDLPlugin;
|
|
74
|
-
exports.default = YouTubeDLPlugin;
|
|
75
70
|
//# sourceMappingURL=youtube-dl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"youtube-dl.js","sourceRoot":"","sources":["../../src/plugin/youtube-dl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"youtube-dl.js","sourceRoot":"","sources":["../../src/plugin/youtube-dl.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,kEAA8D;AAC9D,0BAAqD;AAKrD,MAAa,eAAgB,SAAQ,mBAAe;IAClD,YAAY,eAAe,GAA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E,QAAQ,EAAE,CAAC,CAC1F,CAAC;YACF,OAAO,IAAI,YAAQ,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;SAChG;QACD,OAAO,IAAI,QAAI,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;IACtE,CAAC;IACD,KAAK,CAAC,YAAY,CAAC,GAAW;QAC5B,MAAM,IAAI,GAAG,MAAM,IAAA,oBAAa,EAAC,GAAG,EAAE;YACpC,cAAc,EAAE,IAAI;YACpB,UAAU,EAAE,IAAI;YAChB,UAAU,EAAE,IAAI;YAChB,iBAAiB,EAAE,IAAI;SACxB,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;YACX,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;QACH,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF;AA9CD,0CA8CC","sourcesContent":["import youtubeDlExec, { download } from \"@distube/youtube-dl\";\nimport { ExtractorPlugin, Playlist, Song } from \"..\";\nimport type { OtherSongInfo } from \"..\";\nimport type { GuildMember } from \"discord.js\";\nimport type { YtResponse } from \"@distube/youtube-dl\";\n\nexport class YouTubeDLPlugin extends ExtractorPlugin {\n constructor(updateYouTubeDL = true) {\n super();\n if (updateYouTubeDL) {\n /* eslint-disable no-console */\n download()\n .then((version: any) => console.log(`[DisTube] Updated youtube-dl to ${version}!`))\n .catch(console.error)\n .catch(() => console.warn(\"[DisTube] Unable to update youtube-dl, using default version.\"));\n /* eslint-enable no-console */\n }\n }\n // eslint-disable-next-line @typescript-eslint/require-await\n async validate() {\n return true;\n }\n\n async resolve(url: string, { member, metadata }: { member?: GuildMember; metadata?: any }) {\n const info: any = await youtubeDlExec(url, {\n dumpSingleJson: true,\n noWarnings: true,\n noCallHome: true,\n preferFreeFormats: true,\n }).catch(e => {\n throw new Error(`[youtube-dl] ${e.stderr || e}`);\n });\n if (Array.isArray(info.entries) && info.entries.length > 0) {\n info.source = info.extractor.match(/\\w+/)[0];\n info.songs = info.entries.map(\n (i: OtherSongInfo & YtResponse) => new Song(i, { member, source: i.extractor, metadata }),\n );\n return new Playlist(info, { member, metadata, properties: { source: info.songs[0]?.source } });\n }\n return new Song(info, { member, source: info.extractor, metadata });\n }\n async getStreamURL(url: string) {\n const info = await youtubeDlExec(url, {\n dumpSingleJson: true,\n noWarnings: true,\n noCallHome: true,\n preferFreeFormats: true,\n }).catch(e => {\n throw new Error(`[youtube-dl] ${e.stderr || e}`);\n });\n return info.url;\n }\n}\n"]}
|
|
@@ -1,27 +1,47 @@
|
|
|
1
|
-
import Plugin from "
|
|
1
|
+
import { Plugin } from ".";
|
|
2
2
|
import { PluginType } from "..";
|
|
3
|
-
import type { GuildMember,
|
|
3
|
+
import type { GuildMember, GuildTextBasedChannel, VoiceBasedChannel } from "discord.js";
|
|
4
4
|
/**
|
|
5
5
|
* Custom Plugin
|
|
6
6
|
* @extends Plugin
|
|
7
7
|
* @abstract
|
|
8
8
|
*/
|
|
9
9
|
export declare abstract class CustomPlugin extends Plugin {
|
|
10
|
+
/**
|
|
11
|
+
* This method will be executed if the url is validated.
|
|
12
|
+
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
|
|
13
|
+
* @param {string} song Validated url
|
|
14
|
+
* @param {Object} [options] Optional options
|
|
15
|
+
* @param {Discord.GuildMember} [options.member] Requested user
|
|
16
|
+
* @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}
|
|
17
|
+
* @param {boolean} [options.skip] Skip the playing song (if exists) and play the added song/playlist instantly
|
|
18
|
+
* @param {boolean} [options.unshift] Add the song/playlist after the playing song if exists
|
|
19
|
+
* @param {*} [options.metadata] Metadata
|
|
20
|
+
* @returns {Promise<void>}
|
|
21
|
+
* @abstract
|
|
22
|
+
* @method play
|
|
23
|
+
* @memberof CustomPlugin#
|
|
24
|
+
*/
|
|
10
25
|
type: PluginType;
|
|
11
|
-
|
|
26
|
+
/**
|
|
27
|
+
* This method will be executed if the url is validated.
|
|
28
|
+
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
|
|
29
|
+
* @param {string} song Validated url
|
|
30
|
+
* @param {Object} [options] Optional options
|
|
31
|
+
* @param {Discord.GuildMember} [options.member] Requested user
|
|
32
|
+
* @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}
|
|
33
|
+
* @param {boolean} [options.skip] Skip the playing song (if exists) and play the added song/playlist instantly
|
|
34
|
+
* @param {boolean} [options.unshift] Add the song/playlist after the playing song if exists
|
|
35
|
+
* @param {*} [options.metadata] Metadata
|
|
36
|
+
* @returns {Promise<void>}
|
|
37
|
+
* @abstract
|
|
38
|
+
*/
|
|
39
|
+
abstract play(voiceChannel: VoiceBasedChannel, song: string, options: {
|
|
40
|
+
skip?: boolean;
|
|
41
|
+
unshift?: boolean;
|
|
42
|
+
member?: GuildMember;
|
|
43
|
+
textChannel?: GuildTextBasedChannel;
|
|
44
|
+
metadata?: any;
|
|
45
|
+
}): Promise<void>;
|
|
12
46
|
}
|
|
13
|
-
/**
|
|
14
|
-
* This method will be executed if the url is validated.
|
|
15
|
-
* @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined
|
|
16
|
-
* @param {string} url Validated url
|
|
17
|
-
* @param {Discord.GuildMember} member Requested user
|
|
18
|
-
* @param {Discord.TextChannel?} textChannel Default {@link Queue#textChannel}
|
|
19
|
-
* @param {boolean} skip Skip the playing song (if exists) and play the added song/playlist instantly
|
|
20
|
-
* @param {boolean} unshift Add the song/playlist to the beginning of the queue (after the playing song if exists)
|
|
21
|
-
* @returns {Promise<void>}
|
|
22
|
-
* @method play
|
|
23
|
-
* @memberof CustomPlugin#
|
|
24
|
-
* @abstract
|
|
25
|
-
*/
|
|
26
|
-
export default CustomPlugin;
|
|
27
47
|
//# sourceMappingURL=CustomPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"CustomPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/CustomPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAIxF;;;;GAIG;AACH,8BAAsB,YAAa,SAAQ,MAAM;IAC/C;;;;;;;;;;;;;;OAcG;IACH,IAAI,aAAqB;IACzB;;;;;;;;;;;;OAYG;IACH,QAAQ,CAAC,IAAI,CACX,YAAY,EAAE,iBAAiB,EAC/B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QACP,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,WAAW,CAAC,EAAE,qBAAqB,CAAC;QACpC,QAAQ,CAAC,EAAE,GAAG,CAAC;KAChB,GACA,OAAO,CAAC,IAAI,CAAC;CACjB"}
|
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.CustomPlugin = void 0;
|
|
7
|
-
const
|
|
4
|
+
const _1 = require(".");
|
|
8
5
|
const __1 = require("..");
|
|
6
|
+
// TODO: Clean parameters on the next major version.
|
|
9
7
|
/**
|
|
10
8
|
* Custom Plugin
|
|
11
9
|
* @extends Plugin
|
|
12
10
|
* @abstract
|
|
13
11
|
*/
|
|
14
|
-
class CustomPlugin extends
|
|
12
|
+
class CustomPlugin extends _1.Plugin {
|
|
15
13
|
constructor() {
|
|
16
14
|
super(...arguments);
|
|
15
|
+
/**
|
|
16
|
+
* This method will be executed if the url is validated.
|
|
17
|
+
* @param {Discord.BaseGuildVoiceChannel} voiceChannel The voice channel will be joined
|
|
18
|
+
* @param {string} song Validated url
|
|
19
|
+
* @param {Object} [options] Optional options
|
|
20
|
+
* @param {Discord.GuildMember} [options.member] Requested user
|
|
21
|
+
* @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}
|
|
22
|
+
* @param {boolean} [options.skip] Skip the playing song (if exists) and play the added song/playlist instantly
|
|
23
|
+
* @param {boolean} [options.unshift] Add the song/playlist after the playing song if exists
|
|
24
|
+
* @param {*} [options.metadata] Metadata
|
|
25
|
+
* @returns {Promise<void>}
|
|
26
|
+
* @abstract
|
|
27
|
+
* @method play
|
|
28
|
+
* @memberof CustomPlugin#
|
|
29
|
+
*/
|
|
17
30
|
this.type = __1.PluginType.CUSTOM;
|
|
18
31
|
}
|
|
19
32
|
}
|
|
20
33
|
exports.CustomPlugin = CustomPlugin;
|
|
21
|
-
/**
|
|
22
|
-
* This method will be executed if the url is validated.
|
|
23
|
-
* @param {Discord.VoiceChannel|Discord.StageChannel} voiceChannel The voice channel will be joined
|
|
24
|
-
* @param {string} url Validated url
|
|
25
|
-
* @param {Discord.GuildMember} member Requested user
|
|
26
|
-
* @param {Discord.TextChannel?} textChannel Default {@link Queue#textChannel}
|
|
27
|
-
* @param {boolean} skip Skip the playing song (if exists) and play the added song/playlist instantly
|
|
28
|
-
* @param {boolean} unshift Add the song/playlist to the beginning of the queue (after the playing song if exists)
|
|
29
|
-
* @returns {Promise<void>}
|
|
30
|
-
* @method play
|
|
31
|
-
* @memberof CustomPlugin#
|
|
32
|
-
* @abstract
|
|
33
|
-
*/
|
|
34
|
-
exports.default = CustomPlugin;
|
|
35
34
|
//# 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":";;;AAAA,wBAA2B;AAC3B,0BAAgC;AAGhC,oDAAoD;AAEpD;;;;GAIG;AACH,MAAsB,YAAa,SAAQ,SAAM;IAAjD;;QACE;;;;;;;;;;;;;;WAcG;QACH,SAAI,GAAG,cAAU,CAAC,MAAM,CAAC;IAyB3B,CAAC;CAAA;AAzCD,oCAyCC","sourcesContent":["import { Plugin } from \".\";\nimport { PluginType } from \"..\";\nimport type { GuildMember, GuildTextBasedChannel, VoiceBasedChannel } from \"discord.js\";\n\n// TODO: Clean parameters on the next major version.\n\n/**\n * Custom Plugin\n * @extends Plugin\n * @abstract\n */\nexport abstract class CustomPlugin extends Plugin {\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 url\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}\n * @param {boolean} [options.skip] Skip the playing song (if exists) and play the added song/playlist instantly\n * @param {boolean} [options.unshift] Add the song/playlist after the playing song if exists\n * @param {*} [options.metadata] Metadata\n * @returns {Promise<void>}\n * @abstract\n * @method play\n * @memberof CustomPlugin#\n */\n type = PluginType.CUSTOM;\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 url\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {Discord.BaseGuildTextChannel} [options.textChannel] Default {@link Queue#textChannel}\n * @param {boolean} [options.skip] Skip the playing song (if exists) and play the added song/playlist instantly\n * @param {boolean} [options.unshift] Add the song/playlist after the playing song if exists\n * @param {*} [options.metadata] Metadata\n * @returns {Promise<void>}\n * @abstract\n */\n abstract play(\n voiceChannel: VoiceBasedChannel,\n song: string,\n options: {\n skip?: boolean;\n unshift?: boolean;\n member?: GuildMember;\n textChannel?: GuildTextBasedChannel;\n metadata?: any;\n },\n ): Promise<void>;\n}\n"]}
|
|
@@ -3,13 +3,14 @@ declare const ERROR_MESSAGES: {
|
|
|
3
3
|
NUMBER_COMPARE: (name: string, expected: string, value: number) => string;
|
|
4
4
|
EMPTY_ARRAY: (name: string) => string;
|
|
5
5
|
EMPTY_FILTERED_ARRAY: (name: string, type: string) => string;
|
|
6
|
-
INVALID_KEY: (obj: string, key: string) => string;
|
|
7
6
|
EMPTY_STRING: (name: string) => string;
|
|
7
|
+
INVALID_KEY: (obj: string, key: string) => string;
|
|
8
|
+
MISSING_KEY: (obj: string, key: string) => string;
|
|
9
|
+
MISSING_KEYS: (obj: string, key: string[], all: boolean) => string;
|
|
8
10
|
MISSING_INTENTS: (i: string) => string;
|
|
9
11
|
DISABLED_OPTION: (o: string) => string;
|
|
10
12
|
ENABLED_OPTION: (o: string) => string;
|
|
11
13
|
NOT_IN_VOICE: string;
|
|
12
|
-
NOT_SUPPORTED_VOICE: string;
|
|
13
14
|
VOICE_FULL: string;
|
|
14
15
|
VOICE_CONNECT_FAILED: (s: number) => string;
|
|
15
16
|
VOICE_MISSING_PERMS: string;
|
|
@@ -52,5 +53,5 @@ export declare class DisTubeError<T extends string> extends Error {
|
|
|
52
53
|
get name(): string;
|
|
53
54
|
get code(): string;
|
|
54
55
|
}
|
|
55
|
-
export
|
|
56
|
+
export {};
|
|
56
57
|
//# sourceMappingURL=DisTubeError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeError.d.ts","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":"
|
|
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;;;;;;;;;;;;;;;;;;;;;6BAyBP,MAAM;;;;CAMhC,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"}
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DisTubeError = void 0;
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
4
5
|
const ERROR_MESSAGES = {
|
|
5
|
-
INVALID_TYPE: (expected, got, name) => {
|
|
6
|
-
var _a, _b;
|
|
7
|
-
return `Expected ${Array.isArray(expected) ? expected.map(e => (typeof e === "number" ? e : `'${e}'`)).join(" or ") : `'${expected}'`}${name ? ` for '${name}'` : ""}, but got ${JSON.stringify(got)} (${(_b = (_a = got === null || got === void 0 ? void 0 : got.constructor) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : typeof got})`;
|
|
8
|
-
},
|
|
6
|
+
INVALID_TYPE: (expected, got, name) => `Expected ${Array.isArray(expected) ? expected.map(e => (typeof e === "number" ? e : `'${e}'`)).join(" or ") : `'${expected}'`}${name ? ` for '${name}'` : ""}, but got ${(0, node_util_1.inspect)(got)}`,
|
|
9
7
|
NUMBER_COMPARE: (name, expected, value) => `'${name}' must be ${expected} ${value}`,
|
|
10
8
|
EMPTY_ARRAY: (name) => `'${name}' is an empty array`,
|
|
11
9
|
EMPTY_FILTERED_ARRAY: (name, type) => `There is no valid '${type}' in the '${name}' array`,
|
|
12
|
-
INVALID_KEY: (obj, key) => `'${key}' does not need to be provided in ${obj}`,
|
|
13
10
|
EMPTY_STRING: (name) => `'${name}' string must not be empty`,
|
|
11
|
+
INVALID_KEY: (obj, key) => `'${key}' does not need to be provided in ${obj}`,
|
|
12
|
+
MISSING_KEY: (obj, key) => `'${key}' needs to be provided in ${obj}`,
|
|
13
|
+
MISSING_KEYS: (obj, key, all) => `${key.map(k => `'${k}'`).join(all ? " and " : " or ")} need to be provided in ${obj}`,
|
|
14
14
|
MISSING_INTENTS: (i) => `${i} intent must be provided for the Client`,
|
|
15
15
|
DISABLED_OPTION: (o) => `DisTubeOptions.${o} is disabled`,
|
|
16
16
|
ENABLED_OPTION: (o) => `DisTubeOptions.${o} is enabled`,
|
|
17
17
|
NOT_IN_VOICE: "User is not in any voice channel",
|
|
18
|
-
NOT_SUPPORTED_VOICE: "DisTubeVoice only supports VoiceChannel or a StageChannel",
|
|
19
18
|
VOICE_FULL: "The voice channel is full",
|
|
20
19
|
VOICE_CONNECT_FAILED: (s) => `Cannot connect to the voice channel after ${s} seconds`,
|
|
21
20
|
VOICE_MISSING_PERMS: "You do not have permission to join this voice channel",
|
|
@@ -65,5 +64,4 @@ class DisTubeError extends Error {
|
|
|
65
64
|
}
|
|
66
65
|
}
|
|
67
66
|
exports.DisTubeError = DisTubeError;
|
|
68
|
-
exports.default = DisTubeError;
|
|
69
67
|
//# sourceMappingURL=DisTubeError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DisTubeError.js","sourceRoot":"","sources":["../../src/struct/DisTubeError.ts"],"names":[],"mappings":";;;AAAA,MAAM,cAAc,GAAG;IACrB,YAAY,EAAE,CAAC,QAA0D,EAAE,GAAQ,EAAE,IAAa,EAAE,EAAE
|
|
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,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAA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Y,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 VOICE_DEPRECATED_CONNECTION:\n \"Cannot connect to the voice channel due to a deprecated connection is created.\\n\" +\n \"Read more: https://distube.js.org/guide/additional-info/update.html#voice\",\n\n NO_QUEUE: \"There is no playing queue in this guild\",\n QUEUE_EXIST: \"This guild has a Queue already\",\n ADD_BEFORE_PLAYING: \"Cannot add Song before the playing Song\",\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: string) => `Cannot resolve ${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"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Plugin from "
|
|
1
|
+
import { Plugin } from ".";
|
|
2
2
|
import { PluginType } from "..";
|
|
3
3
|
import type { Playlist, Song } from ".";
|
|
4
4
|
import type { GuildMember } from "discord.js";
|
|
@@ -8,22 +8,32 @@ import type { GuildMember } from "discord.js";
|
|
|
8
8
|
* @abstract
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class ExtractorPlugin extends Plugin {
|
|
11
|
+
/**
|
|
12
|
+
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
13
|
+
*
|
|
14
|
+
* @param {string} url URL
|
|
15
|
+
* @param {Object} [options] Optional options
|
|
16
|
+
* @param {Discord.GuildMember} [options.member] Requested user
|
|
17
|
+
* @param {*} [options.metadata] Metadata
|
|
18
|
+
* @returns {Promise<Song|Playlist>}
|
|
19
|
+
* @method resolve
|
|
20
|
+
* @memberof ExtractorPlugin#
|
|
21
|
+
* @abstract
|
|
22
|
+
*/
|
|
11
23
|
type: PluginType;
|
|
12
24
|
/**
|
|
13
|
-
* Resolve the validated url to a {@link Song} or a {@link Playlist}
|
|
14
|
-
*
|
|
25
|
+
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
26
|
+
*
|
|
27
|
+
* @param {string} url URL
|
|
28
|
+
* @param {Object} [options] Optional options
|
|
29
|
+
* @param {Discord.GuildMember} [options.member] Requested user
|
|
30
|
+
* @param {*} [options.metadata] Metadata
|
|
31
|
+
* @returns {Promise<Song|Playlist>}
|
|
32
|
+
* @abstract
|
|
15
33
|
*/
|
|
16
|
-
abstract resolve(url: string,
|
|
34
|
+
abstract resolve<T = unknown>(url: string, options: {
|
|
35
|
+
member?: GuildMember;
|
|
36
|
+
metadata?: T;
|
|
37
|
+
}): Promise<Song<T> | Playlist<T>>;
|
|
17
38
|
}
|
|
18
|
-
/**
|
|
19
|
-
* Resolve the validated url to a {@link Song} or a {@link Playlist}.\
|
|
20
|
-
* Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs}.
|
|
21
|
-
* @param {string} url URL
|
|
22
|
-
* @param {Discord.GuildMember} member Requested user
|
|
23
|
-
* @returns {Promise<Song|Song[]|Playlist>}
|
|
24
|
-
* @method resolve
|
|
25
|
-
* @memberof ExtractorPlugin#
|
|
26
|
-
* @abstract
|
|
27
|
-
*/
|
|
28
|
-
export default ExtractorPlugin;
|
|
29
39
|
//# sourceMappingURL=ExtractorPlugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtractorPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"ExtractorPlugin.d.ts","sourceRoot":"","sources":["../../src/struct/ExtractorPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAChC,OAAO,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AACH,8BAAsB,eAAgB,SAAQ,MAAM;IAClD;;;;;;;;;;;OAWG;IACH,IAAI,aAAwB;IAC5B;;;;;;;;;OASG;IACH,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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;CAClC"}
|
|
@@ -1,32 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.ExtractorPlugin = void 0;
|
|
7
|
-
const
|
|
4
|
+
const _1 = require(".");
|
|
8
5
|
const __1 = require("..");
|
|
9
6
|
/**
|
|
10
7
|
* Extractor Plugin
|
|
11
8
|
* @extends Plugin
|
|
12
9
|
* @abstract
|
|
13
10
|
*/
|
|
14
|
-
class ExtractorPlugin extends
|
|
11
|
+
class ExtractorPlugin extends _1.Plugin {
|
|
15
12
|
constructor() {
|
|
16
13
|
super(...arguments);
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the validated url to a {@link Song} or a {@link Playlist}.
|
|
16
|
+
*
|
|
17
|
+
* @param {string} url URL
|
|
18
|
+
* @param {Object} [options] Optional options
|
|
19
|
+
* @param {Discord.GuildMember} [options.member] Requested user
|
|
20
|
+
* @param {*} [options.metadata] Metadata
|
|
21
|
+
* @returns {Promise<Song|Playlist>}
|
|
22
|
+
* @method resolve
|
|
23
|
+
* @memberof ExtractorPlugin#
|
|
24
|
+
* @abstract
|
|
25
|
+
*/
|
|
17
26
|
this.type = __1.PluginType.EXTRACTOR;
|
|
18
27
|
}
|
|
19
28
|
}
|
|
20
29
|
exports.ExtractorPlugin = ExtractorPlugin;
|
|
21
|
-
/**
|
|
22
|
-
* Resolve the validated url to a {@link Song} or a {@link Playlist}.\
|
|
23
|
-
* Not needed to add {@link Song#related} because it will be added with {@link Plugin#getRelatedSongs}.
|
|
24
|
-
* @param {string} url URL
|
|
25
|
-
* @param {Discord.GuildMember} member Requested user
|
|
26
|
-
* @returns {Promise<Song|Song[]|Playlist>}
|
|
27
|
-
* @method resolve
|
|
28
|
-
* @memberof ExtractorPlugin#
|
|
29
|
-
* @abstract
|
|
30
|
-
*/
|
|
31
|
-
exports.default = ExtractorPlugin;
|
|
32
30
|
//# 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":";;;AAAA,wBAA2B;AAC3B,0BAAgC;AAIhC;;;;GAIG;AACH,MAAsB,eAAgB,SAAQ,SAAM;IAApD;;QACE;;;;;;;;;;;WAWG;QACH,SAAI,GAAG,cAAU,CAAC,SAAS,CAAC;IAe9B,CAAC;CAAA;AA5BD,0CA4BC","sourcesContent":["import { Plugin } from \".\";\nimport { PluginType } from \"..\";\nimport type { Playlist, Song } from \".\";\nimport type { GuildMember } from \"discord.js\";\n\n/**\n * Extractor Plugin\n * @extends Plugin\n * @abstract\n */\nexport abstract class ExtractorPlugin extends Plugin {\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 {Promise<Song|Playlist>}\n * @method resolve\n * @memberof ExtractorPlugin#\n * @abstract\n */\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 {Promise<Song|Playlist>}\n * @abstract\n */\n abstract resolve<T = unknown>(\n url: string,\n options: { member?: GuildMember; metadata?: T },\n ): Promise<Song<T> | Playlist<T>>;\n}\n"]}
|
|
@@ -4,23 +4,34 @@ import type { GuildMember, User } from "discord.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Class representing a playlist.
|
|
6
6
|
* @prop {string} source Playlist source
|
|
7
|
+
* @template T - The type for the metadata (if any) of the playlist
|
|
7
8
|
*/
|
|
8
|
-
export declare class Playlist implements PlaylistInfo {
|
|
9
|
+
export declare class Playlist<T = unknown> implements PlaylistInfo {
|
|
9
10
|
source: string;
|
|
10
|
-
member?: GuildMember;
|
|
11
|
-
user?: User;
|
|
12
11
|
songs: Song[];
|
|
13
12
|
name: string;
|
|
13
|
+
metadata: T;
|
|
14
|
+
member?: GuildMember;
|
|
15
|
+
user?: User;
|
|
14
16
|
url?: string;
|
|
15
17
|
thumbnail?: string;
|
|
16
18
|
[x: string]: any;
|
|
19
|
+
constructor(playlist: Song[] | ytpl.result | PlaylistInfo);
|
|
20
|
+
/** @deprecated Passing GuildMember for DisTube#Playlist() is deprecated. */
|
|
21
|
+
constructor(playlist: Song[] | ytpl.result | PlaylistInfo, member?: GuildMember, properties?: Record<string, any>, metadata?: T);
|
|
17
22
|
/**
|
|
18
23
|
* Create a playlist
|
|
19
24
|
* @param {Song[]|PlaylistInfo} playlist Playlist
|
|
20
|
-
* @param {
|
|
21
|
-
* @param {
|
|
25
|
+
* @param {Object} [options] Optional options
|
|
26
|
+
* @param {Discord.GuildMember} [options.member] Requested user
|
|
27
|
+
* @param {Object} [options.properties] Custom properties
|
|
28
|
+
* @param {T} [options.metadata] Playlist metadata
|
|
22
29
|
*/
|
|
23
|
-
constructor(playlist: Song[] | ytpl.result | PlaylistInfo,
|
|
30
|
+
constructor(playlist: Song[] | ytpl.result | PlaylistInfo, options?: {
|
|
31
|
+
member?: GuildMember;
|
|
32
|
+
properties?: Record<string, any>;
|
|
33
|
+
metadata?: T;
|
|
34
|
+
});
|
|
24
35
|
/**
|
|
25
36
|
* Playlist duration in second.
|
|
26
37
|
* @type {number}
|
|
@@ -36,7 +47,12 @@ export declare class Playlist implements PlaylistInfo {
|
|
|
36
47
|
* @private
|
|
37
48
|
* @returns {Playlist}
|
|
38
49
|
*/
|
|
39
|
-
_patchMember(member?: GuildMember):
|
|
50
|
+
_patchMember(member?: GuildMember): this;
|
|
51
|
+
/**
|
|
52
|
+
* @param {*} metadata Metadata
|
|
53
|
+
* @private
|
|
54
|
+
* @returns {Playlist}
|
|
55
|
+
*/
|
|
56
|
+
_patchMetadata<S = unknown>(metadata: S): Playlist<S>;
|
|
40
57
|
}
|
|
41
|
-
export default Playlist;
|
|
42
58
|
//# sourceMappingURL=Playlist.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Playlist.d.ts","sourceRoot":"","sources":["../../src/struct/Playlist.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"Playlist.d.ts","sourceRoot":"","sources":["../../src/struct/Playlist.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,eAAe,CAAC;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,IAAI,CAAC;AAC7C,OAAO,KAAK,EAAE,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 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Playlist = void 0;
|
|
4
4
|
const __1 = require("..");
|
|
5
|
+
// TODO: Remove ! on the next major version
|
|
5
6
|
/**
|
|
6
7
|
* Class representing a playlist.
|
|
7
8
|
* @prop {string} source Playlist source
|
|
9
|
+
* @template T - The type for the metadata (if any) of the playlist
|
|
8
10
|
*/
|
|
9
11
|
class Playlist {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
constructor(playlist, member, properties = {}) {
|
|
17
|
-
var _a;
|
|
12
|
+
constructor(playlist, options = {}, props = {}, meta) {
|
|
13
|
+
if ((0, __1.isMemberInstance)(options)) {
|
|
14
|
+
process.emitWarning("Passing GuildMember for DisTube#Playlist() is deprecated, read the docs for more.", "DeprecationWarning");
|
|
15
|
+
return new Playlist(playlist, { member: options, properties: props, metadata: meta });
|
|
16
|
+
}
|
|
17
|
+
const { member, properties, metadata } = Object.assign({ properties: {} }, options);
|
|
18
18
|
if (typeof playlist !== "object") {
|
|
19
19
|
throw new __1.DisTubeError("INVALID_TYPE", ["Array<Song>", "object"], playlist, "playlist");
|
|
20
20
|
}
|
|
@@ -56,18 +56,23 @@ class Playlist {
|
|
|
56
56
|
* Playlist thumbnail.
|
|
57
57
|
* @type {?string}
|
|
58
58
|
*/
|
|
59
|
-
this.thumbnail =
|
|
59
|
+
this.thumbnail = info.thumbnail?.url || info.thumbnail || this.songs[0].thumbnail;
|
|
60
60
|
for (const [key, value] of Object.entries(properties)) {
|
|
61
61
|
this[key] = value;
|
|
62
62
|
}
|
|
63
|
+
/**
|
|
64
|
+
* Optional metadata that can be used to identify the playlist.
|
|
65
|
+
* @type {T}
|
|
66
|
+
*/
|
|
67
|
+
this.metadata = metadata;
|
|
68
|
+
this._patchMetadata(metadata);
|
|
63
69
|
}
|
|
64
70
|
/**
|
|
65
71
|
* Playlist duration in second.
|
|
66
72
|
* @type {number}
|
|
67
73
|
*/
|
|
68
74
|
get duration() {
|
|
69
|
-
|
|
70
|
-
return ((_a = this.songs) === null || _a === void 0 ? void 0 : _a.reduce((prev, next) => prev + (next.duration || 0), 0)) || 0;
|
|
75
|
+
return this.songs?.reduce((prev, next) => prev + (next.duration || 0), 0) || 0;
|
|
71
76
|
}
|
|
72
77
|
/**
|
|
73
78
|
* Formatted duration string `hh:mm:ss`.
|
|
@@ -82,7 +87,6 @@ class Playlist {
|
|
|
82
87
|
* @returns {Playlist}
|
|
83
88
|
*/
|
|
84
89
|
_patchMember(member) {
|
|
85
|
-
var _a;
|
|
86
90
|
if (member) {
|
|
87
91
|
/**
|
|
88
92
|
* User requested.
|
|
@@ -93,12 +97,21 @@ class Playlist {
|
|
|
93
97
|
* User requested.
|
|
94
98
|
* @type {?Discord.User}
|
|
95
99
|
*/
|
|
96
|
-
this.user =
|
|
100
|
+
this.user = this.member?.user;
|
|
97
101
|
}
|
|
98
102
|
this.songs.map(s => s.constructor.name === "Song" && s._patchPlaylist(this, this.member));
|
|
99
103
|
return this;
|
|
100
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* @param {*} metadata Metadata
|
|
107
|
+
* @private
|
|
108
|
+
* @returns {Playlist}
|
|
109
|
+
*/
|
|
110
|
+
_patchMetadata(metadata) {
|
|
111
|
+
this.metadata = metadata;
|
|
112
|
+
this.songs.map(s => s.constructor.name === "Song" && s._patchMetadata(metadata));
|
|
113
|
+
return this;
|
|
114
|
+
}
|
|
101
115
|
}
|
|
102
116
|
exports.Playlist = Playlist;
|
|
103
|
-
exports.default = Playlist;
|
|
104
117
|
//# sourceMappingURL=Playlist.js.map
|