distube 3.0.7 → 3.1.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.
Files changed (100) hide show
  1. package/dist/DisTube.d.ts +98 -37
  2. package/dist/DisTube.d.ts.map +1 -1
  3. package/dist/DisTube.js +130 -84
  4. package/dist/DisTube.js.map +1 -1
  5. package/dist/constant.d.ts +12 -13
  6. package/dist/constant.d.ts.map +1 -1
  7. package/dist/constant.js +12 -13
  8. package/dist/constant.js.map +1 -1
  9. package/dist/core/DisTubeBase.d.ts +3 -4
  10. package/dist/core/DisTubeBase.d.ts.map +1 -1
  11. package/dist/core/DisTubeBase.js +1 -2
  12. package/dist/core/DisTubeBase.js.map +1 -1
  13. package/dist/core/DisTubeHandler.d.ts +37 -25
  14. package/dist/core/DisTubeHandler.d.ts.map +1 -1
  15. package/dist/core/DisTubeHandler.js +68 -59
  16. package/dist/core/DisTubeHandler.js.map +1 -1
  17. package/dist/core/DisTubeOptions.d.ts +1 -2
  18. package/dist/core/DisTubeOptions.d.ts.map +1 -1
  19. package/dist/core/DisTubeOptions.js +64 -58
  20. package/dist/core/DisTubeOptions.js.map +1 -1
  21. package/dist/core/DisTubeStream.d.ts +1 -1
  22. package/dist/core/DisTubeStream.d.ts.map +1 -1
  23. package/dist/core/DisTubeStream.js +0 -1
  24. package/dist/core/DisTubeStream.js.map +1 -1
  25. package/dist/core/index.d.ts +2 -2
  26. package/dist/core/index.d.ts.map +1 -1
  27. package/dist/core/index.js +2 -2
  28. package/dist/core/index.js.map +1 -1
  29. package/dist/core/manager/BaseManager.d.ts +8 -4
  30. package/dist/core/manager/BaseManager.d.ts.map +1 -1
  31. package/dist/core/manager/BaseManager.js +11 -13
  32. package/dist/core/manager/BaseManager.js.map +1 -1
  33. package/dist/core/manager/QueueManager.d.ts +11 -38
  34. package/dist/core/manager/QueueManager.d.ts.map +1 -1
  35. package/dist/core/manager/QueueManager.js +116 -129
  36. package/dist/core/manager/QueueManager.js.map +1 -1
  37. package/dist/core/voice/DisTubeVoice.d.ts +10 -13
  38. package/dist/core/voice/DisTubeVoice.d.ts.map +1 -1
  39. package/dist/core/voice/DisTubeVoice.js +30 -17
  40. package/dist/core/voice/DisTubeVoice.js.map +1 -1
  41. package/dist/core/voice/DisTubeVoiceManager.d.ts +6 -6
  42. package/dist/core/voice/DisTubeVoiceManager.d.ts.map +1 -1
  43. package/dist/core/voice/DisTubeVoiceManager.js +3 -3
  44. package/dist/core/voice/DisTubeVoiceManager.js.map +1 -1
  45. package/dist/plugin/http.d.ts +5 -3
  46. package/dist/plugin/http.d.ts.map +1 -1
  47. package/dist/plugin/http.js +3 -5
  48. package/dist/plugin/http.js.map +1 -1
  49. package/dist/plugin/https.d.ts +10 -5
  50. package/dist/plugin/https.d.ts.map +1 -1
  51. package/dist/plugin/https.js +5 -8
  52. package/dist/plugin/https.js.map +1 -1
  53. package/dist/plugin/youtube-dl.d.ts +5 -4
  54. package/dist/plugin/youtube-dl.d.ts.map +1 -1
  55. package/dist/plugin/youtube-dl.js +7 -11
  56. package/dist/plugin/youtube-dl.js.map +1 -1
  57. package/dist/struct/CustomPlugin.d.ts +37 -17
  58. package/dist/struct/CustomPlugin.d.ts.map +1 -1
  59. package/dist/struct/CustomPlugin.js +18 -19
  60. package/dist/struct/CustomPlugin.js.map +1 -1
  61. package/dist/struct/DisTubeError.d.ts +4 -2
  62. package/dist/struct/DisTubeError.d.ts.map +1 -1
  63. package/dist/struct/DisTubeError.js +4 -3
  64. package/dist/struct/DisTubeError.js.map +1 -1
  65. package/dist/struct/ExtractorPlugin.d.ts +25 -15
  66. package/dist/struct/ExtractorPlugin.d.ts.map +1 -1
  67. package/dist/struct/ExtractorPlugin.js +14 -16
  68. package/dist/struct/ExtractorPlugin.js.map +1 -1
  69. package/dist/struct/Playlist.d.ts +24 -8
  70. package/dist/struct/Playlist.d.ts.map +1 -1
  71. package/dist/struct/Playlist.js +24 -8
  72. package/dist/struct/Playlist.js.map +1 -1
  73. package/dist/struct/Plugin.d.ts +4 -12
  74. package/dist/struct/Plugin.d.ts.map +1 -1
  75. package/dist/struct/Plugin.js +1 -11
  76. package/dist/struct/Plugin.js.map +1 -1
  77. package/dist/struct/Queue.d.ts +5 -6
  78. package/dist/struct/Queue.d.ts.map +1 -1
  79. package/dist/struct/Queue.js +2 -3
  80. package/dist/struct/Queue.js.map +1 -1
  81. package/dist/struct/SearchResult.d.ts +0 -1
  82. package/dist/struct/SearchResult.d.ts.map +1 -1
  83. package/dist/struct/SearchResult.js +0 -1
  84. package/dist/struct/SearchResult.js.map +1 -1
  85. package/dist/struct/Song.d.ts +26 -10
  86. package/dist/struct/Song.d.ts.map +1 -1
  87. package/dist/struct/Song.js +39 -27
  88. package/dist/struct/Song.js.map +1 -1
  89. package/dist/struct/TaskQueue.d.ts +1 -6
  90. package/dist/struct/TaskQueue.d.ts.map +1 -1
  91. package/dist/struct/TaskQueue.js +13 -6
  92. package/dist/struct/TaskQueue.js.map +1 -1
  93. package/dist/tsconfig.tsbuildinfo +1 -1
  94. package/dist/type.d.ts +12 -12
  95. package/dist/type.d.ts.map +1 -1
  96. package/dist/type.js.map +1 -1
  97. package/dist/util.d.ts +4 -4
  98. package/dist/util.d.ts.map +1 -1
  99. package/dist/util.js.map +1 -1
  100. package/package.json +5 -6
