distube 3.2.1 → 3.3.1-1
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 +31 -23
- package/dist/DisTube.d.ts.map +1 -1
- package/dist/DisTube.js +56 -28
- package/dist/DisTube.js.map +1 -1
- package/dist/constant.d.ts +2 -3
- package/dist/constant.d.ts.map +1 -1
- package/dist/constant.js +2 -3
- package/dist/constant.js.map +1 -1
- package/dist/core/DisTubeHandler.d.ts +10 -3
- package/dist/core/DisTubeHandler.d.ts.map +1 -1
- package/dist/core/DisTubeHandler.js +22 -23
- package/dist/core/DisTubeHandler.js.map +1 -1
- package/dist/core/DisTubeOptions.d.ts +1 -1
- package/dist/core/DisTubeOptions.d.ts.map +1 -1
- package/dist/core/DisTubeOptions.js +8 -4
- 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.map +1 -1
- package/dist/core/manager/QueueManager.d.ts.map +1 -1
- package/dist/core/manager/QueueManager.js +4 -1
- package/dist/core/manager/QueueManager.js.map +1 -1
- package/dist/struct/CustomPlugin.d.ts +34 -30
- package/dist/struct/CustomPlugin.d.ts.map +1 -1
- package/dist/struct/CustomPlugin.js +32 -16
- package/dist/struct/CustomPlugin.js.map +1 -1
- package/dist/struct/DisTubeError.d.ts +1 -2
- package/dist/struct/DisTubeError.d.ts.map +1 -1
- package/dist/struct/DisTubeError.js +1 -2
- package/dist/struct/DisTubeError.js.map +1 -1
- package/dist/struct/ExtractorPlugin.d.ts +21 -15
- package/dist/struct/ExtractorPlugin.d.ts.map +1 -1
- package/dist/struct/ExtractorPlugin.js +21 -12
- package/dist/struct/ExtractorPlugin.js.map +1 -1
- package/dist/struct/Playlist.d.ts +15 -12
- package/dist/struct/Playlist.d.ts.map +1 -1
- package/dist/struct/Playlist.js +50 -39
- package/dist/struct/Playlist.js.map +1 -1
- package/dist/struct/Plugin.d.ts +9 -8
- package/dist/struct/Plugin.d.ts.map +1 -1
- package/dist/struct/Plugin.js +10 -9
- package/dist/struct/Plugin.js.map +1 -1
- package/dist/struct/Queue.d.ts +6 -6
- package/dist/struct/Queue.d.ts.map +1 -1
- package/dist/struct/Queue.js +23 -21
- package/dist/struct/Queue.js.map +1 -1
- package/dist/struct/Song.d.ts +18 -21
- package/dist/struct/Song.d.ts.map +1 -1
- package/dist/struct/Song.js +74 -58
- package/dist/struct/Song.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/type.d.ts +18 -4
- package/dist/type.d.ts.map +1 -1
- package/dist/type.js.map +1 -1
- package/dist/util.d.ts +2 -0
- package/dist/util.d.ts.map +1 -1
- package/dist/util.js +11 -4
- package/dist/util.js.map +1 -1
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Playlist.js","sourceRoot":"","sources":["../../src/struct/Playlist.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Playlist.js","sourceRoot":"","sources":["../../src/struct/Playlist.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,0BAA8E;AAK9E,2CAA2C;AAE3C;;;;GAIG;AACH,MAAa,QAAQ;IAiCnB,YACE,QAA6C,EAC7C,UAMQ,EAAE,EACV,KAA2B,EAC3B,IAAQ;QAvCV,qCAAc;QACd,mCAAsB;QAwCpB,IAAI,IAAA,oBAAgB,EAAC,OAAO,CAAC,EAAE;YAC7B,OAAO,CAAC,WAAW,CACjB,mFAAmF,EACnF,oBAAoB,CACrB,CAAC;YACF,OAAO,IAAI,QAAQ,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;SACvF;QAED,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAEjD,IAAI,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AAC,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;IAED;;;OAGG;IACH,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,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;AAzJD,4BAyJC","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// TODO: Remove ! on the next major version\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 constructor(playlist: Song[] | ytpl.result | PlaylistInfo);\n /** @deprecated Passing GuildMember for DisTube#Playlist() is deprecated. */\n constructor(\n playlist: Song[] | ytpl.result | PlaylistInfo,\n member?: GuildMember,\n properties?: Record<string, any>,\n metadata?: T,\n );\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 constructor(\n playlist: Song[] | ytpl.result | PlaylistInfo,\n options:\n | GuildMember\n | {\n member?: GuildMember;\n properties?: Record<string, any>;\n metadata?: T;\n } = {},\n props?: Record<string, any>,\n meta?: T,\n ) {\n if (isMemberInstance(options)) {\n process.emitWarning(\n \"Passing GuildMember for DisTube#Playlist() is deprecated, read the docs for more.\",\n \"DeprecationWarning\",\n );\n return new Playlist(playlist, { member: options, properties: props, metadata: meta });\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 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 (!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 /**\n * Optional metadata that can be used to identify the playlist.\n * @type {T}\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,5 +1,5 @@
|
|
|
1
1
|
import type { Client, GuildTextBasedChannel } from "discord.js";
|
|
2
|
-
import type { DisTube, DisTubeEvents, DisTubeHandler, DisTubeVoiceManager, Options, PluginType, QueueManager } from "..";
|
|
2
|
+
import type { Awaitable, DisTube, DisTubeEvents, DisTubeHandler, DisTubeVoiceManager, Options, PluginType, QueueManager, RelatedSong } from "..";
|
|
3
3
|
/**
|
|
4
4
|
* DisTube Plugin
|
|
5
5
|
* @abstract
|
|
@@ -58,17 +58,18 @@ export declare abstract class Plugin {
|
|
|
58
58
|
*/
|
|
59
59
|
get handler(): DisTubeHandler;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
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.
|
|
62
63
|
* @param {string} url Input url
|
|
63
|
-
* @returns {Promise<
|
|
64
|
+
* @returns {string|Promise<string>}
|
|
64
65
|
*/
|
|
65
|
-
|
|
66
|
+
getStreamURL(url: string): Awaitable<string>;
|
|
66
67
|
/**
|
|
67
|
-
* Get
|
|
68
|
-
* Not needed
|
|
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.
|
|
69
70
|
* @param {string} url Input url
|
|
70
|
-
* @returns {Promise<
|
|
71
|
+
* @returns {Song[]|Promise<Song[]>}
|
|
71
72
|
*/
|
|
72
|
-
|
|
73
|
+
getRelatedSongs(url: string): Awaitable<RelatedSong[]>;
|
|
73
74
|
}
|
|
74
75
|
//# 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,OAAO,EACP,aAAa,EACb,cAAc,EACd,mBAAmB,EACnB,OAAO,EACP,UAAU,EACV,YAAY,
|
|
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;AAEZ;;;;GAIG;AACH,8BAAsB,MAAM;IAC1B,IAAI,EAAG,UAAU,CAAC;IAClB,OAAO,EAAG,OAAO,CAAC;IAClB,IAAI,CAAC,OAAO,EAAE,OAAO;IAOrB;;;;OAIG;IACH;;;;;OAKG;IACH,IAAI,CAAC,SAAS,EAAE,MAAM,aAAa,EAAE,GAAG,IAAI,EAAE,GAAG,GAAG,OAAO;IAG3D;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,qBAAqB;IAGvD;;;;OAIG;IACH,IAAI,MAAM,IAAI,YAAY,CAEzB;IACD;;;;OAIG;IACH,IAAI,MAAM,IAAI,mBAAmB,CAEhC;IACD;;;;OAIG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IACD;;;;OAIG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IACD;;;;OAIG;IACH,IAAI,OAAO,IAAI,cAAc,CAE5B;IACD;;;;;OAKG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,MAAM,CAAC;IAG5C;;;;;OAKG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,WAAW,EAAE,CAAC;CAGvD"}
|
package/dist/struct/Plugin.js
CHANGED
|
@@ -77,21 +77,22 @@ class Plugin {
|
|
|
77
77
|
return this.distube.handler;
|
|
78
78
|
}
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
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.
|
|
81
82
|
* @param {string} url Input url
|
|
82
|
-
* @returns {Promise<
|
|
83
|
+
* @returns {string|Promise<string>}
|
|
83
84
|
*/
|
|
84
|
-
|
|
85
|
-
return
|
|
85
|
+
getStreamURL(url) {
|
|
86
|
+
return url;
|
|
86
87
|
}
|
|
87
88
|
/**
|
|
88
|
-
* Get
|
|
89
|
-
* Not needed
|
|
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.
|
|
90
91
|
* @param {string} url Input url
|
|
91
|
-
* @returns {Promise<
|
|
92
|
+
* @returns {Song[]|Promise<Song[]>}
|
|
92
93
|
*/
|
|
93
|
-
|
|
94
|
-
return
|
|
94
|
+
getRelatedSongs(url) {
|
|
95
|
+
return [];
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
exports.Plugin = Plugin;
|
|
@@ -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":";;;AAcA;;;;GAIG;AACH,MAAsB,MAAM;IAG1B,IAAI,CAAC,OAAgB;QACnB;;;WAGG;QACH,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACD;;;;OAIG;IACH;;;;;OAKG;IACH,IAAI,CAAC,SAA8B,EAAE,GAAG,IAAS;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,IAAI,CAAC,CAAC;IAC/C,CAAC;IACD;;;;OAIG;IACH,SAAS,CAAC,KAAY,EAAE,OAA+B;QACrD,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IACD;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IACD;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IACD;;;;OAIG;IACH,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IACD;;;;OAIG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,CAAC;IACD;;;;OAIG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;IAC9B,CAAC;IACD;;;;;OAKG;IACH,YAAY,CAAC,GAAW;QACtB,OAAO,GAAG,CAAC;IACb,CAAC;IACD;;;;;OAKG;IACH,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,8 +1,8 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { DisTubeBase } from "../core";
|
|
3
3
|
import { RepeatMode, Song, TaskQueue } from "..";
|
|
4
|
+
import type { DisTube, DisTubeVoice, DisTubeVoiceEvents } from "..";
|
|
4
5
|
import type { GuildMember, GuildTextBasedChannel, Snowflake } from "discord.js";
|
|
5
|
-
import type { DisTube, DisTubeVoice, DisTubeVoiceEvents, SearchResult } from "..";
|
|
6
6
|
/**
|
|
7
7
|
* Represents a queue.
|
|
8
8
|
* @extends DisTubeBase
|
|
@@ -117,14 +117,14 @@ export declare class Queue extends DisTubeBase {
|
|
|
117
117
|
get volume(): number;
|
|
118
118
|
set volume(value: number);
|
|
119
119
|
/**
|
|
120
|
+
* @private
|
|
120
121
|
* Add a Song or an array of Song to the queue
|
|
121
122
|
* @param {Song|Song[]} song Song to add
|
|
122
|
-
* @param {number} [position
|
|
123
|
-
* @param {boolean} [queuing=true] Wether or not waiting for unfinished tasks
|
|
123
|
+
* @param {number} [position=0] Position to add, <= 0 to add to the end of the queue
|
|
124
124
|
* @throws {Error}
|
|
125
125
|
* @returns {Queue} The guild queue
|
|
126
126
|
*/
|
|
127
|
-
addToQueue(song: Song |
|
|
127
|
+
addToQueue(song: Song | Song[], position?: number): Queue;
|
|
128
128
|
/**
|
|
129
129
|
* Pause the guild stream
|
|
130
130
|
* @returns {Queue} The guild queue
|
|
@@ -198,12 +198,12 @@ export declare class Queue extends DisTubeBase {
|
|
|
198
198
|
*/
|
|
199
199
|
addRelatedSong(): Promise<Song>;
|
|
200
200
|
/**
|
|
201
|
-
* Stop the guild stream
|
|
201
|
+
* Stop the guild stream and delete the queue
|
|
202
202
|
*/
|
|
203
203
|
stop(): Promise<void>;
|
|
204
204
|
/**
|
|
205
205
|
* Delete the queue from the manager
|
|
206
|
-
* (This does not leave the
|
|
206
|
+
* (This does not leave the voice channel even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)
|
|
207
207
|
* @private
|
|
208
208
|
*/
|
|
209
209
|
delete(): void;
|
|
@@ -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;AACtC,OAAO,EAAgB,UAAU,EAAE,IAAI,EAAE,SAAS,EAAkB,MAAM,IAAI,CAAC;AAC/E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"Queue.d.ts","sourceRoot":"","sources":["../../src/struct/Queue.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,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;AAEhF;;;GAGG;AACH,qBAAa,KAAM,SAAQ,WAAW;IACpC,QAAQ,CAAC,EAAE,EAAE,SAAS,CAAC;IACvB;;OAEG;IACH,KAAK,EAAE,YAAY,CAAC;IACpB;;OAEG;IACH,KAAK,EAAE,IAAI,EAAE,CAAC;IACd;;OAEG;IACH,aAAa,EAAE,IAAI,EAAE,CAAC;IACtB;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;;OAGG;IACH,IAAI,EAAE,OAAO,CAAC;IACd;;OAEG;IACH,OAAO,EAAE,OAAO,CAAC;I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,CAAC;IAgB/B;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC;IAe/B;;;;;;;OAOG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;IA4B5C;;;;;OAKG;IACH,aAAa,CAAC,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU;IAS5C;;;;;;;OAOG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,KAAK,EAAE,KAAK,UAAQ,GAAG,KAAK,CAAC,MAAM,CAAC;IAwB1E;;;;OAIG;IACH,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK;IAOzB;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;IASrC;;OAEG;IACG,IAAI;IAWV;;;;OAIG;IACH,MAAM;IAYN;;;OAGG;IACH,cAAc,IAAI,OAAO;CAI1B"}
|
package/dist/struct/Queue.js
CHANGED
|
@@ -21,7 +21,11 @@ class Queue extends core_1.DisTubeBase {
|
|
|
21
21
|
* The client user as a `GuildMember` of this queue's guild
|
|
22
22
|
* @type {Discord.GuildMember}
|
|
23
23
|
*/
|
|
24
|
-
this.clientMember =
|
|
24
|
+
this.clientMember =
|
|
25
|
+
voice.channel.guild?.me ??
|
|
26
|
+
(() => {
|
|
27
|
+
throw new __1.DisTubeError("INVALID_TYPE", "GuildMember", null, "<VoiceChannel>.guild.me");
|
|
28
|
+
})();
|
|
25
29
|
/**
|
|
26
30
|
* Voice connection of this queue.
|
|
27
31
|
* @type {DisTubeVoice}
|
|
@@ -164,33 +168,33 @@ class Queue extends core_1.DisTubeBase {
|
|
|
164
168
|
this.voice.volume = value;
|
|
165
169
|
}
|
|
166
170
|
/**
|
|
171
|
+
* @private
|
|
167
172
|
* Add a Song or an array of Song to the queue
|
|
168
173
|
* @param {Song|Song[]} song Song to add
|
|
169
|
-
* @param {number} [position
|
|
170
|
-
* @param {boolean} [queuing=true] Wether or not waiting for unfinished tasks
|
|
174
|
+
* @param {number} [position=0] Position to add, <= 0 to add to the end of the queue
|
|
171
175
|
* @throws {Error}
|
|
172
176
|
* @returns {Queue} The guild queue
|
|
173
177
|
*/
|
|
174
|
-
addToQueue(song, position =
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
+
addToQueue(song, position = 0) {
|
|
179
|
+
if (!song || (Array.isArray(song) && !song.length)) {
|
|
180
|
+
throw new __1.DisTubeError("INVALID_TYPE", ["Song", "Array<Song>"], song, "song");
|
|
181
|
+
}
|
|
182
|
+
if (typeof position !== "number" || !Number.isInteger(position)) {
|
|
183
|
+
throw new __1.DisTubeError("INVALID_TYPE", "integer", position, "position");
|
|
178
184
|
}
|
|
179
|
-
if (position
|
|
180
|
-
|
|
181
|
-
if (position < 0) {
|
|
182
|
-
if (isArray)
|
|
185
|
+
if (position <= 0) {
|
|
186
|
+
if (Array.isArray(song))
|
|
183
187
|
this.songs.push(...song);
|
|
184
188
|
else
|
|
185
189
|
this.songs.push(song);
|
|
186
190
|
}
|
|
187
|
-
else if (isArray) {
|
|
191
|
+
else if (Array.isArray(song)) {
|
|
188
192
|
this.songs.splice(position, 0, ...song);
|
|
189
193
|
}
|
|
190
194
|
else {
|
|
191
195
|
this.songs.splice(position, 0, song);
|
|
192
196
|
}
|
|
193
|
-
if (isArray)
|
|
197
|
+
if (Array.isArray(song))
|
|
194
198
|
song.map(s => delete s.formats);
|
|
195
199
|
else
|
|
196
200
|
delete song.formats;
|
|
@@ -283,9 +287,9 @@ class Queue extends core_1.DisTubeBase {
|
|
|
283
287
|
async shuffle() {
|
|
284
288
|
await this.taskQueue.queuing();
|
|
285
289
|
try {
|
|
286
|
-
if (!this.songs.length)
|
|
287
|
-
return this;
|
|
288
290
|
const playing = this.songs.shift();
|
|
291
|
+
if (playing === undefined)
|
|
292
|
+
return this;
|
|
289
293
|
for (let i = this.songs.length - 1; i > 0; i--) {
|
|
290
294
|
const j = Math.floor(Math.random() * (i + 1));
|
|
291
295
|
[this.songs[i], this.songs[j]] = [this.songs[j], this.songs[i]];
|
|
@@ -319,9 +323,7 @@ class Queue extends core_1.DisTubeBase {
|
|
|
319
323
|
this.previousSongs.push(...this.songs);
|
|
320
324
|
}
|
|
321
325
|
else {
|
|
322
|
-
this.previousSongs.push(...this.songs.map(s => {
|
|
323
|
-
return { id: s.id };
|
|
324
|
-
}));
|
|
326
|
+
this.previousSongs.push(...this.songs.map(s => ({ id: s.id })));
|
|
325
327
|
}
|
|
326
328
|
this.songs = nextSongs;
|
|
327
329
|
this.next = true;
|
|
@@ -424,14 +426,14 @@ class Queue extends core_1.DisTubeBase {
|
|
|
424
426
|
const related = this.songs[0].related.find(v => !this.previousSongs.map(s => s.id).includes(v.id));
|
|
425
427
|
if (!related || !(related instanceof __1.Song))
|
|
426
428
|
throw new __1.DisTubeError("NO_RELATED");
|
|
427
|
-
const song = await this.handler.resolveSong(related
|
|
429
|
+
const song = await this.handler.resolveSong(related, { member: this.clientMember, metadata: related.metadata });
|
|
428
430
|
if (!(song instanceof __1.Song))
|
|
429
431
|
throw new __1.DisTubeError("CANNOT_PLAY_RELATED");
|
|
430
432
|
this.addToQueue(song);
|
|
431
433
|
return song;
|
|
432
434
|
}
|
|
433
435
|
/**
|
|
434
|
-
* Stop the guild stream
|
|
436
|
+
* Stop the guild stream and delete the queue
|
|
435
437
|
*/
|
|
436
438
|
async stop() {
|
|
437
439
|
await this.taskQueue.queuing();
|
|
@@ -449,7 +451,7 @@ class Queue extends core_1.DisTubeBase {
|
|
|
449
451
|
}
|
|
450
452
|
/**
|
|
451
453
|
* Delete the queue from the manager
|
|
452
|
-
* (This does not leave the
|
|
454
|
+
* (This does not leave the voice channel even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)
|
|
453
455
|
* @private
|
|
454
456
|
*/
|
|
455
457
|
delete() {
|
package/dist/struct/Queue.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Queue.js","sourceR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eBase } from \"../core\";\nimport { DisTubeError, RepeatMode, Song, TaskQueue, formatDuration } from \"..\";\nimport type { GuildMember, GuildTextBasedChannel, Snowflake } from \"discord.js\";\nimport type { DisTube, DisTubeVoice, DisTubeVoiceEvents, SearchResult } from \"..\";\n\n/**\n * Represents a queue.\n * @extends DisTubeBase\n */\nexport class Queue extends DisTubeBase {\n readonly id: Snowflake;\n /**\n * Voice connection of this queue\n */\n voice: DisTubeVoice;\n /**\n * List of songs in the queue (The first one is the playing song)\n */\n songs: Song[];\n /**\n * List of the previous songs.\n */\n previousSongs: Song[];\n /**\n * Whether stream is currently stopped.\n * @private\n */\n stopped: boolean;\n /**\n * Whether or not the last song was skipped to next song.\n * @private\n */\n next: boolean;\n /**\n * Whether or not the last song was skipped to previous song.\n * @private\n */\n prev: boolean;\n /**\n * Whether or not the stream is currently playing.\n */\n playing: boolean;\n /**\n * Whether or not the stream is currently paused.\n */\n paused: boolean;\n /**\n * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).\n * Default value: `0` (disabled)\n */\n repeatMode: RepeatMode;\n /**\n * Whether or not the autoplay mode is enabled.\n * Default value: `false`\n */\n autoplay: boolean;\n /**\n * Enabled audio filters.\n * Available filters: {@link Filters}\n */\n filters: string[];\n /**\n * What time in the song to begin (in seconds).\n */\n beginTime: number;\n /**\n * The text channel of the Queue. (Default: where the first command is called).\n */\n textChannel?: GuildTextBasedChannel;\n /**\n * Timeout for checking empty channel\n * @private\n */\n emptyTimeout?: NodeJS.Timeout;\n /**\n * The client user as a `GuildMember` of this queue's guild\n */\n clientMember: GuildMember;\n /**\n * Task queuing system\n */\n taskQueue: TaskQueue;\n listeners?: DisTubeVoiceEvents;\n /**\n * Create a queue for the guild\n * @param {DisTube} distube DisTube\n * @param {DisTubeVoice} voice Voice connection\n * @param {Song|Song[]} song First song(s)\n * @param {Discord.BaseGuildTextChannel?} textChannel Default text channel\n */\n constructor(distube: DisTube, voice: DisTubeVoice, song: Song | Song[], textChannel?: GuildTextBasedChannel) {\n super(distube);\n /**\n * The client user as a `GuildMember` of this queue's guild\n * @type {Discord.GuildMember}\n */\n this.clientMember = voice.channel.guild?.me as GuildMember;\n /**\n * Voice connection of this queue.\n * @type {DisTubeVoice}\n */\n this.voice = voice;\n /**\n * Queue id (Guild id)\n * @type {Discord.Snowflake}\n */\n this.id = voice.id;\n /**\n * Get or set the stream volume. Default value: `50`.\n * @type {number}\n */\n this.volume = 50;\n /**\n * List of songs in the queue (The first one is the playing song)\n * @type {Array<Song>}\n */\n this.songs = Array.isArray(song) ? [...song] : [song];\n /**\n * List of the previous songs.\n * @type {Array<Song>}\n */\n this.previousSongs = [];\n /**\n * Whether stream is currently stopped.\n * @type {boolean}\n * @private\n */\n this.stopped = false;\n /**\n * Whether or not the last song was skipped to next song.\n * @type {boolean}\n * @private\n */\n this.next = false;\n /**\n * Whether or not the last song was skipped to previous song.\n * @type {boolean}\n * @private\n */\n this.prev = false;\n /**\n * Whether or not the stream is currently playing.\n * @type {boolean}\n */\n this.playing = true;\n /**\n * Whether or not the stream is currently paused.\n * @type {boolean}\n */\n this.paused = false;\n /**\n * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).\n * Default value: `0` (disabled)\n * @type {RepeatMode}\n */\n this.repeatMode = RepeatMode.DISABLED;\n /**\n * Whether or not the autoplay mode is enabled.\n * Default value: `false`\n * @type {boolean}\n */\n this.autoplay = false;\n /**\n * Enabled audio filters.\n * Available filters: {@link Filters}\n * @type {Array<string>}\n */\n this.filters = [];\n /**\n * What time in the song to begin (in seconds).\n * @type {number}\n */\n this.beginTime = 0;\n /**\n * The text channel of the Queue. (Default: where the first command is called).\n * @type {Discord.TextChannel?}\n */\n this.textChannel = textChannel;\n /**\n * Timeout for checking empty channel\n * @type {*}\n * @private\n */\n this.emptyTimeout = undefined;\n /**\n * Task queuing system\n * @type {TaskQueue}\n * @private\n */\n this.taskQueue = new TaskQueue();\n /**\n * DisTubeVoice listener\n * @type {Object}\n * @private\n */\n this.listeners = undefined;\n }\n /**\n * Formatted duration string.\n * @type {string}\n */\n get formattedDuration() {\n return formatDuration(this.duration);\n }\n /**\n * Queue's duration.\n * @type {number}\n */\n get duration() {\n return this.songs.length ? this.songs.reduce((prev, next) => prev + next.duration, 0) : 0;\n }\n /**\n * What time in the song is playing (in seconds).\n * @type {number}\n */\n get currentTime() {\n return this.voice.playbackDuration + this.beginTime;\n }\n /**\n * Formatted {@link Queue#currentTime} string.\n * @type {string}\n */\n get formattedCurrentTime() {\n return formatDuration(this.currentTime);\n }\n /**\n * The voice channel playing in.\n * @type {Discord.VoiceChannel|Discord.StageChannel|null}\n */\n get voiceChannel() {\n return this.clientMember.voice.channel;\n }\n get volume() {\n return this.voice.volume;\n }\n set volume(value: number) {\n this.voice.volume = value;\n }\n /**\n * Add a Song or an array of Song to the queue\n * @param {Song|Song[]} song Song to add\n * @param {number} [position=-1] Position to add, < 0 to add to the end of the queue\n * @param {boolean} [queuing=true] Wether or not waiting for unfinished tasks\n * @throws {Error}\n * @returns {Queue} The guild queue\n */\n addToQueue(song: Song | SearchResult | (Song | SearchResult)[], position = -1): Queue {\n const isArray = Array.isArray(song);\n if (!song || (isArray && !(song as Song[]).length)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"Song\", \"SearchResult\", \"Array<Song|SearchResult>\"], song, \"song\");\n }\n if (position === 0) throw new DisTubeError(\"ADD_BEFORE_PLAYING\");\n if (position < 0) {\n if (isArray) this.songs.push(...(song as Song[]));\n else this.songs.push(song as Song);\n } else if (isArray) {\n this.songs.splice(position, 0, ...(song as Song[]));\n } else {\n this.songs.splice(position, 0, song as Song);\n }\n if (isArray) (song as Song[]).map(s => delete s.formats);\n else delete (song as Song).formats;\n return this;\n }\n /**\n * Pause the guild stream\n * @returns {Queue} The guild queue\n */\n pause(): Queue {\n if (this.paused) throw new DisTubeError(\"PAUSED\");\n this.playing = false;\n this.paused = true;\n this.voice.pause();\n return this;\n }\n /**\n * Resume the guild stream\n * @returns {Queue} The guild queue\n */\n resume(): Queue {\n if (this.playing) throw new DisTubeError(\"RESUMED\");\n this.playing = true;\n this.paused = false;\n this.voice.unpause();\n return this;\n }\n /**\n * Set the guild stream's volume\n * @param {number} percent The percentage of volume you want to set\n * @returns {Queue} The guild queue\n */\n setVolume(percent: number): Queue {\n this.volume = percent;\n return this;\n }\n\n /**\n * Skip the playing song if there is a next song in the queue.\n * <info>If {@link Queue#autoplay} is `true` and there is no up next song,\n * DisTube will add and play a related song.</info>\n * @returns {Promise<Song>} The song will skip to\n * @throws {Error}\n */\n async skip(): Promise<Song> {\n await this.taskQueue.queuing();\n try {\n if (this.songs.length <= 1) {\n if (this.autoplay) await this.addRelatedSong();\n else throw new DisTubeError(\"NO_UP_NEXT\");\n }\n const song = this.songs[1];\n this.next = true;\n this.voice.stop();\n return song;\n } finally {\n this.taskQueue.resolve();\n }\n }\n\n /**\n * Play the previous song if exists\n * @returns {Song} The guild queue\n * @throws {Error}\n */\n async previous(): Promise<Song> {\n await this.taskQueue.queuing();\n try {\n if (!this.options.savePreviousSongs) throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n if (this.previousSongs?.length === 0 && this.repeatMode !== RepeatMode.QUEUE) {\n throw new DisTubeError(\"NO_PREVIOUS\");\n }\n const song =\n this.repeatMode === 2 ? this.songs[this.songs.length - 1] : this.previousSongs[this.previousSongs.length - 1];\n this.prev = true;\n this.voice.stop();\n return song;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Shuffle the queue's songs\n * @returns {Promise<Queue>} The guild queue\n */\n async shuffle(): Promise<Queue> {\n await this.taskQueue.queuing();\n try {\n if (!this.songs.length) return this;\n const playing = this.songs.shift() as Song;\n for (let i = this.songs.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [this.songs[i], this.songs[j]] = [this.songs[j], this.songs[i]];\n }\n this.songs.unshift(playing);\n return this;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Jump to the song position in the queue.\n * The next one is 1, 2,...\n * The previous one is -1, -2,...\n * @param {number} position The song position to play\n * @returns {Promise<Queue>} The guild queue\n * @throws {Error} if `num` is invalid number\n */\n async jump(position: number): Promise<Queue> {\n await this.taskQueue.queuing();\n try {\n if (typeof position !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", position, \"position\");\n if (!position || position > this.songs.length || -position > this.previousSongs.length) {\n throw new DisTubeError(\"NO_SONG_POSITION\");\n }\n if (position > 0) {\n const nextSongs = this.songs.splice(position - 1);\n if (this.options.savePreviousSongs) {\n this.previousSongs.push(...this.songs);\n } else {\n this.previousSongs.push(\n ...this.songs.map(s => {\n return { id: s.id } as Song;\n }),\n );\n }\n this.songs = nextSongs;\n this.next = true;\n } else if (!this.options.savePreviousSongs) {\n throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n } else {\n this.prev = true;\n if (position !== -1) this.songs.unshift(...this.previousSongs.splice(position + 1));\n }\n this.voice.stop();\n return this;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Set the repeat mode of the guild queue.\\\n * Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`\n * @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)\n * @returns {RepeatMode} The new repeat mode\n */\n setRepeatMode(mode?: RepeatMode): RepeatMode {\n if (mode !== undefined && !Object.values(RepeatMode).includes(mode)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"RepeatMode\", \"undefined\"], mode, \"mode\");\n }\n if (mode === undefined) this.repeatMode = (this.repeatMode + 1) % 3;\n else if (this.repeatMode === mode) this.repeatMode = RepeatMode.DISABLED;\n else this.repeatMode = mode;\n return this.repeatMode;\n }\n /**\n * Enable or disable filter(s) of the queue.\n * Available filters: {@link Filters}\n * @param {string|string[]|false} filter A filter name, an array of filter name or `false` to clear all the filters\n * @param {boolean} [force=false] Force enable the input filter(s) even if it's enabled\n * @returns {Array<string>} Enabled filters.\n * @throws {Error}\n */\n setFilter(filter: string | string[] | false, force = false): Array<string> {\n if (Array.isArray(filter)) {\n filter = filter.filter(f => Object.prototype.hasOwnProperty.call(this.distube.filters, f));\n if (!filter.length) throw new DisTubeError(\"EMPTY_FILTERED_ARRAY\", \"filter\", \"filter name\");\n for (const f of filter) {\n if (this.filters.includes(f)) {\n if (!force) this.filters.splice(this.filters.indexOf(f), 1);\n } else {\n this.filters.push(f);\n }\n }\n } else if (filter === false) {\n this.filters = [];\n } else if (!Object.prototype.hasOwnProperty.call(this.distube.filters, filter)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"filter name\", filter, \"filter\");\n } else if (this.filters.includes(filter)) {\n if (!force) this.filters.splice(this.filters.indexOf(filter), 1);\n } else {\n this.filters.push(filter);\n }\n this.beginTime = this.currentTime;\n this.queues.playSong(this);\n return this.filters;\n }\n /**\n * Set the playing time to another position\n * @param {number} time Time in seconds\n * @returns {Queue} The guild queue\n */\n seek(time: number): Queue {\n if (typeof time !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", time, \"time\");\n if (isNaN(time) || time < 0) throw new DisTubeError(\"NUMBER_COMPARE\", \"time\", \"bigger or equal to\", 0);\n this.beginTime = time;\n this.queues.playSong(this);\n return this;\n }\n /**\n * Add a related song of the playing song to the queue\n * @returns {Promise<Song>} The added song\n * @throws {Error}\n */\n async addRelatedSong(): Promise<Song> {\n if (!this.songs?.[0]) throw new DisTubeError(\"NO_PLAYING\");\n const related = this.songs[0].related.find(v => !this.previousSongs.map(s => s.id).includes(v.id));\n if (!related || !(related instanceof Song)) throw new DisTubeError(\"NO_RELATED\");\n const song = await this.handler.resolveSong(related.url, { member: this.clientMember, metadata: related.metadata });\n if (!(song instanceof Song)) throw new DisTubeError(\"CANNOT_PLAY_RELATED\");\n this.addToQueue(song);\n return song;\n }\n /**\n * Stop the guild stream\n */\n async stop() {\n await this.taskQueue.queuing();\n try {\n this.stopped = true;\n if (this.options.leaveOnStop) this.voice.leave();\n else this.voice.stop();\n this.delete();\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Delete the queue from the manager\n * (This does not leave the queue even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)\n * @private\n */\n delete() {\n this.stopped = true;\n this.songs = [];\n this.previousSongs = [];\n if (this.listeners) {\n for (const event of Object.keys(this.listeners) as (keyof DisTubeVoiceEvents)[]) {\n this.voice.removeListener(event, this.listeners[event]);\n }\n }\n this.queues.delete(this.id);\n this.emit(\"deleteQueue\", this);\n }\n /**\n * Toggle autoplay mode\n * @returns {boolean} Autoplay mode state\n */\n toggleAutoplay(): boolean {\n this.autoplay = !this.autoplay;\n return this.autoplay;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Queue.js","sourceRoot":"","sources":["../../src/struct/Queue.ts"],"names":[],"mappings":";;;AAAA,kCAAsC;AACtC,0BAA+E;AAI/E;;;GAGG;AACH,MAAa,KAAM,SAAQ,kBAAW;IA0EpC;;;;;;OAMG;IACH,YAAY,OAAgB,EAAE,KAAmB,EAAE,IAAmB,EAAE,WAAmC;QACzG,KAAK,CAAC,OAAO,CAAC,CAAC;QACf;;;WAGG;QACH,IAAI,CAAC,YAAY;YACf,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE;gBACvB,CAAC,GAAG,EAAE;oBACJ,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,aAAa,EAAE,IAAI,EAAE,yBAAyB,CAAC,CAAC;gBACzF,CAAC,CAAC,EAAE,CAAC;QACP;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB;;;WAGG;QACH,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC;QACnB;;;WAGG;QACH,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAA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QACJ,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,aAAa,GAAG,EAAE,CAAC;QACxB,IAAI,IAAI,CAAC,SAAS,EAAE;YAClB,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAiC,EAAE;gBAC/E,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;aACzD;SACF;QACD,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IACD;;;OAGG;IACH,cAAc;QACZ,IAAI,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAvfD,sBAufC","sourcesContent":["import { DisTubeBase } from \"../core\";\nimport { DisTubeError, RepeatMode, Song, TaskQueue, formatDuration } from \"..\";\nimport type { DisTube, DisTubeVoice, DisTubeVoiceEvents } from \"..\";\nimport type { GuildMember, GuildTextBasedChannel, Snowflake } from \"discord.js\";\n\n/**\n * Represents a queue.\n * @extends DisTubeBase\n */\nexport class Queue extends DisTubeBase {\n readonly id: Snowflake;\n /**\n * Voice connection of this queue\n */\n voice: DisTubeVoice;\n /**\n * List of songs in the queue (The first one is the playing song)\n */\n songs: Song[];\n /**\n * List of the previous songs.\n */\n previousSongs: Song[];\n /**\n * Whether stream is currently stopped.\n * @private\n */\n stopped: boolean;\n /**\n * Whether or not the last song was skipped to next song.\n * @private\n */\n next: boolean;\n /**\n * Whether or not the last song was skipped to previous song.\n * @private\n */\n prev: boolean;\n /**\n * Whether or not the stream is currently playing.\n */\n playing: boolean;\n /**\n * Whether or not the stream is currently paused.\n */\n paused: boolean;\n /**\n * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).\n * Default value: `0` (disabled)\n */\n repeatMode: RepeatMode;\n /**\n * Whether or not the autoplay mode is enabled.\n * Default value: `false`\n */\n autoplay: boolean;\n /**\n * Enabled audio filters.\n * Available filters: {@link Filters}\n */\n filters: string[];\n /**\n * What time in the song to begin (in seconds).\n */\n beginTime: number;\n /**\n * The text channel of the Queue. (Default: where the first command is called).\n */\n textChannel?: GuildTextBasedChannel;\n /**\n * Timeout for checking empty channel\n * @private\n */\n emptyTimeout?: NodeJS.Timeout;\n /**\n * The client user as a `GuildMember` of this queue's guild\n */\n clientMember: GuildMember;\n /**\n * Task queuing system\n */\n taskQueue: TaskQueue;\n listeners?: DisTubeVoiceEvents;\n /**\n * Create a queue for the guild\n * @param {DisTube} distube DisTube\n * @param {DisTubeVoice} voice Voice connection\n * @param {Song|Song[]} song First song(s)\n * @param {Discord.BaseGuildTextChannel?} textChannel Default text channel\n */\n constructor(distube: DisTube, voice: DisTubeVoice, song: Song | Song[], textChannel?: GuildTextBasedChannel) {\n super(distube);\n /**\n * The client user as a `GuildMember` of this queue's guild\n * @type {Discord.GuildMember}\n */\n this.clientMember =\n voice.channel.guild?.me ??\n (() => {\n throw new DisTubeError(\"INVALID_TYPE\", \"GuildMember\", null, \"<VoiceChannel>.guild.me\");\n })();\n /**\n * Voice connection of this queue.\n * @type {DisTubeVoice}\n */\n this.voice = voice;\n /**\n * Queue id (Guild id)\n * @type {Discord.Snowflake}\n */\n this.id = voice.id;\n /**\n * Get or set the stream volume. Default value: `50`.\n * @type {number}\n */\n this.volume = 50;\n /**\n * List of songs in the queue (The first one is the playing song)\n * @type {Array<Song>}\n */\n this.songs = Array.isArray(song) ? [...song] : [song];\n /**\n * List of the previous songs.\n * @type {Array<Song>}\n */\n this.previousSongs = [];\n /**\n * Whether stream is currently stopped.\n * @type {boolean}\n * @private\n */\n this.stopped = false;\n /**\n * Whether or not the last song was skipped to next song.\n * @type {boolean}\n * @private\n */\n this.next = false;\n /**\n * Whether or not the last song was skipped to previous song.\n * @type {boolean}\n * @private\n */\n this.prev = false;\n /**\n * Whether or not the stream is currently playing.\n * @type {boolean}\n */\n this.playing = true;\n /**\n * Whether or not the stream is currently paused.\n * @type {boolean}\n */\n this.paused = false;\n /**\n * Type of repeat mode (`0` is disabled, `1` is repeating a song, `2` is repeating all the queue).\n * Default value: `0` (disabled)\n * @type {RepeatMode}\n */\n this.repeatMode = RepeatMode.DISABLED;\n /**\n * Whether or not the autoplay mode is enabled.\n * Default value: `false`\n * @type {boolean}\n */\n this.autoplay = false;\n /**\n * Enabled audio filters.\n * Available filters: {@link Filters}\n * @type {Array<string>}\n */\n this.filters = [];\n /**\n * What time in the song to begin (in seconds).\n * @type {number}\n */\n this.beginTime = 0;\n /**\n * The text channel of the Queue. (Default: where the first command is called).\n * @type {Discord.TextChannel?}\n */\n this.textChannel = textChannel;\n /**\n * Timeout for checking empty channel\n * @type {*}\n * @private\n */\n this.emptyTimeout = undefined;\n /**\n * Task queuing system\n * @type {TaskQueue}\n * @private\n */\n this.taskQueue = new TaskQueue();\n /**\n * DisTubeVoice listener\n * @type {Object}\n * @private\n */\n this.listeners = undefined;\n }\n /**\n * Formatted duration string.\n * @type {string}\n */\n get formattedDuration() {\n return formatDuration(this.duration);\n }\n /**\n * Queue's duration.\n * @type {number}\n */\n get duration() {\n return this.songs.length ? this.songs.reduce((prev, next) => prev + next.duration, 0) : 0;\n }\n /**\n * What time in the song is playing (in seconds).\n * @type {number}\n */\n get currentTime() {\n return this.voice.playbackDuration + this.beginTime;\n }\n /**\n * Formatted {@link Queue#currentTime} string.\n * @type {string}\n */\n get formattedCurrentTime() {\n return formatDuration(this.currentTime);\n }\n /**\n * The voice channel playing in.\n * @type {Discord.VoiceChannel|Discord.StageChannel|null}\n */\n get voiceChannel() {\n return this.clientMember.voice.channel;\n }\n get volume() {\n return this.voice.volume;\n }\n set volume(value: number) {\n this.voice.volume = value;\n }\n /**\n * @private\n * Add a Song or an array of Song to the queue\n * @param {Song|Song[]} song Song to add\n * @param {number} [position=0] Position to add, <= 0 to add to the end of the queue\n * @throws {Error}\n * @returns {Queue} The guild queue\n */\n addToQueue(song: Song | Song[], position = 0): Queue {\n if (!song || (Array.isArray(song) && !song.length)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"Song\", \"Array<Song>\"], song, \"song\");\n }\n if (typeof position !== \"number\" || !Number.isInteger(position)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"integer\", position, \"position\");\n }\n if (position <= 0) {\n if (Array.isArray(song)) this.songs.push(...song);\n else this.songs.push(song);\n } else if (Array.isArray(song)) {\n this.songs.splice(position, 0, ...song);\n } else {\n this.songs.splice(position, 0, song);\n }\n if (Array.isArray(song)) song.map(s => delete s.formats);\n else delete song.formats;\n return this;\n }\n /**\n * Pause the guild stream\n * @returns {Queue} The guild queue\n */\n pause(): Queue {\n if (this.paused) throw new DisTubeError(\"PAUSED\");\n this.playing = false;\n this.paused = true;\n this.voice.pause();\n return this;\n }\n /**\n * Resume the guild stream\n * @returns {Queue} The guild queue\n */\n resume(): Queue {\n if (this.playing) throw new DisTubeError(\"RESUMED\");\n this.playing = true;\n this.paused = false;\n this.voice.unpause();\n return this;\n }\n /**\n * Set the guild stream's volume\n * @param {number} percent The percentage of volume you want to set\n * @returns {Queue} The guild queue\n */\n setVolume(percent: number): Queue {\n this.volume = percent;\n return this;\n }\n\n /**\n * Skip the playing song if there is a next song in the queue.\n * <info>If {@link Queue#autoplay} is `true` and there is no up next song,\n * DisTube will add and play a related song.</info>\n * @returns {Promise<Song>} The song will skip to\n * @throws {Error}\n */\n async skip(): Promise<Song> {\n await this.taskQueue.queuing();\n try {\n if (this.songs.length <= 1) {\n if (this.autoplay) await this.addRelatedSong();\n else throw new DisTubeError(\"NO_UP_NEXT\");\n }\n const song = this.songs[1];\n this.next = true;\n this.voice.stop();\n return song;\n } finally {\n this.taskQueue.resolve();\n }\n }\n\n /**\n * Play the previous song if exists\n * @returns {Song} The guild queue\n * @throws {Error}\n */\n async previous(): Promise<Song> {\n await this.taskQueue.queuing();\n try {\n if (!this.options.savePreviousSongs) throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n if (this.previousSongs?.length === 0 && this.repeatMode !== RepeatMode.QUEUE) {\n throw new DisTubeError(\"NO_PREVIOUS\");\n }\n const song =\n this.repeatMode === 2 ? this.songs[this.songs.length - 1] : this.previousSongs[this.previousSongs.length - 1];\n this.prev = true;\n this.voice.stop();\n return song;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Shuffle the queue's songs\n * @returns {Promise<Queue>} The guild queue\n */\n async shuffle(): Promise<Queue> {\n await this.taskQueue.queuing();\n try {\n const playing = this.songs.shift();\n if (playing === undefined) return this;\n for (let i = this.songs.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [this.songs[i], this.songs[j]] = [this.songs[j], this.songs[i]];\n }\n this.songs.unshift(playing);\n return this;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Jump to the song position in the queue.\n * The next one is 1, 2,...\n * The previous one is -1, -2,...\n * @param {number} position The song position to play\n * @returns {Promise<Queue>} The guild queue\n * @throws {Error} if `num` is invalid number\n */\n async jump(position: number): Promise<Queue> {\n await this.taskQueue.queuing();\n try {\n if (typeof position !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", position, \"position\");\n if (!position || position > this.songs.length || -position > this.previousSongs.length) {\n throw new DisTubeError(\"NO_SONG_POSITION\");\n }\n if (position > 0) {\n const nextSongs = this.songs.splice(position - 1);\n if (this.options.savePreviousSongs) {\n this.previousSongs.push(...this.songs);\n } else {\n this.previousSongs.push(...this.songs.map(s => ({ id: s.id } as Song)));\n }\n this.songs = nextSongs;\n this.next = true;\n } else if (!this.options.savePreviousSongs) {\n throw new DisTubeError(\"DISABLED_OPTION\", \"savePreviousSongs\");\n } else {\n this.prev = true;\n if (position !== -1) this.songs.unshift(...this.previousSongs.splice(position + 1));\n }\n this.voice.stop();\n return this;\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Set the repeat mode of the guild queue.\\\n * Toggle mode `(Disabled -> Song -> Queue -> Disabled ->...)` if `mode` is `undefined`\n * @param {RepeatMode?} [mode] The repeat modes (toggle if `undefined`)\n * @returns {RepeatMode} The new repeat mode\n */\n setRepeatMode(mode?: RepeatMode): RepeatMode {\n if (mode !== undefined && !Object.values(RepeatMode).includes(mode)) {\n throw new DisTubeError(\"INVALID_TYPE\", [\"RepeatMode\", \"undefined\"], mode, \"mode\");\n }\n if (mode === undefined) this.repeatMode = (this.repeatMode + 1) % 3;\n else if (this.repeatMode === mode) this.repeatMode = RepeatMode.DISABLED;\n else this.repeatMode = mode;\n return this.repeatMode;\n }\n /**\n * Enable or disable filter(s) of the queue.\n * Available filters: {@link Filters}\n * @param {string|string[]|false} filter A filter name, an array of filter name or `false` to clear all the filters\n * @param {boolean} [force=false] Force enable the input filter(s) even if it's enabled\n * @returns {Array<string>} Enabled filters.\n * @throws {Error}\n */\n setFilter(filter: string | string[] | false, force = false): Array<string> {\n if (Array.isArray(filter)) {\n filter = filter.filter(f => Object.prototype.hasOwnProperty.call(this.distube.filters, f));\n if (!filter.length) throw new DisTubeError(\"EMPTY_FILTERED_ARRAY\", \"filter\", \"filter name\");\n for (const f of filter) {\n if (this.filters.includes(f)) {\n if (!force) this.filters.splice(this.filters.indexOf(f), 1);\n } else {\n this.filters.push(f);\n }\n }\n } else if (filter === false) {\n this.filters = [];\n } else if (!Object.prototype.hasOwnProperty.call(this.distube.filters, filter)) {\n throw new DisTubeError(\"INVALID_TYPE\", \"filter name\", filter, \"filter\");\n } else if (this.filters.includes(filter)) {\n if (!force) this.filters.splice(this.filters.indexOf(filter), 1);\n } else {\n this.filters.push(filter);\n }\n this.beginTime = this.currentTime;\n this.queues.playSong(this);\n return this.filters;\n }\n /**\n * Set the playing time to another position\n * @param {number} time Time in seconds\n * @returns {Queue} The guild queue\n */\n seek(time: number): Queue {\n if (typeof time !== \"number\") throw new DisTubeError(\"INVALID_TYPE\", \"number\", time, \"time\");\n if (isNaN(time) || time < 0) throw new DisTubeError(\"NUMBER_COMPARE\", \"time\", \"bigger or equal to\", 0);\n this.beginTime = time;\n this.queues.playSong(this);\n return this;\n }\n /**\n * Add a related song of the playing song to the queue\n * @returns {Promise<Song>} The added song\n * @throws {Error}\n */\n async addRelatedSong(): Promise<Song> {\n if (!this.songs?.[0]) throw new DisTubeError(\"NO_PLAYING\");\n const related = this.songs[0].related.find(v => !this.previousSongs.map(s => s.id).includes(v.id));\n if (!related || !(related instanceof Song)) throw new DisTubeError(\"NO_RELATED\");\n const song = await this.handler.resolveSong(related, { member: this.clientMember, metadata: related.metadata });\n if (!(song instanceof Song)) throw new DisTubeError(\"CANNOT_PLAY_RELATED\");\n this.addToQueue(song);\n return song;\n }\n /**\n * Stop the guild stream and delete the queue\n */\n async stop() {\n await this.taskQueue.queuing();\n try {\n this.stopped = true;\n if (this.options.leaveOnStop) this.voice.leave();\n else this.voice.stop();\n this.delete();\n } finally {\n this.taskQueue.resolve();\n }\n }\n /**\n * Delete the queue from the manager\n * (This does not leave the voice channel even if {@link DisTubeOptions|DisTubeOptions.leaveOnStop} is enabled)\n * @private\n */\n delete() {\n this.stopped = true;\n this.songs = [];\n this.previousSongs = [];\n if (this.listeners) {\n for (const event of Object.keys(this.listeners) as (keyof DisTubeVoiceEvents)[]) {\n this.voice.removeListener(event, this.listeners[event]);\n }\n }\n this.queues.delete(this.id);\n this.emit(\"deleteQueue\", this);\n }\n /**\n * Toggle autoplay mode\n * @returns {boolean} Autoplay mode state\n */\n toggleAutoplay(): boolean {\n this.autoplay = !this.autoplay;\n return this.autoplay;\n }\n}\n"]}
|
package/dist/struct/Song.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Playlist } from "./Playlist";
|
|
2
2
|
import type ytdl from "@distube/ytdl-core";
|
|
3
|
-
import type { GuildMember
|
|
4
|
-
import type { Chapter, OtherSongInfo, SearchResult } from "..";
|
|
3
|
+
import type { GuildMember } from "discord.js";
|
|
4
|
+
import type { Chapter, OtherSongInfo, RelatedSong, SearchResult } from "..";
|
|
5
5
|
/**
|
|
6
6
|
* Class representing a song.
|
|
7
7
|
*
|
|
@@ -13,11 +13,9 @@ import type { Chapter, OtherSongInfo, SearchResult } from "..";
|
|
|
13
13
|
* @template T - The type for the metadata (if any) of the song
|
|
14
14
|
*/
|
|
15
15
|
export declare class Song<T = unknown> {
|
|
16
|
+
#private;
|
|
16
17
|
source: string;
|
|
17
|
-
metadata: T;
|
|
18
18
|
formats?: ytdl.videoFormat[];
|
|
19
|
-
member?: GuildMember;
|
|
20
|
-
user?: User;
|
|
21
19
|
id?: string;
|
|
22
20
|
name?: string;
|
|
23
21
|
isLive: boolean;
|
|
@@ -26,7 +24,7 @@ export declare class Song<T = unknown> {
|
|
|
26
24
|
url: string;
|
|
27
25
|
streamURL?: string;
|
|
28
26
|
thumbnail?: string;
|
|
29
|
-
related:
|
|
27
|
+
related: RelatedSong[];
|
|
30
28
|
views: number;
|
|
31
29
|
likes: number;
|
|
32
30
|
dislikes: number;
|
|
@@ -37,7 +35,6 @@ export declare class Song<T = unknown> {
|
|
|
37
35
|
age_restricted: boolean;
|
|
38
36
|
chapters: Chapter[];
|
|
39
37
|
reposts: number;
|
|
40
|
-
playlist?: Playlist;
|
|
41
38
|
constructor(info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo);
|
|
42
39
|
/** @deprecated Passing GuildMember for DisTube#Song() is deprecated. */
|
|
43
40
|
constructor(info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo, member?: GuildMember, source?: string, metadata?: T);
|
|
@@ -49,7 +46,7 @@ export declare class Song<T = unknown> {
|
|
|
49
46
|
* @param {string} [options.source="youtube"] Song source
|
|
50
47
|
* @param {T} [options.metadata] Song metadata
|
|
51
48
|
*/
|
|
52
|
-
constructor(info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo, options?: {
|
|
49
|
+
constructor(info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo | RelatedSong, options?: {
|
|
53
50
|
member?: GuildMember;
|
|
54
51
|
source?: string;
|
|
55
52
|
metadata?: T;
|
|
@@ -62,23 +59,23 @@ export declare class Song<T = unknown> {
|
|
|
62
59
|
*/
|
|
63
60
|
_patchOther(info: OtherSongInfo): void;
|
|
64
61
|
/**
|
|
65
|
-
*
|
|
66
|
-
* @
|
|
67
|
-
* @private
|
|
68
|
-
* @returns {Song}
|
|
62
|
+
* The playlist added this song
|
|
63
|
+
* @type {Playlist?}
|
|
69
64
|
*/
|
|
70
|
-
|
|
65
|
+
get playlist(): Playlist | undefined;
|
|
66
|
+
set playlist(playlist: Playlist | undefined);
|
|
71
67
|
/**
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
74
|
-
* @returns {Song}
|
|
68
|
+
* User requested.
|
|
69
|
+
* @type {Discord.GuildMember?}
|
|
75
70
|
*/
|
|
76
|
-
|
|
71
|
+
get member(): GuildMember | undefined;
|
|
72
|
+
set member(member: GuildMember | undefined);
|
|
77
73
|
/**
|
|
78
|
-
*
|
|
79
|
-
* @
|
|
80
|
-
* @returns {Song}
|
|
74
|
+
* User requested.
|
|
75
|
+
* @type {Discord.User?}
|
|
81
76
|
*/
|
|
82
|
-
|
|
77
|
+
get user(): import("discord.js").User | undefined;
|
|
78
|
+
get metadata(): T;
|
|
79
|
+
set metadata(metadata: T);
|
|
83
80
|
}
|
|
84
81
|
//# sourceMappingURL=Song.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Song.d.ts","sourceRoot":"","sources":["../../src/struct/Song.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW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