add missing types & docs (#308)

This commit is contained in:
Casper 2021-02-28 08:20:20 +01:00 committed by GitHub
parent bc2f44520d
commit cd2ac779d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View file

@ -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

3
typings/index.d.ts vendored
View file

@ -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);