@@ -1 +1 @@
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,WAAyB;;QAC/F,KAAK,CAAC,OAAO,CAAC,CAAC;QACf;;;WAGG;QACH,IAAI,CAAC,YAAY,GAAG,MAAA,KAAK,CAAC,OAAO,CAAC,KAAK,0CAAE,EAAiB,CAAC;QAC3D;;;WAGG;QACH,IAAI,CAAC,KAAK,GAAG,KA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CAAC;YACvB,IAAI,CAAC,MAAM,EAAE,CAAC;SACf;gBAAS;YACR,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;SAC1B;IACH,CAAC;IACD;;;;OAIG;IACH,MAAM;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;AAtfD,sBAsfC;AAED,kBAAe,KAAK,CAAC","sourcesContent":["import { DisTubeBase } from \"../core\";\nimport { DisTubeError, RepeatMode, Song, TaskQueue, formatDuration } from \"..\";\nimport type { GuildMember, Snowflake, TextChannel } 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 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?: TextChannel;\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.TextChannel?} textChannel Default text channel\n */\n constructor(distube: DisTube, voice: DisTubeVoice, song: Song | Song[], textChannel?: TextChannel) {\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(this.clientMember, related.url);\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\nexport default Queue;\n"]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CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AAtfD,sBAsfC","sourcesContent":["import { DisTubeBase } 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"]}
@@ -24,5 +24,4 @@ export declare class SearchResult {
24
24
  */
25
25
  constructor(info: Video | Playlist);
26
26
  }
27
- export default SearchResult;
28
27
  //# sourceMappingURL=SearchResult.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SearchResult.d.ts","sourceRoot":"","sources":["../../src/struct/SearchResult.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAErD,0CAA0C;AAC1C,qBAAa,YAAY;IACvB,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,QAAQ,EAAE;QACR,oBAAoB;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,mBAAmB;QACnB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF;;;OAGG;gBACS,IAAI,EAAE,KAAK,GAAG,QAAQ;CA+DnC;AAED,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"SearchResult.d.ts","sourceRoot":"","sources":["../../src/struct/SearchResult.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAErD,0CAA0C;AAC1C,qBAAa,YAAY;IACvB,MAAM,EAAE,SAAS,CAAC;IAClB,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,QAAQ,EAAE;QACR,oBAAoB;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,mBAAmB;QACnB,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF;;;OAGG;gBACS,IAAI,EAAE,KAAK,GAAG,QAAQ;CA+DnC"}
@@ -75,5 +75,4 @@ class SearchResult {
75
75
  }
76
76
  }
77
77
  exports.SearchResult = SearchResult;
78
- exports.default = SearchResult;
79
78
  //# sourceMappingURL=SearchResult.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SearchResult.js","sourceRoot":"","sources":["../../src/struct/SearchResult.ts"],"names":[],"mappings":";;;AAAA,0BAA4D;AAG5D,0CAA0C;AAC1C,MAAa,YAAY;IAkBvB;;;OAGG;IACH,YAAY,IAAsB;;QAChC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB;;;WAGG;QACH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AAC,KAAK,CAAC,0CAAE,GAAG;SAC/D,CAAC;IACJ,CAAC;CACF;AArFD,oCAqFC;AAED,kBAAe,YAAY,CAAC","sourcesContent":["import { DisTubeError, formatDuration, toSecond } from \"..\";\nimport type { Playlist, Video } from \"@distube/ytsr\";\n\n/** Class representing a search result. */\nexport class SearchResult {\n source: \"youtube\";\n type: \"video\" | \"playlist\";\n id: string;\n name: string;\n url: string;\n views?: number;\n isLive?: boolean;\n duration?: number;\n formattedDuration?: string;\n thumbnail?: string;\n /** Video or playlist uploader */\n uploader: {\n /** Uploader name */\n name?: string;\n /** Uploader url */\n url?: string;\n };\n /**\n * Create a search result\n * @param {Object} info ytsr result\n */\n constructor(info: Video | Playlist) {\n this.source = \"youtube\";\n /**\n * Type of SearchResult (`video` or `playlist`)\n * @type {string}\n */\n this.type = info.type;\n /**\n * YouTube video or playlist id\n * @type {string}\n */\n this.id = info.id;\n /**\n * Video or playlist title.\n * @type {string}\n */\n this.name = info.name;\n /**\n * Video or playlist URL.\n * @type {string}\n */\n this.url = info.url;\n if (this.type === \"video\") {\n info = info as Video;\n /**\n * [Video only] Video or playlist views count\n * @type {number}\n */\n this.views = info.views;\n /**\n * [Video only] Indicates if the video is an active live.\n * @type {boolean?}\n */\n this.isLive = info.isLive;\n /**\n * [Video only] Video duration.\n * @type {number}\n */\n this.duration = this.isLive ? 0 : toSecond(info.duration);\n /**\n * [Video only] Formatted duration string `hh:mm:ss` or `mm:ss`.\n * @type {string}\n */\n this.formattedDuration = this.isLive ? \"Live\" : formatDuration(this.duration);\n /**\n * [Video only] Video thumbnail.\n * @type {string?}\n */\n this.thumbnail = info.thumbnail;\n } else if (this.type !== \"playlist\") {\n throw new DisTubeError(\"INVALID_TYPE\", [\"video\", \"playlist\"], this.type, \"SearchResult.type\");\n }\n /**\n * Song uploader\n * @type {Object}\n * @prop {string?} name Uploader name\n * @prop {string?} url Uploader url\n */\n this.uploader = {\n name: ((info as Video).author || (info as Playlist).owner)?.name,\n url: ((info as Video).author || (info as Playlist).owner)?.url,\n };\n }\n}\n\nexport default SearchResult;\n"]}
