diff --git a/src/Player.ts b/src/Player.ts index 106aa0b..133c3bb 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -2,7 +2,7 @@ import { Client, Collection, GuildResolvable, Snowflake, User, VoiceState } from import { TypedEmitter as EventEmitter } from "tiny-typed-emitter"; import { Queue } from "./Structures/Queue"; import { VoiceUtils } from "./VoiceInterface/VoiceUtils"; -import { PlayerEvents, PlayerOptions, QueryType, SearchOptions, DiscordPlayerInitOptions } from "./types/types"; +import { PlayerEvents, PlayerOptions, QueryType, SearchOptions, PlayerInitOptions } from "./types/types"; import Track from "./Structures/Track"; import { QueryResolver } from "./utils/QueryResolver"; import YouTube from "youtube-sr"; @@ -19,7 +19,7 @@ const soundcloud = new SoundCloud(); class Player extends EventEmitter { public readonly client: Client; - public readonly options: DiscordPlayerInitOptions = { + public readonly options: PlayerInitOptions = { autoRegisterExtractor: true, ytdlOptions: {} }; @@ -30,9 +30,9 @@ class Player extends EventEmitter { /** * Creates new Discord Player * @param {Client} client The Discord Client - * @param {DiscordPlayerInitOptions} [options={}] The player init options + * @param {PlayerInitOptions} [options={}] The player init options */ - constructor(client: Client, options: DiscordPlayerInitOptions = {}) { + constructor(client: Client, options: PlayerInitOptions = {}) { super(); /** diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index 45fb3c2..aa32660 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -522,20 +522,16 @@ class Queue { /** * Returns player stream timestamp - * @param {boolean} [queue=false] If it should generate timestamp for the queue * @returns {PlayerTimestamp} */ - getPlayerTimestamp(queue = false) { + getPlayerTimestamp() { this.#watchDestroyed(); - const previousTracksTime = this.previousTracks.length > 0 ? this.previousTracks.reduce((p, c) => p + c.durationMS, 0) : 0; - const currentStreamTime = queue ? previousTracksTime + this.streamTime : this.streamTime; - const totalTracksTime = this.totalTime; - const totalTime = queue ? previousTracksTime + totalTracksTime : this.current.durationMS; + const currentStreamTime = this.streamTime; + const totalTime = this.current.durationMS; const currentTimecode = Util.buildTimeCode(Util.parseMS(currentStreamTime)); const endTimecode = Util.buildTimeCode(Util.parseMS(totalTime)); - // why return { current: currentTimecode, end: endTimecode, @@ -548,15 +544,11 @@ class Queue { * @param {PlayerProgressbarOptions} options The progress bar options * @returns {string} */ - createProgressBar(options: PlayerProgressbarOptions = { timecodes: true, queue: false }) { + createProgressBar(options: PlayerProgressbarOptions = { timecodes: true }) { this.#watchDestroyed(); - const previousTracksTime = this.previousTracks.length > 0 ? this.previousTracks.reduce((p, c) => p + c.durationMS, 0) : 0; - const currentStreamTime = options.queue ? previousTracksTime + this.streamTime : this.streamTime; - const totalTracksTime = this.totalTime; - const totalTime = options.queue ? previousTracksTime + totalTracksTime : this.current.durationMS; const length = typeof options.length === "number" ? (options.length <= 0 || options.length === Infinity ? 15 : options.length) : 15; - const index = Math.round((currentStreamTime / totalTime) * length); + const index = Math.round((this.streamTime / this.current.durationMS) * length); const indicator = typeof options.indicator === "string" && options.indicator.length > 0 ? options.indicator : "🔘"; const line = typeof options.line === "string" && options.line.length > 0 ? options.line : "▬"; @@ -564,14 +556,14 @@ class Queue { const bar = line.repeat(length - 1).split(""); bar.splice(index, 0, indicator); if (options.timecodes) { - const timestamp = this.getPlayerTimestamp(options.queue); + const timestamp = this.getPlayerTimestamp(); return `${timestamp.current} ┃ ${bar.join("")} ┃ ${timestamp.end}`; } else { return `${bar.join("")}`; } } else { if (options.timecodes) { - const timestamp = this.getPlayerTimestamp(options.queue); + const timestamp = this.getPlayerTimestamp(); return `${timestamp.current} ┃ ${indicator}${line.repeat(length - 1)} ┃ ${timestamp.end}`; } else { return `${indicator}${line.repeat(length - 1)}`; diff --git a/src/types/types.ts b/src/types/types.ts index f37a494..7a40ce2 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -113,7 +113,6 @@ export interface TimeData { */ export interface PlayerProgressbarOptions { timecodes?: boolean; - queue?: boolean; length?: number; line?: string; indicator?: string; @@ -449,11 +448,11 @@ export interface PlaylistJSON { } /** - * @typedef {object} DiscordPlayerInitOptions + * @typedef {object} PlayerInitOptions * @property {boolean} [autoRegisterExtractor=true] If it should automatically register `@discord-player/extractor` * @property {YTDLDownloadOptions} [ytdlOptions={}] The options passed to `ytdl-core` */ -export interface DiscordPlayerInitOptions { +export interface PlayerInitOptions { autoRegisterExtractor?: boolean; ytdlOptions?: downloadOptions; }