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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Playlist.js","sourceRoot":"","sources":["../../src/struct/Playlist.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"Playlist.js","sourceRoot":"","sources":["../../src/struct/Playlist.ts"],"names":[],"mappings":";;;;;;;;;;;;;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BAAgB,EAAC,MAAM,CAAC;YAAE,OAAO;QACtC,uBAAA,IAAI,oBAAW,MAAM,MAAA,CAAC;QACtB,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACjF,CAAC;IAMD,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;IAC3B,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,uBAAA,IAAI,0BAAU,CAAC;IACxB,CAAC;IAED,IAAI,QAAQ,CAAC,QAAW;QACtB,uBAAA,IAAI,sBAAa,QAAQ,MAAA,CAAC;QAC1B,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,MAAM,IAAI,CAAC,CAAC,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC;IAChF,CAAC;CACF;AA7HD,4BA6HC","sourcesContent":["import { DisTubeError, formatDuration, isMemberInstance, isRecord } from \"..\";\nimport type ytpl from \"@distube/ytpl\";\nimport type { PlaylistInfo, Song } from \"..\";\nimport type { GuildMember } from \"discord.js\";\n\n/**\n * Class representing a playlist.\n * @prop {string} source Playlist source\n * @template T - The type for the metadata (if any) of the playlist\n */\nexport class Playlist<T = unknown> implements PlaylistInfo {\n source!: string;\n songs!: Song[];\n name!: string;\n #metadata!: T;\n #member?: GuildMember;\n url?: string;\n thumbnail?: string;\n [x: string]: any;\n /**\n * Create a playlist\n * @param {Song[]|PlaylistInfo} playlist Playlist\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {Object} [options.properties] Custom properties\n * @param {T} [options.metadata] Playlist metadata\n */\n constructor(\n playlist: Song[] | ytpl.result | PlaylistInfo,\n options: {\n member?: GuildMember;\n properties?: Record<string, any>;\n metadata?: T;\n } = {},\n ) {\n const { member, properties, metadata } = options;\n\n if (typeof playlist !== \"object\") {\n throw new DisTubeError(\"INVALID_TYPE\", [\"Array<Song>\", \"object\"], playlist, \"playlist\");\n }\n if (typeof properties !== \"undefined\" && !isRecord(properties)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"object\", properties, \"properties\");\n }\n // FIXME\n const info = playlist as any;\n /**\n * The source of the playlist\n * @type {string}\n */\n this.source = (info.source || properties?.source || \"youtube\").toLowerCase();\n /**\n * Playlist songs.\n * @type {Array<Song>}\n */\n this.songs = Array.isArray(info) ? info : info.items || info.songs;\n if (!Array.isArray(this.songs) || !this.songs.length) {\n throw new DisTubeError(\"EMPTY_PLAYLIST\");\n }\n this.songs.map(s => s.constructor.name === \"Song\" && (s.playlist = this));\n this.member = member || info.member || undefined;\n /**\n * Playlist name.\n * @type {string}\n */\n this.name =\n info.name ||\n info.title ||\n (this.songs[0].name\n ? `${this.songs[0].name} and ${this.songs.length - 1} more songs.`\n : `${this.songs.length} songs playlist`);\n /**\n * Playlist URL.\n * @type {string}\n */\n this.url = info.url || info.webpage_url;\n /**\n * Playlist thumbnail.\n * @type {string?}\n */\n this.thumbnail = info.thumbnail?.url || info.thumbnail || this.songs[0].thumbnail;\n if (properties) for (const [key, value] of Object.entries(properties)) this[key] = value;\n\n /**\n * Optional metadata that can be used to identify the playlist.\n * @type {T}\n */\n this.metadata = metadata as T;\n }\n\n /**\n * Playlist duration in second.\n * @type {number}\n */\n get duration() {\n return this.songs?.reduce((prev, next) => prev + (next.duration || 0), 0) || 0;\n }\n\n /**\n * Formatted duration string `hh:mm:ss`.\n * @type {string}\n */\n get formattedDuration() {\n return formatDuration(this.duration);\n }\n\n /**\n * User requested.\n * @type {Discord.GuildMember?}\n */\n get member() {\n return this.#member;\n }\n\n set member(member: GuildMember | undefined) {\n if (!isMemberInstance(member)) return;\n this.#member = member;\n this.songs.map(s => s.constructor.name === \"Song\" && (s.member = this.member));\n }\n\n /**\n * User requested.\n * @type {Discord.User?}\n */\n get user() {\n return this.member?.user;\n }\n\n get metadata() {\n return this.#metadata;\n }\n\n set metadata(metadata: T) {\n this.#metadata = metadata;\n this.songs.map(s => s.constructor.name === \"Song\" && (s.metadata = metadata));\n }\n}\n"]}
|
package/dist/struct/Plugin.d.ts
CHANGED
|
@@ -1,75 +1,17 @@
|
|
|
1
1
|
import type { Client, GuildTextBasedChannel } from "discord.js";
|
|
2
2
|
import type { Awaitable, DisTube, DisTubeEvents, DisTubeHandler, DisTubeVoiceManager, Options, PluginType, QueueManager, RelatedSong } from "..";
|
|
3
|
-
/**
|
|
4
|
-
* DisTube Plugin
|
|
5
|
-
* @abstract
|
|
6
|
-
* @private
|
|
7
|
-
*/
|
|
8
3
|
export declare abstract class Plugin {
|
|
9
4
|
type: PluginType;
|
|
10
5
|
distube: DisTube;
|
|
11
6
|
init(distube: DisTube): void;
|
|
12
|
-
/**
|
|
13
|
-
* Type of the plugin
|
|
14
|
-
* @name Plugin#type
|
|
15
|
-
* @type {PluginType}
|
|
16
|
-
*/
|
|
17
|
-
/**
|
|
18
|
-
* Emit the {@link DisTube} of this base
|
|
19
|
-
* @param {string} eventName Event name
|
|
20
|
-
* @param {...any} args arguments
|
|
21
|
-
* @returns {boolean}
|
|
22
|
-
*/
|
|
23
7
|
emit(eventName: keyof DisTubeEvents, ...args: any): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Emit error event
|
|
26
|
-
* @param {Error} error error
|
|
27
|
-
* @param {Discord.BaseGuildTextChannel} [channel] Text channel where the error is encountered.
|
|
28
|
-
*/
|
|
29
8
|
emitError(error: Error, channel?: GuildTextBasedChannel): void;
|
|
30
|
-
/**
|
|
31
|
-
* The queue manager
|
|
32
|
-
* @type {QueueManager}
|
|
33
|
-
* @readonly
|
|
34
|
-
*/
|
|
35
9
|
get queues(): QueueManager;
|
|
36
|
-
/**
|
|
37
|
-
* The voice manager
|
|
38
|
-
* @type {DisTubeVoiceManager}
|
|
39
|
-
* @readonly
|
|
40
|
-
*/
|
|
41
10
|
get voices(): DisTubeVoiceManager;
|
|
42
|
-
/**
|
|
43
|
-
* Discord.js client
|
|
44
|
-
* @type {Discord.Client}
|
|
45
|
-
* @readonly
|
|
46
|
-
*/
|
|
47
11
|
get client(): Client;
|
|
48
|
-
/**
|
|
49
|
-
* DisTube options
|
|
50
|
-
* @type {DisTubeOptions}
|
|
51
|
-
* @readonly
|
|
52
|
-
*/
|
|
53
12
|
get options(): Options;
|
|
54
|
-
/**
|
|
55
|
-
* DisTube handler
|
|
56
|
-
* @type {DisTubeHandler}
|
|
57
|
-
* @readonly
|
|
58
|
-
*/
|
|
59
13
|
get handler(): DisTubeHandler;
|
|
60
|
-
/**
|
|
61
|
-
* Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
|
|
62
|
-
* Not needed if the plugin plays song from YouTube.
|
|
63
|
-
* @param {string} url Input url
|
|
64
|
-
* @returns {string|Promise<string>}
|
|
65
|
-
*/
|
|
66
14
|
getStreamURL(url: string): Awaitable<string>;
|
|
67
|
-
/**
|
|
68
|
-
* Get related songs from a supported url. {@link Song#member} should be `undefined`.
|
|
69
|
-
* Not needed to add {@link Song#related} because it will be added with this function later.
|
|
70
|
-
* @param {string} url Input url
|
|
71
|
-
* @returns {Song[]|Promise<Song[]>}
|
|
72
|
-
*/
|
|
73
15
|
getRelatedSongs(url: string): Awaitable<RelatedSong[]>;
|
|
74
16
|
}
|
|
75
17
|
//# sourceMappingURL=Plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/struct/Plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,OAAO,EACP,UAAU,EACV,YAAY,EACZ,WAAW,EACZ,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"Plugin.d.ts","sourceRoot":"","sources":["../../src/struct/Plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,KAAK,EACV,SAAS,EACT,OAAO,EACP,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,OAAO,EACP,UAAU,EACV,YAAY,EACZ,WAAW,EACZ,MAAM,IAAI,CAAC;AAOZ,8BAAsB,MAAM;IAC1B,IAAI,EAAG,UAAU,CAAC;IAClB,OAAO,EAAG,OAAO,CAAC;IAClB,IAAI,CAAC,OAAO,EAAE,OAAO;IAkBrB,IAAI,CAAC,SAAS,EAAE,MAAM,aAAa,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,OAAO;IAQ3D,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAQvD,IAAI,MAAM,IAAI,YAAY,CAEzB;IAMD,IAAI,MAAM,IAAI,mBAAmB,CAEhC;IAMD,IAAI,MAAM,IAAI,MAAM,CAEnB;IAMD,IAAI,OAAO,IAAI,OAAO,CAErB;IAMD,IAAI,OAAO,IAAI,cAAc,CAE5B;IAOD,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAS5C,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;CAGvD"}
|
package/dist/struct/Plugin.js
CHANGED
|
@@ -1,96 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Plugin = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* DisTube Plugin
|
|
6
|
-
* @abstract
|
|
7
|
-
* @private
|
|
8
|
-
*/
|
|
9
4
|
class Plugin {
|
|
10
5
|
init(distube) {
|
|
11
|
-
/**
|
|
12
|
-
* DisTube
|
|
13
|
-
* @type {DisTube}
|
|
14
|
-
*/
|
|
15
6
|
this.distube = distube;
|
|
16
7
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Type of the plugin
|
|
19
|
-
* @name Plugin#type
|
|
20
|
-
* @type {PluginType}
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* Emit the {@link DisTube} of this base
|
|
24
|
-
* @param {string} eventName Event name
|
|
25
|
-
* @param {...any} args arguments
|
|
26
|
-
* @returns {boolean}
|
|
27
|
-
*/
|
|
28
8
|
emit(eventName, ...args) {
|
|
29
9
|
return this.distube.emit(eventName, ...args);
|
|
30
10
|
}
|
|
31
|
-
/**
|
|
32
|
-
* Emit error event
|
|
33
|
-
* @param {Error} error error
|
|
34
|
-
* @param {Discord.BaseGuildTextChannel} [channel] Text channel where the error is encountered.
|
|
35
|
-
*/
|
|
36
11
|
emitError(error, channel) {
|
|
37
12
|
this.distube.emitError(error, channel);
|
|
38
13
|
}
|
|
39
|
-
/**
|
|
40
|
-
* The queue manager
|
|
41
|
-
* @type {QueueManager}
|
|
42
|
-
* @readonly
|
|
43
|
-
*/
|
|
44
14
|
get queues() {
|
|
45
15
|
return this.distube.queues;
|
|
46
16
|
}
|
|
47
|
-
/**
|
|
48
|
-
* The voice manager
|
|
49
|
-
* @type {DisTubeVoiceManager}
|
|
50
|
-
* @readonly
|
|
51
|
-
*/
|
|
52
17
|
get voices() {
|
|
53
18
|
return this.distube.voices;
|
|
54
19
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Discord.js client
|
|
57
|
-
* @type {Discord.Client}
|
|
58
|
-
* @readonly
|
|
59
|
-
*/
|
|
60
20
|
get client() {
|
|
61
21
|
return this.distube.client;
|
|
62
22
|
}
|
|
63
|
-
/**
|
|
64
|
-
* DisTube options
|
|
65
|
-
* @type {DisTubeOptions}
|
|
66
|
-
* @readonly
|
|
67
|
-
*/
|
|
68
23
|
get options() {
|
|
69
24
|
return this.distube.options;
|
|
70
25
|
}
|
|
71
|
-
/**
|
|
72
|
-
* DisTube handler
|
|
73
|
-
* @type {DisTubeHandler}
|
|
74
|
-
* @readonly
|
|
75
|
-
*/
|
|
76
26
|
get handler() {
|
|
77
27
|
return this.distube.handler;
|
|
78
28
|
}
|
|
79
|
-
/**
|
|
80
|
-
* Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.
|
|
81
|
-
* Not needed if the plugin plays song from YouTube.
|
|
82
|
-
* @param {string} url Input url
|
|
83
|
-
* @returns {string|Promise<string>}
|
|
84
|
-
*/
|
|
85
29
|
getStreamURL(url) {
|
|
86
30
|
return url;
|
|
87
31
|
}
|
|
88
|
-
/**
|
|
89
|
-
* Get related songs from a supported url. {@link Song#member} should be `undefined`.
|
|
90
|
-
* Not needed to add {@link Song#related} because it will be added with this function later.
|
|
91
|
-
* @param {string} url Input url
|
|
92
|
-
* @returns {Song[]|Promise<Song[]>}
|
|
93
|
-
*/
|
|
94
32
|
getRelatedSongs(url) {
|
|
95
33
|
return [];
|
|
96
34
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../src/struct/Plugin.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../src/struct/Plugin.ts"],"names":[],"mappings":";;;AAmBA,MAAsB,MAAM;IAG1B,IAAI,CAAC,OAAgB;QAKnB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAYD,IAAI,CAAC,SAA8B,EAAE,GAAG,IAAS;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC;IAMD,SAAS,CAAC,KAAY,EAAE,OAA+B;QACrD,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IAMD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAMD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAMD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAMD,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,CAAC;IAMD,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,CAAC;IAOD,YAAY,CAAC,GAAW;QACtB,OAAO,GAAG,CAAC;IACb,CAAC;IAOD,eAAe,CAAC,GAAW;QACzB,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AA1FD,wBA0FC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\nimport type { Client, GuildTextBasedChannel } from \"discord.js\";\nimport type {\n Awaitable,\n DisTube,\n DisTubeEvents,\n DisTubeHandler,\n DisTubeVoiceManager,\n Options,\n PluginType,\n QueueManager,\n RelatedSong,\n} from \"..\";\n\n/**\n * DisTube Plugin\n * @abstract\n * @private\n */\nexport abstract class Plugin {\n type!: PluginType;\n distube!: DisTube;\n init(distube: DisTube) {\n /**\n * DisTube\n * @type {DisTube}\n */\n this.distube = distube;\n }\n /**\n * Type of the plugin\n * @name Plugin#type\n * @type {PluginType}\n */\n /**\n * Emit the {@link DisTube} of this base\n * @param {string} eventName Event name\n * @param {...any} args arguments\n * @returns {boolean}\n */\n emit(eventName: keyof DisTubeEvents, ...args: any): boolean {\n return this.distube.emit(eventName, ...args);\n }\n /**\n * Emit error event\n * @param {Error} error error\n * @param {Discord.BaseGuildTextChannel} [channel] Text channel where the error is encountered.\n */\n emitError(error: Error, channel?: GuildTextBasedChannel) {\n this.distube.emitError(error, channel);\n }\n /**\n * The queue manager\n * @type {QueueManager}\n * @readonly\n */\n get queues(): QueueManager {\n return this.distube.queues;\n }\n /**\n * The voice manager\n * @type {DisTubeVoiceManager}\n * @readonly\n */\n get voices(): DisTubeVoiceManager {\n return this.distube.voices;\n }\n /**\n * Discord.js client\n * @type {Discord.Client}\n * @readonly\n */\n get client(): Client {\n return this.distube.client;\n }\n /**\n * DisTube options\n * @type {DisTubeOptions}\n * @readonly\n */\n get options(): Options {\n return this.distube.options;\n }\n /**\n * DisTube handler\n * @type {DisTubeHandler}\n * @readonly\n */\n get handler(): DisTubeHandler {\n return this.distube.handler;\n }\n /**\n * Get the stream url from {@link Song#url}. Returns {@link Song#url} by default.\n * Not needed if the plugin plays song from YouTube.\n * @param {string} url Input url\n * @returns {string|Promise<string>}\n */\n getStreamURL(url: string): Awaitable<string> {\n return url;\n }\n /**\n * Get related songs from a supported url. {@link Song#member} should be `undefined`.\n * Not needed to add {@link Song#related} because it will be added with this function later.\n * @param {string} url Input url\n * @returns {Song[]|Promise<Song[]>}\n */\n getRelatedSongs(url: string): Awaitable<RelatedSong[]> {\n return [];\n }\n}\n"]}
|
package/dist/struct/Queue.d.ts
CHANGED
|
@@ -1,216 +1,49 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { DisTubeBase } from "../core";
|
|
2
|
+
import { DisTubeBase, FilterManager } from "../core";
|
|
3
3
|
import { RepeatMode, Song, TaskQueue } from "..";
|
|
4
4
|
import type { DisTube, DisTubeVoice, DisTubeVoiceEvents } from "..";
|
|
5
5
|
import type { GuildMember, GuildTextBasedChannel, Snowflake } from "discord.js";
|
|
6
|
-
/**
|
|
7
|
-
* Represents a queue.
|
|
8
|
-
* @extends DisTubeBase
|
|
9
|
-
*/
|
|
10
6
|
export declare class Queue extends DisTubeBase {
|
|
7
|
+
#private;
|
|
11
8
|
readonly id: Snowflake;
|
|
12
|
-
/**
|
|
13
|
-
* Voice connection of this queue
|
|
14
|
-
*/
|
|
15
9
|
voice: DisTubeVoice;
|
|
16
|
-
/**
|
|
17
|
-
* List of songs in the queue (The first one is the playing song)
|
|
18
|
-
*/
|
|
19
10
|
songs: Song[];
|
|
20
|
-
/**
|
|
21
|
-
* List of the previous songs.
|
|
22
|
-
*/
|
|
23
11
|
previousSongs: Song[];
|
|
24
|
-
/**
|
|
25
|
-
* Whether stream is currently stopped.
|
|
26
|
-
* @private
|
|
27
|
-
*/
|
|
28
12
|
stopped: boolean;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
* @private
|
|
32
|
-
*/
|
|
33
|
-
next: boolean;
|
|
34
|
-
/**
|
|
35
|
-
* Whether or not the last song was skipped to previous song.
|
|
36
|
-
* @private
|
|
37
|
-
*/
|
|
38
|
-
prev: boolean;
|
|
39
|
-
/**
|
|
40
|
-
* Whether or not the stream is currently playing.
|
|
41
|
-
*/
|
|
13
|
+
_next: boolean;
|
|
14
|
+
_prev: boolean;
|
|
42
15
|
playing: boolean;
|
|
43
|
-
/**
|
|
44
|
-
* Whether or not the stream is currently paused.
|
|
45
|
-
*/
|
|
46
16
|
paused: boolean;
|
|
47
|
-
/**
|
|
48
|
-
* Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).
|
|
49
|
-
* Default value: `0` (disabled)
|
|
50
|
-
*/
|
|
51
17
|
repeatMode: RepeatMode;
|
|
52
|
-
/**
|
|
53
|
-
* Whether or not the autoplay mode is enabled.
|
|
54
|
-
* Default value: `false`
|
|
55
|
-
*/
|
|
56
18
|
autoplay: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* Enabled audio filters.
|
|
59
|
-
* Available filters: {@link Filters}
|
|
60
|
-
*/
|
|
61
|
-
filters: string[];
|
|
62
|
-
/**
|
|
63
|
-
* What time in the song to begin (in seconds).
|
|
64
|
-
*/
|
|
65
19
|
beginTime: number;
|
|
66
|
-
/**
|
|
67
|
-
* The text channel of the Queue. (Default: where the first command is called).
|
|
68
|
-
*/
|
|
69
20
|
textChannel?: GuildTextBasedChannel;
|
|
70
|
-
|
|
71
|
-
* Timeout for checking empty channel
|
|
72
|
-
* @private
|
|
73
|
-
*/
|
|
74
|
-
emptyTimeout?: NodeJS.Timeout;
|
|
75
|
-
/**
|
|
76
|
-
* The client user as a `GuildMember` of this queue's guild
|
|
77
|
-
*/
|
|
21
|
+
_emptyTimeout?: NodeJS.Timeout;
|
|
78
22
|
clientMember: GuildMember;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*/
|
|
82
|
-
taskQueue: TaskQueue;
|
|
83
|
-
listeners?: DisTubeVoiceEvents;
|
|
84
|
-
/**
|
|
85
|
-
* Create a queue for the guild
|
|
86
|
-
* @param {DisTube} distube DisTube
|
|
87
|
-
* @param {DisTubeVoice} voice Voice connection
|
|
88
|
-
* @param {Song|Song[]} song First song(s)
|
|
89
|
-
* @param {Discord.BaseGuildTextChannel?} textChannel Default text channel
|
|
90
|
-
*/
|
|
23
|
+
_taskQueue: TaskQueue;
|
|
24
|
+
_listeners?: DisTubeVoiceEvents;
|
|
91
25
|
constructor(distube: DisTube, voice: DisTubeVoice, song: Song | Song[], textChannel?: GuildTextBasedChannel);
|
|
92
|
-
|
|
93
|
-
* Formatted duration string.
|
|
94
|
-
* @type {string}
|
|
95
|
-
*/
|
|
26
|
+
get filters(): FilterManager;
|
|
96
27
|
get formattedDuration(): string;
|
|
97
|
-
/**
|
|
98
|
-
* Queue's duration.
|
|
99
|
-
* @type {number}
|
|
100
|
-
*/
|
|
101
28
|
get duration(): number;
|
|
102
|
-
/**
|
|
103
|
-
* What time in the song is playing (in seconds).
|
|
104
|
-
* @type {number}
|
|
105
|
-
*/
|
|
106
29
|
get currentTime(): number;
|
|
107
|
-
/**
|
|
108
|
-
* Formatted {@link Queue#currentTime} string.
|
|
109
|
-
* @type {string}
|
|
110
|
-
*/
|
|
111
30
|
get formattedCurrentTime(): string;
|
|
112
|
-
/**
|
|
113
|
-
* The voice channel playing in.
|
|
114
|
-
* @type {Discord.VoiceChannel|Discord.StageChannel|null}
|
|
115
|
-
*/
|
|
116
31
|
get voiceChannel(): import("discord.js").VoiceBasedChannel | null;
|
|
117
32
|
get volume(): number;
|
|
118
33
|
set volume(value: number);
|
|
119
|
-
/**
|
|
120
|
-
* @private
|
|
121
|
-
* Add a Song or an array of Song to the queue
|
|
122
|
-
* @param {Song|Song[]} song Song to add
|
|
123
|
-
* @param {number} [position=0] Position to add, <= 0 to add to the end of the queue
|
|
124
|
-
* @throws {Error}
|
|
125
|
-
* @returns {Queue} The guild queue
|
|
126
|
-
*/
|
|
127
34
|
addToQueue(song: Song | Song[], position?: number): Queue;
|
|
128
|
-
/**
|
|
129
|
-
* Pause the guild stream
|
|
130
|
-
* @returns {Queue} The guild queue
|
|
131
|
-
*/
|
|
132
35
|
pause(): Queue;
|
|
133
|
-
/**
|
|
134
|
-
* Resume the guild stream
|
|
135
|
-
* @returns {Queue} The guild queue
|
|
136
|
-
*/
|
|
137
36
|
resume(): Queue;
|
|
138
|
-
/**
|
|
139
|
-
* Set the guild stream's volume
|
|
140
|
-
* @param {number} percent The percentage of volume you want to set
|
|
141
|
-
* @returns {Queue} The guild queue
|
|
142
|
-
*/
|
|
143
37
|
setVolume(percent: number): Queue;
|
|
144
|
-
/**
|
|
145
|
-
* Skip the playing song if there is a next song in the queue.
|
|
146
|
-
* <info>If {@link Queue#autoplay} is `true` and there is no up next song,
|
|
147
|
-
* DisTube will add and play a related song.</info>
|
|
148
|
-
* @returns {Promise<Song>} The song will skip to
|
|
149
|
-
* @throws {Error}
|
|
150
|
-
*/
|
|
151
38
|
skip(): Promise<Song>;
|
|
152
|
-
/**
|
|
153
|
-
* Play the previous song if exists
|
|
154
|
-
* @returns {Song} The guild queue
|
|
155
|
-
* @throws {Error}
|
|
156
|
-
*/
|
|
157
39
|
previous(): Promise<Song>;
|
|
158
|
-
/**
|
|
159
|
-
* Shuffle the queue's songs
|
|
160
|
-
* @returns {Promise<Queue>} The guild queue
|
|
161
|
-
*/
|
|
162
40
|
shuffle(): Promise<Queue>;
|
|
163
|
-
|
|
164
|
-
* Jump to the song position in the queue.
|
|
165
|
-
* The next one is 1, 2,...
|
|
166
|
-
* The previous one is -1, -2,...
|
|
167
|
-
* @param {number} position The song position to play
|
|
168
|
-
* @returns {Promise<Queue>} The guild queue
|
|
169
|
-
* @throws {Error} if `num` is invalid number
|
|
170
|
-
*/
|
|
171
|
-
jump(position: number): Promise<Queue>;
|
|
172
|
-
/**
|
|
173
|
-
* Set the repeat mode of the guild queue.\
|
|
174
|
-
* Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`
|
|
175
|
-
* @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)
|
|
176
|
-
* @returns {RepeatMode} The new repeat mode
|
|
177
|
-
*/
|
|
41
|
+
jump(position: number): Promise<Song>;
|
|
178
42
|
setRepeatMode(mode?: RepeatMode): RepeatMode;
|
|
179
|
-
/**
|
|
180
|
-
* Enable or disable filter(s) of the queue.
|
|
181
|
-
* Available filters: {@link Filters}
|
|
182
|
-
* @param {string|string[]|false} filter A filter name, an array of filter name or `false` to clear all the filters
|
|
183
|
-
* @param {boolean} [force=false] Force enable the input filter(s) even if it's enabled
|
|
184
|
-
* @returns {Array<string>} Enabled filters.
|
|
185
|
-
* @throws {Error}
|
|
186
|
-
*/
|
|
187
|
-
setFilter(filter: string | string[] | false, force?: boolean): Array<string>;
|
|
188
|
-
/**
|
|
189
|
-
* Set the playing time to another position
|
|
190
|
-
* @param {number} time Time in seconds
|
|
191
|
-
* @returns {Queue} The guild queue
|
|
192
|
-
*/
|
|
193
43
|
seek(time: number): Queue;
|
|
194
|
-
/**
|
|
195
|
-
* Add a related song of the playing song to the queue
|
|
196
|
-
* @returns {Promise<Song>} The added song
|
|
197
|
-
* @throws {Error}
|
|
198
|
-
*/
|
|
199
44
|
addRelatedSong(): Promise<Song>;
|
|
200
|
-
/**
|
|
201
|
-
* Stop the guild stream and delete the queue
|
|
202
|
-
*/
|
|
203
45
|
stop(): Promise<void>;
|
|
204
|
-
|
|
205
|
-
* Delete the queue from the manager
|
|
206
|
-
* (This does not leave the voice channel even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)
|
|
207
|
-
* @private
|
|
208
|
-
*/
|
|
209
|
-
delete(): void;
|
|
210
|
-
/**
|
|
211
|
-
* Toggle autoplay mode
|
|
212
|
-
* @returns {boolean} Autoplay mode state
|
|
213
|
-
*/
|
|
46
|
+
remove(): void;
|
|
214
47
|
toggleAutoplay(): boolean;
|
|
215
48
|
}
|
|
216
49
|
//# sourceMappingURL=Queue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../src/struct/Queue.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../src/struct/Queue.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,EAAgB,UAAU,EAAE,IAAI,EAAE,SAAS,EAAkB,MAAM,IAAI,CAAC;AAC/E,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAMhF,qBAAa,KAAM,SAAQ,WAAW;;IACpC,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB,KAAK,EAAE,YAAY,CAAC;IACpB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,aAAa,EAAE,IAAI,EAAE,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,OAAO,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,CAA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