1
+ {"version":3,"file":"SearchResult.js","sourceRoot":"","sources":["../../src/struct/SearchResult.ts"],"names":[],"mappings":";;;AAAA,0BAA4D;AAG5D,0CAA0C;AAC1C,MAAa,YAAY;IAkBvB;;;OAGG;IACH,YAAY,IAAsB;;QAChC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB;;;WAGG;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB;;;WAGG;QACH,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,CAAC;QAClB;;;WAGG;QACH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACtB;;;WAGG;QACH,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACpB,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE;YACzB,IAAI,GAAG,IAAa,CAAC;YACrB;;;eAGG;YACH,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;YACxB;;;eAGG;YACH,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YAC1B;;;eAGG;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAA,YAAQ,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC1D;;;eAGG;YACH,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAA,kBAAc,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAC9E;;;eAGG;YACH,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;SACjC;aAAM,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU,EAAE;YACnC,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC;SAC/F;QACD;;;;;WAKG;QACH,IAAI,CAAC,QAAQ,GAAG;YACd,IAAI,EAAE,MAAA,CAAE,IAAc,CAAC,MAAM,IAAK,IAAiB,CAAC,KAAK,CAAC,0CAAE,IAAI;YAChE,GAAG,EAAE,MAAA,CAAE,IAAc,CAAC,MAAM,IAAK,IAAiB,CAAC,KAAK,CAAC,0CAAE,GAAG;SAC/D,CAAC;IACJ,CAAC;CACF;AArFD,oCAqFC","sourcesContent":["import { DisTubeError, formatDuration, toSecond } from \"..\";\nimport type { Playlist, Video } from \"@distube/ytsr\";\n\n/** Class representing a search result. */\nexport class SearchResult {\n source: \"youtube\";\n type: \"video\" | \"playlist\";\n id: string;\n name: string;\n url: string;\n views?: number;\n isLive?: boolean;\n duration?: number;\n formattedDuration?: string;\n thumbnail?: string;\n /** Video or playlist uploader */\n uploader: {\n /** Uploader name */\n name?: string;\n /** Uploader url */\n url?: string;\n };\n /**\n * Create a search result\n * @param {Object} info ytsr result\n */\n constructor(info: Video | Playlist) {\n this.source = \"youtube\";\n /**\n * Type of SearchResult (`video` or `playlist`)\n * @type {string}\n */\n this.type = info.type;\n /**\n * YouTube video or playlist id\n * @type {string}\n */\n this.id = info.id;\n /**\n * Video or playlist title.\n * @type {string}\n */\n this.name = info.name;\n /**\n * Video or playlist URL.\n * @type {string}\n */\n this.url = info.url;\n if (this.type === \"video\") {\n info = info as Video;\n /**\n * [Video only] Video or playlist views count\n * @type {number}\n */\n this.views = info.views;\n /**\n * [Video only] Indicates if the video is an active live.\n * @type {boolean?}\n */\n this.isLive = info.isLive;\n /**\n * [Video only] Video duration.\n * @type {number}\n */\n this.duration = this.isLive ? 0 : toSecond(info.duration);\n /**\n * [Video only] Formatted duration string `hh:mm:ss` or `mm:ss`.\n * @type {string}\n */\n this.formattedDuration = this.isLive ? \"Live\" : formatDuration(this.duration);\n /**\n * [Video only] Video thumbnail.\n * @type {string?}\n */\n this.thumbnail = info.thumbnail;\n } else if (this.type !== \"playlist\") {\n throw new DisTubeError(\"INVALID_TYPE\", [\"video\", \"playlist\"], this.type, \"SearchResult.type\");\n }\n /**\n * Song uploader\n * @type {Object}\n * @prop {string?} name Uploader name\n * @prop {string?} url Uploader url\n */\n this.uploader = {\n name: ((info as Video).author || (info as Playlist).owner)?.name,\n url: ((info as Video).author || (info as Playlist).owner)?.url,\n };\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import Playlist from "./Playlist";
1
+ import { Playlist } from "./Playlist";
2
2
  import type ytdl from "@distube/ytdl-core";
3
3
  import type { GuildMember, User } from "discord.js";
4
4
  import type { Chapter, OtherSongInfo, SearchResult } from "..";
@@ -10,9 +10,11 @@ import type { Chapter, OtherSongInfo, SearchResult } from "..";
10
10
  *
11
11
  * Missing info: {@link Song#likes}, {@link Song#dislikes}, {@link Song#streamURL},
12
12
  * {@link Song#related}, {@link Song#chapters}, {@link Song#age_restricted}</info>
13
+ * @template T - The type for the metadata (if any) of the song
13
14
  */
14
- export declare class Song {
15
+ export declare class Song<T = unknown> {
15
16
  source: string;
17
+ metadata: T;
16
18
  formats?: ytdl.videoFormat[];
17
19
  member?: GuildMember;
18
20
  user?: User;
@@ -24,7 +26,7 @@ export declare class Song {
24
26
  url: string;
25
27
  streamURL?: string;
26
28
  thumbnail?: string;
27
- related: Song[];
29
+ related: Omit<Song, "related">[];
28
30
  views: number;
29
31
  likes: number;
30
32
  dislikes: number;
@@ -36,33 +38,47 @@ export declare class Song {
36
38
  chapters: Chapter[];
37
39
  reposts: number;
38
40
  playlist?: Playlist;
41
+ constructor(info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo);
42
+ /** @deprecated Passing GuildMember for DisTube#Song() is deprecated. */
43
+ constructor(info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo, member?: GuildMember, source?: string, metadata?: T);
39
44
  /**
40
45
  * Create a Song
41
46
  * @param {ytdl.videoInfo|SearchResult|OtherSongInfo} info Raw info
42
- * @param {Discord.GuildMember?} member Requested user
43
- * @param {string} source Song source
47
+ * @param {Object} [options] Optional options
48
+ * @param {Discord.GuildMember} [options.member] Requested user
49
+ * @param {string} [options.source="youtube"] Song source
50
+ * @param {T} [options.metadata] Song metadata
44
51
  */
45
- constructor(info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo, member?: GuildMember, source?: string);
52
+ constructor(info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo, options?: {
53
+ member?: GuildMember;
54
+ source?: string;
55
+ metadata?: T;
56
+ });
46
57
  _patchYouTube(i: ytdl.videoInfo | SearchResult): void;
47
58
  /**
48
59
  * Patch data from other source
49
60
  * @param {OtherSongInfo} info Video info
50
61
  * @private
51
62
  */
52
- private _patchOther;
63
+ _patchOther(info: OtherSongInfo): void;
53
64
  /**
54
65
  * @param {Playlist} playlist Playlist
55
66
  * @param {Discord.GuildMember} [member] Requested user
56
67
  * @private
57
68
  * @returns {Song}
58
69
  */
59
- _patchPlaylist(playlist: Playlist, member?: GuildMember): Song;
70
+ _patchPlaylist(playlist: Playlist, member?: GuildMember): this;
60
71
  /**
61
72
  * @param {Discord.GuildMember} [member] Requested user
62
73
  * @private
63
74
  * @returns {Song}
64
75
  */
65
- _patchMember(member?: GuildMember): Song;
76
+ _patchMember(member?: GuildMember): this;
77
+ /**
78
+ * @param {*} metadata Metadata
79
+ * @private
80
+ * @returns {Song}
81
+ */
82
+ _patchMetadata<S = unknown>(metadata: S): Song<S>;
66
83
  }
67
- export default Song;
68
84
  //# sourceMappingURL=Song.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Song.d.ts","sourceRoot":"","sources":["../../src/struct/Song.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAElC,OAAO,KAAK,IAAI,MAAM,oBAAoB,CAAC;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE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M,CAAC;KACd,CAAC;IACF,cAAc,EAAG,OAAO,CAAC;IACzB,QAAQ,EAAG,OAAO,EAAE,CAAC;IACrB,OAAO,EAAG,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,QAAQ,CAAC;gBACR,IAAI,EAAE,IAAI,CAAC,SAAS,GAAG,YAAY,GAAG,aAAa,GAAG,IAAI,CAAC,YAAY;IACnF,wEAAwE;gBAEtE,IAAI,EAAE,IAAI,CAAC,SAAS,GAAG,YAAY,GAAG,aAAa,GAAG,IAAI,CAAC,YAAY,EACvE,MAAM,CAAC,EAAE,WAAW,EACpB,MAAM,CAAC,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,CAAC;IAEd;;;;;;;OAOG;gBAED,IAAI,EAAE,IAAI,CAAC,SAAS,GAAG,YAAY,GAAG,aAAa,GAAG,IAAI,CAAC,YAAY,EACvE,OAAO,CAAC,EAAE;QACR,MAAM,CAAC,EAAE,WAAW,CAAC;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,CAAC,CAAC;KACd;IAgDH,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,GAAG,YAAY;IAuH9C;;;;OAIG;IACH,WAAW,CAAC,IAAI,EAAE,aAAa;IAsB/B;;;;;OAKG;IACH,cAAc,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,WAAW;IAWvD;;;;OAIG;IACH,YAAY,CAAC,MAAM,CAAC,EAAE,WAAW;IAcjC;;;;OAIG;IACH,cAAc,CAAC,CAAC,GAAG,OAAO,EAAE,QAAQ,EAAE,CAAC;CAIxC"}
@@ -1,11 +1,9 @@
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.Song = void 0;
7
- const Playlist_1 = __importDefault(require("./Playlist"));
4
+ const Playlist_1 = require("./Playlist");
8
5
  const __1 = require("..");
6
+ // TODO: Clean parameters on the next major version.
9
7
  /**
10
8
  * Class representing a song.
11
9
  *
@@ -14,16 +12,16 @@ const __1 = require("..");
14
12
  *
15
13
  * Missing info: {@link Song#likes}, {@link Song#dislikes}, {@link Song#streamURL},
16
14
  * {@link Song#related}, {@link Song#chapters}, {@link Song#age_restricted}</info>
15
+ * @template T - The type for the metadata (if any) of the song
17
16
  */
18
17
  class Song {
19
- /**
20
- * Create a Song
21
- * @param {ytdl.videoInfo|SearchResult|OtherSongInfo} info Raw info
22
- * @param {Discord.GuildMember?} member Requested user
23
- * @param {string} source Song source
24
- */
25
- constructor(info, member, source = "youtube") {
18
+ constructor(info, options = {}, src = "youtube", meta) {
26
19
  var _a;
20
+ if ((0, __1.isMemberInstance)(options)) {
21
+ process.emitWarning("Passing GuildMember for DisTube#Song() is deprecated, read the docs for more.", "DeprecationWarning");
22
+ return new Song(info, { member: options, source: src, metadata: meta });
23
+ }
24
+ const { member, source, metadata } = Object.assign({ source: "youtube" }, options);
27
25
  if (typeof source !== "string" ||
28
26
  (info.src && typeof info.src !== "string")) {
29
27
  throw new __1.DisTubeError("INVALID_TYPE", "string", source, "source");
@@ -40,6 +38,11 @@ class Song {
40
38
  else {
41
39
  this._patchOther(info);
42
40
  }
41
+ /**
42
+ * Optional metadata that can be used to identify the song.
43
+ * @type {T}
44
+ */
45
+ this.metadata = metadata;
43
46
  }
44
47
  _patchYouTube(i) {
45
48
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
@@ -108,10 +111,13 @@ class Song {
108
111
  ((_c = details.thumbnail) === null || _c === void 0 ? void 0 : _c.url) ||
109
112
  details.thumbnail;
110
113
  /**
111
- * Related songs
114
+ * Related songs (without {@link Song#related} properties)
112
115
  * @type {Song[]}
113
116
  */
114
- this.related = ((_d = info === null || info === void 0 ? void 0 : info.related_videos) === null || _d === void 0 ? void 0 : _d.map((v) => new Song(v))) || details.related || [];
117
+ this.related =
118
+ ((_d = info === null || info === void 0 ? void 0 : info.related_videos) === null || _d === void 0 ? void 0 : _d.map((v) => new Song(v, { source: this.source, metadata: this.metadata }))) ||
119
+ details.related ||
120
+ [];
115
121
  /**
116
122
  * Song views count
117
123
  * @type {number}
@@ -194,7 +200,7 @@ class Song {
194
200
  * @returns {Song}
195
201
  */
196
202
  _patchPlaylist(playlist, member) {
197
- if (!(playlist instanceof Playlist_1.default))
203
+ if (!(playlist instanceof Playlist_1.Playlist))
198
204
  throw new __1.DisTubeError("INVALID_TYPE", "Playlist", playlist, "playlist");
199
205
  /**
200
206
  * The playlist added this song
@@ -209,21 +215,27 @@ class Song {
209
215
  * @returns {Song}
210
216
  */
211
217
  _patchMember(member) {
212
- if (member) {
213
- /**
214
- * User requested
215
- * @type {Discord.GuildMember?}
216
- */
217
- this.member = member;
218
- /**
219
- * User requested
220
- * @type {Discord.User?}
221
- */
222
- this.user = member === null || member === void 0 ? void 0 : member.user;
223
- }
218
+ /**
219
+ * User requested
220
+ * @type {Discord.GuildMember?}
221
+ */
222
+ this.member = member;
223
+ /**
224
+ * User requested
225
+ * @type {Discord.User?}
226
+ */
227
+ this.user = member === null || member === void 0 ? void 0 : member.user;
228
+ return this;
229
+ }
230
+ /**
231
+ * @param {*} metadata Metadata
232
+ * @private
233
+ * @returns {Song}
234
+ */
235
+ _patchMetadata(metadata) {
236
+ this.metadata = metadata;
224
237
  return this;
225
238
  }
226
239
  }
227
240
  exports.Song = Song;
228
- exports.default = Song;
229
241
  //# sourceMappingURL=Song.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Song.js","sourceRoot":"","sources":["../../src/struct/Song.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAkC;AAClC,0BAAyE;AAKzE;;;;;;;;GAQG;AACH,MAAa,IAAI;IAyBf;;;;;OAKG;IACH,YACE,IAAuE,EACvE,MAAoB,EACpB,MAAM,GAAG,SAAS;;QAElB,IACE,OAAO,MAAM,KAAK,QAAQ;YAC1B,CAAE,IAAsB,CAAC,GAAG,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IACtC,CAAC;IAED;;;;;OAKG;IACH,cAAc,CAAC,QAAkB,EAAE,MAAoB;QACrD,IAAI,CAAC,CAAC,QAAQ,YAAY,kBAAQ,CAAC;YAAE,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAE9G;;;WAGG;QACH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,MAAoB;QAC/B,IAAI,MAAM,EAAE;YACV;;;eAGG;YACH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB;;;eAGG;YACH,IAAI,CAAC,IAAI,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC;SAC1B;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA3OD,oBA2OC;AAED,kBAAe,IAAI,CAAC","sourcesContent":["import Playlist from \"./Playlist\";\nimport { DisTubeError, formatDuration, parseNumber, toSecond } from \"..\";\nimport type ytdl from \"@distube/ytdl-core\";\nimport type { GuildMember, User } from \"discord.js\";\nimport type { Chapter, OtherSongInfo, SearchResult } from \"..\";\n\n/**\n * Class representing a song.\n *\n * <info>If {@link Song} is added from a YouTube {@link SearchResult} or {@link Playlist},\n * some info will be missing to save your resources. It will be filled when emitting {@link DisTube#playSong} event.\n *\n * Missing info: {@link Song#likes}, {@link Song#dislikes}, {@link Song#streamURL},\n * {@link Song#related}, {@link Song#chapters}, {@link Song#age_restricted}</info>\n */\nexport class Song {\n source: string;\n formats?: ytdl.videoFormat[];\n member?: GuildMember;\n user?: User;\n id?: string;\n name?: string;\n isLive!: boolean;\n duration!: number;\n formattedDuration?: string;\n url!: string;\n streamURL?: string;\n thumbnail?: string;\n related!: Song[];\n views!: number;\n likes!: number;\n dislikes!: number;\n uploader!: {\n name?: string;\n url?: string;\n };\n age_restricted!: boolean;\n chapters!: Chapter[];\n reposts!: number;\n playlist?: Playlist;\n /**\n * Create a Song\n * @param {ytdl.videoInfo|SearchResult|OtherSongInfo} info Raw info\n * @param {Discord.GuildMember?} member Requested user\n * @param {string} source Song source\n */\n constructor(\n info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo,\n member?: GuildMember,\n source = \"youtube\",\n ) {\n if (\n typeof source !== \"string\" ||\n ((info as OtherSongInfo).src && typeof (info as OtherSongInfo).src !== \"string\")\n ) {\n throw new DisTubeError(\"INVALID_TYPE\", \"string\", source, \"source\");\n }\n /**\n * The source of the song\n * @type {string}\n */\n this.source = ((info as OtherSongInfo)?.src || source).toLowerCase();\n this._patchMember(member);\n if (this.source === \"youtube\") {\n this._patchYouTube(info as ytdl.videoInfo);\n } else {\n this._patchOther(info as OtherSongInfo);\n }\n }\n\n _patchYouTube(i: ytdl.videoInfo | SearchResult) {\n // FIXME\n const info = i as any;\n if ((info as any).full === true) {\n /**\n * Stream formats (Available if the song is from YouTube and playing)\n * @type {ytdl.videoFormat[]?}\n * @private\n */\n this.formats = info.formats;\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports\n const err = require(\"@distube/ytdl-core/lib/utils\").playError(info.player_response, [\n \"UNPLAYABLE\",\n \"LIVE_STREAM_OFFLINE\",\n \"LOGIN_REQUIRED\",\n ]);\n if (err) throw err;\n\n if (!info.formats?.length) throw new DisTubeError(\"UNAVAILABLE_VIDEO\");\n }\n const details = info.videoDetails || info;\n /**\n * YouTube video id\n * @type {string?}\n */\n this.id = details.videoId || details.id;\n /**\n * Song name aka video title.\n * @type {string?}\n */\n this.name = details.title || details.name;\n /**\n * Indicates if the video is an active live.\n * @type {boolean}\n */\n this.isLive = !!details.isLive;\n /**\n * Song duration.\n * @type {number}\n */\n this.duration = this.isLive ? 0 : toSecond(details.lengthSeconds || details.length_seconds || details.duration);\n /**\n * Formatted duration string (`hh:mm:ss`, `mm:ss` or `Live`).\n * @type {string?}\n */\n this.formattedDuration = this.isLive ? \"Live\" : formatDuration(this.duration);\n /**\n * Song URL.\n * @type {string}\n */\n this.url = `https://www.youtube.com/watch?v=${this.id}`;\n /**\n * Stream / Download URL (Available if the song is playing)\n * @type {string?}\n */\n this.streamURL = undefined;\n /**\n * Song thumbnail.\n * @type {string?}\n */\n this.thumbnail =\n details.thumbnails?.sort((a: any, b: any) => b.width - a.width)[0].url ||\n details.thumbnail?.url ||\n details.thumbnail;\n /**\n * Related songs\n * @type {Song[]}\n */\n this.related = info?.related_videos?.map((v: any) => new Song(v)) || details.related || [];\n /**\n * Song views count\n * @type {number}\n */\n this.views = parseNumber(details.viewCount || details.view_count || details.views);\n /**\n * Song like count\n * @type {number}\n */\n this.likes = parseNumber(details.likes);\n /**\n * Song dislike count\n * @type {number}\n */\n this.dislikes = parseNumber(details.dislikes);\n /**\n * Song uploader\n * @type {Object}\n * @prop {string?} name Uploader name\n * @prop {string?} url Uploader url\n */\n this.uploader = {\n name: info.uploader?.name || details.author?.name,\n url: info.uploader?.url || details.author?.channel_url || details.author?.url,\n };\n /**\n * Whether or not an age-restricted content\n * @type {boolean}\n */\n this.age_restricted = !!details.age_restricted;\n /**\n * @typedef {Object} Chapter\n * @prop {string} title Chapter title\n * @prop {number} start_time Chapter start time in seconds\n */\n /**\n * Chapters information (YouTube only)\n * @type {Chapter[]}\n */\n this.chapters = details.chapters || [];\n /**\n * Song repost count\n * @type {number}\n */\n this.reposts = 0;\n }\n\n /**\n * Patch data from other source\n * @param {OtherSongInfo} info Video info\n * @private\n */\n private _patchOther(info: OtherSongInfo) {\n if (info.id) this.id = info.id;\n if (info.title) this.name = info.title;\n else if (info.name) this.name = info.name;\n this.isLive = Boolean(info.is_live || info.isLive);\n this.duration = this.isLive ? 0 : toSecond(info._duration_raw || info.duration);\n this.formattedDuration = this.isLive ? \"Live\" : formatDuration(this.duration);\n this.url = info.webpage_url || info.url;\n this.thumbnail = info.thumbnail;\n this.related = info.related || [];\n this.views = parseNumber(info.view_count || info.views);\n this.likes = parseNumber(info.like_count || info.likes);\n this.dislikes = parseNumber(info.dislike_count || info.dislikes);\n this.reposts = parseNumber(info.repost_count || info.reposts);\n this.uploader = {\n name: info.uploader,\n url: info.uploader_url,\n };\n this.age_restricted = info.age_restricted || (!!info.age_limit && parseNumber(info.age_limit) >= 18);\n this.chapters = info.chapters || [];\n }\n\n /**\n * @param {Playlist} playlist Playlist\n * @param {Discord.GuildMember} [member] Requested user\n * @private\n * @returns {Song}\n */\n _patchPlaylist(playlist: Playlist, member?: GuildMember): Song {\n if (!(playlist instanceof Playlist)) throw new DisTubeError(\"INVALID_TYPE\", \"Playlist\", playlist, \"playlist\");\n\n /**\n * The playlist added this song\n * @type {Playlist?}\n */\n this.playlist = playlist;\n return this._patchMember(member);\n }\n\n /**\n * @param {Discord.GuildMember} [member] Requested user\n * @private\n * @returns {Song}\n */\n _patchMember(member?: GuildMember): Song {\n if (member) {\n /**\n * User requested\n * @type {Discord.GuildMember?}\n */\n this.member = member;\n /**\n * User requested\n * @type {Discord.User?}\n */\n this.user = member?.user;\n }\n return this;\n }\n}\n\nexport default Song;\n"]}
1
+ {"version":3,"file":"Song.js","sourceRoot":"","sources":["../../src/struct/Song.ts"],"names":[],"mappings":";;;AAAA,yCAAsC;AACtC,0BAA2F;AAK3F,oDAAoD;AAEpD;;;;;;;;;GASG;AACH,MAAa,IAAI;IAkDf,YACE,IAAuE,EACvE,UAMQ,EAAE,EACV,GAAG,GAAG,SAAS,EACf,IAAQ;;QAER,IAAI,IAAA,oBAAgB,EAAC,OAAO,CAAC,EAAE;YAC7B,OAAO,CAAC,WAAW,CACjB,+EAA+E,EAC/E,oBAAoB,CACrB,CAAC;YACF,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;SACzE;QAED,MAAM,EAAE,MAAM,EAAE,MAA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AG;YACd,IAAI,EAAE,IAAI,CAAC,QAAQ;YACnB,GAAG,EAAE,IAAI,CAAC,YAAY;SACvB,CAAC;QACF,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,cAAc,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,IAAI,IAAA,eAAW,EAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;QACrG,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACH,cAAc,CAAC,QAAkB,EAAE,MAAoB;QACrD,IAAI,CAAC,CAAC,QAAQ,YAAY,mBAAQ,CAAC;YAAE,MAAM,IAAI,gBAAY,CAAC,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;QAE9G;;;WAGG;QACH,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;IAED;;;;OAIG;IACH,YAAY,CAAC,MAAoB;QAC/B;;;WAGG;QACH,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB;;;WAGG;QACH,IAAI,CAAC,IAAI,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAc,QAAW;QACrC,IAAI,CAAC,QAAQ,GAAG,QAAwB,CAAC;QACzC,OAAO,IAA0B,CAAC;IACpC,CAAC;CACF;AA/RD,oBA+RC","sourcesContent":["import { Playlist } from \"./Playlist\";\nimport { DisTubeError, formatDuration, isMemberInstance, parseNumber, toSecond } from \"..\";\nimport type ytdl from \"@distube/ytdl-core\";\nimport type { GuildMember, User } from \"discord.js\";\nimport type { Chapter, OtherSongInfo, SearchResult } from \"..\";\n\n// TODO: Clean parameters on the next major version.\n\n/**\n * Class representing a song.\n *\n * <info>If {@link Song} is added from a YouTube {@link SearchResult} or {@link Playlist},\n * some info will be missing to save your resources. It will be filled when emitting {@link DisTube#playSong} event.\n *\n * Missing info: {@link Song#likes}, {@link Song#dislikes}, {@link Song#streamURL},\n * {@link Song#related}, {@link Song#chapters}, {@link Song#age_restricted}</info>\n * @template T - The type for the metadata (if any) of the song\n */\nexport class Song<T = unknown> {\n source!: string;\n metadata!: T;\n formats?: ytdl.videoFormat[];\n member?: GuildMember;\n user?: User;\n id?: string;\n name?: string;\n isLive!: boolean;\n duration!: number;\n formattedDuration?: string;\n url!: string;\n streamURL?: string;\n thumbnail?: string;\n related!: Omit<Song, \"related\">[];\n views!: number;\n likes!: number;\n dislikes!: number;\n uploader!: {\n name?: string;\n url?: string;\n };\n age_restricted!: boolean;\n chapters!: Chapter[];\n reposts!: number;\n playlist?: Playlist;\n constructor(info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo);\n /** @deprecated Passing GuildMember for DisTube#Song() is deprecated. */\n constructor(\n info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo,\n member?: GuildMember,\n source?: string,\n metadata?: T,\n );\n /**\n * Create a Song\n * @param {ytdl.videoInfo|SearchResult|OtherSongInfo} info Raw info\n * @param {Object} [options] Optional options\n * @param {Discord.GuildMember} [options.member] Requested user\n * @param {string} [options.source=\"youtube\"] Song source\n * @param {T} [options.metadata] Song metadata\n */\n constructor(\n info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo,\n options?: {\n member?: GuildMember;\n source?: string;\n metadata?: T;\n },\n );\n constructor(\n info: ytdl.videoInfo | SearchResult | OtherSongInfo | ytdl.relatedVideo,\n options:\n | GuildMember\n | {\n member?: GuildMember;\n source?: string;\n metadata?: T;\n } = {},\n src = \"youtube\",\n meta?: T,\n ) {\n if (isMemberInstance(options)) {\n process.emitWarning(\n \"Passing GuildMember for DisTube#Song() is deprecated, read the docs for more.\",\n \"DeprecationWarning\",\n );\n return new Song(info, { member: options, source: src, metadata: meta });\n }\n\n const { member, source, metadata } = Object.assign({ source: \"youtube\" }, options);\n\n if (\n typeof source !== \"string\" ||\n ((info as OtherSongInfo).src && typeof (info as OtherSongInfo).src !== \"string\")\n ) {\n throw new DisTubeError(\"INVALID_TYPE\", \"string\", source, \"source\");\n }\n /**\n * The source of the song\n * @type {string}\n */\n this.source = ((info as OtherSongInfo)?.src || source).toLowerCase();\n this._patchMember(member);\n if (this.source === \"youtube\") {\n this._patchYouTube(info as ytdl.videoInfo);\n } else {\n this._patchOther(info as OtherSongInfo);\n }\n /**\n * Optional metadata that can be used to identify the song.\n * @type {T}\n */\n this.metadata = metadata as T;\n }\n\n _patchYouTube(i: ytdl.videoInfo | SearchResult) {\n // FIXME\n const info = i as any;\n if ((info as any).full === true) {\n /**\n * Stream formats (Available if the song is from YouTube and playing)\n * @type {ytdl.videoFormat[]?}\n * @private\n */\n this.formats = info.formats;\n // eslint-disable-next-line @typescript-eslint/no-var-requires, @typescript-eslint/no-require-imports\n const err = require(\"@distube/ytdl-core/lib/utils\").playError(info.player_response, [\n \"UNPLAYABLE\",\n \"LIVE_STREAM_OFFLINE\",\n \"LOGIN_REQUIRED\",\n ]);\n if (err) throw err;\n\n if (!info.formats?.length) throw new DisTubeError(\"UNAVAILABLE_VIDEO\");\n }\n const details = info.videoDetails || info;\n /**\n * YouTube video id\n * @type {string?}\n */\n this.id = details.videoId || details.id;\n /**\n * Song name aka video title.\n * @type {string?}\n */\n this.name = details.title || details.name;\n /**\n * Indicates if the video is an active live.\n * @type {boolean}\n */\n this.isLive = !!details.isLive;\n /**\n * Song duration.\n * @type {number}\n */\n this.duration = this.isLive ? 0 : toSecond(details.lengthSeconds || details.length_seconds || details.duration);\n /**\n * Formatted duration string (`hh:mm:ss`, `mm:ss` or `Live`).\n * @type {string?}\n */\n this.formattedDuration = this.isLive ? \"Live\" : formatDuration(this.duration);\n /**\n * Song URL.\n * @type {string}\n */\n this.url = `https://www.youtube.com/watch?v=${this.id}`;\n /**\n * Stream / Download URL (Available if the song is playing)\n * @type {string?}\n */\n this.streamURL = undefined;\n /**\n * Song thumbnail.\n * @type {string?}\n */\n this.thumbnail =\n details.thumbnails?.sort((a: any, b: any) => b.width - a.width)[0].url ||\n details.thumbnail?.url ||\n details.thumbnail;\n /**\n * Related songs (without {@link Song#related} properties)\n * @type {Song[]}\n */\n this.related =\n info?.related_videos?.map((v: any) => new Song(v, { source: this.source, metadata: this.metadata })) ||\n details.related ||\n [];\n /**\n * Song views count\n * @type {number}\n */\n this.views = parseNumber(details.viewCount || details.view_count || details.views);\n /**\n * Song like count\n * @type {number}\n */\n this.likes = parseNumber(details.likes);\n /**\n * Song dislike count\n * @type {number}\n */\n this.dislikes = parseNumber(details.dislikes);\n /**\n * Song uploader\n * @type {Object}\n * @prop {string?} name Uploader name\n * @prop {string?} url Uploader url\n */\n this.uploader = {\n name: info.uploader?.name || details.author?.name,\n url: info.uploader?.url || details.author?.channel_url || details.author?.url,\n };\n /**\n * Whether or not an age-restricted content\n * @type {boolean}\n */\n this.age_restricted = !!details.age_restricted;\n /**\n * @typedef {Object} Chapter\n * @prop {string} title Chapter title\n * @prop {number} start_time Chapter start time in seconds\n */\n /**\n * Chapters information (YouTube only)\n * @type {Chapter[]}\n */\n this.chapters = details.chapters || [];\n /**\n * Song repost count\n * @type {number}\n */\n this.reposts = 0;\n }\n\n /**\n * Patch data from other source\n * @param {OtherSongInfo} info Video info\n * @private\n */\n _patchOther(info: OtherSongInfo) {\n if (info.id) this.id = info.id;\n if (info.title) this.name = info.title;\n else if (info.name) this.name = info.name;\n this.isLive = Boolean(info.is_live || info.isLive);\n this.duration = this.isLive ? 0 : toSecond(info._duration_raw || info.duration);\n this.formattedDuration = this.isLive ? \"Live\" : formatDuration(this.duration);\n this.url = info.webpage_url || info.url;\n this.thumbnail = info.thumbnail;\n this.related = info.related || [];\n this.views = parseNumber(info.view_count || info.views);\n this.likes = parseNumber(info.like_count || info.likes);\n this.dislikes = parseNumber(info.dislike_count || info.dislikes);\n this.reposts = parseNumber(info.repost_count || info.reposts);\n this.uploader = {\n name: info.uploader,\n url: info.uploader_url,\n };\n this.age_restricted = info.age_restricted || (!!info.age_limit && parseNumber(info.age_limit) >= 18);\n this.chapters = info.chapters || [];\n }\n\n /**\n * @param {Playlist} playlist Playlist\n * @param {Discord.GuildMember} [member] Requested user\n * @private\n * @returns {Song}\n */\n _patchPlaylist(playlist: Playlist, member?: GuildMember) {\n if (!(playlist instanceof Playlist)) throw new DisTubeError(\"INVALID_TYPE\", \"Playlist\", playlist, \"playlist\");\n\n /**\n * The playlist added this song\n * @type {Playlist?}\n */\n this.playlist = playlist;\n return this._patchMember(member);\n }\n\n /**\n * @param {Discord.GuildMember} [member] Requested user\n * @private\n * @returns {Song}\n */\n _patchMember(member?: GuildMember) {\n /**\n * User requested\n * @type {Discord.GuildMember?}\n */\n this.member = member;\n /**\n * User requested\n * @type {Discord.User?}\n */\n this.user = member?.user;\n return this;\n }\n\n /**\n * @param {*} metadata Metadata\n * @private\n * @returns {Song}\n */\n _patchMetadata<S = unknown>(metadata: S) {\n this.metadata = metadata as unknown as T;\n return this as unknown as Song<S>;\n }\n}\n"]}
@@ -3,12 +3,7 @@
3
3
  * @private
4
4
  */
5
5
  export declare class TaskQueue {
6
- /**
7
- * The task array
8
- * @type {Task[]}
9
- * @private
10
- */
11
- private tasks;
6
+ #private;
12
7
  /**
13
8
  * Waits for last task finished and queues a new task
14
9
  * @param {boolean} [resolveInfo=false] Whether the task is a resolving info task
@@ -1 +1 @@
1
- {"version":3,"file":"TaskQueue.d.ts","sourceRoot":"","sources":["../../src/struct/TaskQueue.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,qBAAa,SAAS;IACpB;;;;OAIG;IACH,OAAO,CAAC,KAAK,CAAc;IAE3B;;;;OAIG;IACI,OAAO,CAAC,WAAW,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAMlD;;OAEG;IACI,OAAO,IAAI,IAAI;IAItB;;;OAGG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;;OAGG;IACH,IAAW,cAAc,IAAI,OAAO,CAEnC;CACF"}
1
+ {"version":3,"file":"TaskQueue.d.ts","sourceRoot":"","sources":["../../src/struct/TaskQueue.ts"],"names":[],"mappings":"AAYA;;;GAGG;AACH,qBAAa,SAAS;;IAQpB;;;;OAIG;IACI,OAAO,CAAC,WAAW,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC;IAMlD;;OAEG;IACI,OAAO,IAAI,IAAI;IAItB;;;OAGG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;IAED;;;OAGG;IACH,IAAW,cAAc,IAAI,OAAO,CAEnC;CACF"}
@@ -1,4 +1,10 @@
1
1
  "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var _TaskQueue_tasks;
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
3
9
  exports.TaskQueue = void 0;
4
10
  class Task {
@@ -20,7 +26,7 @@ class TaskQueue {
20
26
  * @type {Task[]}
21
27
  * @private
22
28
  */
23
- this.tasks = [];
29
+ _TaskQueue_tasks.set(this, []);
24
30
  }
25
31
  /**
26
32
  * Waits for last task finished and queues a new task
@@ -28,8 +34,8 @@ class TaskQueue {
28
34
  * @returns {Promise<void>}
29
35
  */
30
36
  queuing(resolveInfo = false) {
31
- const next = this.remaining ? this.tasks[this.tasks.length - 1].promise : Promise.resolve();
32
- this.tasks.push(new Task(resolveInfo));
37
+ const next = this.remaining ? __classPrivateFieldGet(this, _TaskQueue_tasks, "f")[__classPrivateFieldGet(this, _TaskQueue_tasks, "f").length - 1].promise : Promise.resolve();
38
+ __classPrivateFieldGet(this, _TaskQueue_tasks, "f").push(new Task(resolveInfo));
33
39
  return next;
34
40
  }
35
41
  /**
@@ -37,22 +43,23 @@ class TaskQueue {
37
43
  */
38
44
  resolve() {
39
45
  var _a;
40
- (_a = this.tasks.shift()) === null || _a === void 0 ? void 0 : _a.resolve();
46
+ (_a = __classPrivateFieldGet(this, _TaskQueue_tasks, "f").shift()) === null || _a === void 0 ? void 0 : _a.resolve();
41
47
  }
42
48
  /**
43
49
  * The remaining number of tasks
44
50
  * @type {number}
45
51
  */
46
52
  get remaining() {
47
- return this.tasks.length;
53
+ return __classPrivateFieldGet(this, _TaskQueue_tasks, "f").length;
48
54
  }
49
55
  /**
50
56
  * Whether or not having a resolving info task
51
57
  * @type {boolean}
52
58
  */
53
59
  get hasResolveTask() {
54
- return !!this.tasks.find(t => t.resolveInfo);
60
+ return !!__classPrivateFieldGet(this, _TaskQueue_tasks, "f").find(t => t.resolveInfo);
55
61
  }
56
62
  }
57
63
  exports.TaskQueue = TaskQueue;
64
+ _TaskQueue_tasks = new WeakMap();
58
65
  //# sourceMappingURL=TaskQueue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaskQueue.js","sourceRoot":"","sources":["../../src/struct/TaskQueue.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI;IAIR,YAAY,WAAoB;QAC9B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAO,GAAG,CAAC,EAAE;YACrC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;GAGG;AACH,MAAa,SAAS;IAAtB;QACE;;;;WAIG;QACK,UAAK,GAAW,EAAE,CAAC;IAmC7B,CAAC;IAjCC;;;;OAIG;IACI,OAAO,CAAC,WAAW,GAAG,KAAK;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC5F,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACI,OAAO;;QACZ,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,0CAAE,OAAO,EAAE,CAAC;IAChC,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACvB,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAC/C,CAAC;CACF;AAzCD,8BAyCC","sourcesContent":["class Task {\n resolve!: () => void;\n promise: Promise<void>;\n resolveInfo: boolean;\n constructor(resolveInfo: boolean) {\n this.resolveInfo = resolveInfo;\n this.promise = new Promise<void>(res => {\n this.resolve = res;\n });\n }\n}\n\n/**\n * Task queuing system\n * @private\n */\nexport class TaskQueue {\n /**\n * The task array\n * @type {Task[]}\n * @private\n */\n private tasks: Task[] = [];\n\n /**\n * Waits for last task finished and queues a new task\n * @param {boolean} [resolveInfo=false] Whether the task is a resolving info task\n * @returns {Promise<void>}\n */\n public queuing(resolveInfo = false): Promise<void> {\n const next = this.remaining ? this.tasks[this.tasks.length - 1].promise : Promise.resolve();\n this.tasks.push(new Task(resolveInfo));\n return next;\n }\n\n /**\n * Removes the finished task and processes the next task\n */\n public resolve(): void {\n this.tasks.shift()?.resolve();\n }\n\n /**\n * The remaining number of tasks\n * @type {number}\n */\n public get remaining(): number {\n return this.tasks.length;\n }\n\n /**\n * Whether or not having a resolving info task\n * @type {boolean}\n */\n public get hasResolveTask(): boolean {\n return !!this.tasks.find(t => t.resolveInfo);\n }\n}\n"]}
1
+ {"version":3,"file":"TaskQueue.js","sourceRoot":"","sources":["../../src/struct/TaskQueue.ts"],"names":[],"mappings":";;;;;;;;;AAAA,MAAM,IAAI;IAIR,YAAY,WAAoB;QAC9B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,CAAO,GAAG,CAAC,EAAE;YACrC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED;;;GAGG;AACH,MAAa,SAAS;IAAtB;QACE;;;;WAIG;QACH,2BAAiB,EAAE,EAAC;IAmCtB,CAAC;IAjCC;;;;OAIG;IACI,OAAO,CAAC,WAAW,GAAG,KAAK;QAChC,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAA,IAAI,wBAAO,CAAC,uBAAA,IAAI,wBAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;QAC9F,uBAAA,IAAI,wBAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QACxC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACI,OAAO;;QACZ,MAAA,uBAAA,IAAI,wBAAO,CAAC,KAAK,EAAE,0CAAE,OAAO,EAAE,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,IAAW,SAAS;QAClB,OAAO,uBAAA,IAAI,wBAAO,CAAC,MAAM,CAAC;IAC5B,CAAC;IAED;;;OAGG;IACH,IAAW,cAAc;QACvB,OAAO,CAAC,CAAC,uBAAA,IAAI,wBAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;IAChD,CAAC;CACF;AAzCD,8BAyCC","sourcesContent":["class Task {\n resolve!: () => void;\n promise: Promise<void>;\n resolveInfo: boolean;\n constructor(resolveInfo: boolean) {\n this.resolveInfo = resolveInfo;\n this.promise = new Promise<void>(res => {\n this.resolve = res;\n });\n }\n}\n\n/**\n * Task queuing system\n * @private\n */\nexport class TaskQueue {\n /**\n * The task array\n * @type {Task[]}\n * @private\n */\n #tasks: Task[] = [];\n\n /**\n * Waits for last task finished and queues a new task\n * @param {boolean} [resolveInfo=false] Whether the task is a resolving info task\n * @returns {Promise<void>}\n */\n public queuing(resolveInfo = false): Promise<void> {\n const next = this.remaining ? this.#tasks[this.#tasks.length - 1].promise : Promise.resolve();\n this.#tasks.push(new Task(resolveInfo));\n return next;\n }\n\n /**\n * Removes the finished task and processes the next task\n */\n public resolve(): void {\n this.#tasks.shift()?.resolve();\n }\n\n /**\n * The remaining number of tasks\n * @type {number}\n */\n public get remaining(): number {\n return this.#tasks.length;\n }\n\n /**\n * Whether or not having a resolving info task\n * @type {boolean}\n */\n public get hasResolveTask(): boolean {\n return !!this.#tasks.find(t => t.resolveInfo);\n }\n}\n"]}