From cd2ac779d94f024b8968b7aaf82eaab747b5b2e5 Mon Sep 17 00:00:00 2001 From: Casper Date: Sun, 28 Feb 2021 08:20:20 +0100 Subject: [PATCH] add missing types & docs (#308) --- src/Queue.js | 16 ++++++++++++++++ typings/index.d.ts | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/Queue.js b/src/Queue.js index a800a99..5b2442d 100644 --- a/src/Queue.js +++ b/src/Queue.js @@ -90,18 +90,34 @@ class Queue extends EventEmitter { this.firstMessage = message } + /** + * The current playing track + * @type {Track} + */ get playing () { return this.tracks[0] } + /** + * The calculated volume of the queue + * @type {number} + */ get calculatedVolume () { return this.filters.bassboost ? this.volume + 50 : this.volume } + /** + * Returns the total time of the queue in milliseconds + * @type {number} + */ get totalTime () { return this.tracks.length > 0 ? this.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : 0 } + /** + * The current stream time + * @type {number} + */ get currentStreamTime () { return this.voiceConnection.dispatcher ? this.voiceConnection.dispatcher.streamTime + this.additionalStreamTime diff --git a/typings/index.d.ts b/typings/index.d.ts index 4b1fc7f..8842fe1 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -115,7 +115,7 @@ declare module 'discord-player' { requestedBy: User; } type Playlist = YTSRPlaylist & CustomPlaylist; - type PlayerError = 'NotConnected' | 'UnableToJoin' | 'NotPlaying' | 'LiveVideo' | 'ParseError' | 'VideoUnavailable'; + type PlayerError = 'NotConnected' | 'UnableToJoin' | 'NotPlaying' | 'LiveVideo' | 'ParseError' | 'VideoUnavailable' | 'MusicStarting'; interface PlayerEvents { searchResults: [Message, string, Track[]]; searchInvalidResponse: [Message, string, Track[], string, MessageCollector]; @@ -155,6 +155,7 @@ declare module 'discord-player' { public playing: Track; public calculatedVolume: number; public currentStreamTime: number; + public totalTime: number; } class Track { constructor(videoData: object, user: User, player: Player);