jsdoc
This commit is contained in:
parent
6e71a9c8b0
commit
ef07e0f3c8
6 changed files with 157 additions and 147 deletions
142
src/Player.ts
142
src/Player.ts
|
@ -91,7 +91,7 @@ export class Player extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Define custom extractor in this player
|
* Define custom extractor in this player
|
||||||
* @param {string} extractorName The extractor name
|
* @param {String} extractorName The extractor name
|
||||||
* @param {any} extractor The extractor itself
|
* @param {any} extractor The extractor itself
|
||||||
*/
|
*/
|
||||||
use(extractorName: string, extractor: any): Player {
|
use(extractorName: string, extractor: any): Player {
|
||||||
|
@ -111,7 +111,7 @@ export class Player extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove existing extractor from this player
|
* Remove existing extractor from this player
|
||||||
* @param {string} extractorName The extractor name
|
* @param {String} extractorName The extractor name
|
||||||
*/
|
*/
|
||||||
unuse(extractorName: string): boolean {
|
unuse(extractorName: string): boolean {
|
||||||
if (!extractorName) throw new PlayerError('Missing extractor name!', 'PlayerExtractorError');
|
if (!extractorName) throw new PlayerError('Missing extractor name!', 'PlayerExtractorError');
|
||||||
|
@ -366,7 +366,7 @@ export class Player extends EventEmitter {
|
||||||
* Play a song
|
* Play a song
|
||||||
* @param {Discord.Message} message The discord.js message object
|
* @param {Discord.Message} message The discord.js message object
|
||||||
* @param {string|Track} query Search query, can be `Player.Track` instance
|
* @param {string|Track} query Search query, can be `Player.Track` instance
|
||||||
* @param {boolean} [firstResult] If it should play the first result
|
* @param {Boolean} [firstResult] If it should play the first result
|
||||||
* @example await player.play(message, "never gonna give you up", true)
|
* @example await player.play(message, "never gonna give you up", true)
|
||||||
*/
|
*/
|
||||||
async play(message: Message, query: string | Track, firstResult?: boolean): Promise<void> {
|
async play(message: Message, query: string | Track, firstResult?: boolean): Promise<void> {
|
||||||
|
@ -501,7 +501,7 @@ export class Player extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* Sets track position
|
* Sets track position
|
||||||
* @param {Discord.Message} message The message object
|
* @param {Discord.Message} message The message object
|
||||||
* @param {number} time Time in ms to set
|
* @param {Number} time Time in ms to set
|
||||||
*/
|
*/
|
||||||
setPosition(message: Message, time: number): Promise<void> {
|
setPosition(message: Message, time: number): Promise<void> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
|
@ -524,7 +524,7 @@ export class Player extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* Sets track position
|
* Sets track position
|
||||||
* @param {Discord.Message} message The message object
|
* @param {Discord.Message} message The message object
|
||||||
* @param {number} time Time in ms to set
|
* @param {Number} time Time in ms to set
|
||||||
*/
|
*/
|
||||||
seek(message: Message, time: number): Promise<void> {
|
seek(message: Message, time: number): Promise<void> {
|
||||||
return this.setPosition(message, time);
|
return this.setPosition(message, time);
|
||||||
|
@ -645,7 +645,7 @@ export class Player extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* Sets music volume
|
* Sets music volume
|
||||||
* @param {Discord.Message} message The message object
|
* @param {Discord.Message} message The message object
|
||||||
* @param {number} percent The volume percentage/amount to set
|
* @param {Number} percent The volume percentage/amount to set
|
||||||
*/
|
*/
|
||||||
setVolume(message: Message, percent: number): boolean {
|
setVolume(message: Message, percent: number): boolean {
|
||||||
const queue = this.getQueue(message);
|
const queue = this.getQueue(message);
|
||||||
|
@ -705,7 +705,7 @@ export class Player extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* Sets repeat mode
|
* Sets repeat mode
|
||||||
* @param {Discord.Message} message The message object
|
* @param {Discord.Message} message The message object
|
||||||
* @param {boolean} enabled If it should enable the repeat mode
|
* @param {Boolean} enabled If it should enable the repeat mode
|
||||||
*/
|
*/
|
||||||
setRepeatMode(message: Message, enabled: boolean): boolean {
|
setRepeatMode(message: Message, enabled: boolean): boolean {
|
||||||
const queue = this.getQueue(message);
|
const queue = this.getQueue(message);
|
||||||
|
@ -722,7 +722,7 @@ export class Player extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* Sets loop mode
|
* Sets loop mode
|
||||||
* @param {Discord.Message} message The message object
|
* @param {Discord.Message} message The message object
|
||||||
* @param {boolean} enabled If it should enable the loop mode
|
* @param {Boolean} enabled If it should enable the loop mode
|
||||||
*/
|
*/
|
||||||
setLoopMode(message: Message, enabled: boolean): boolean {
|
setLoopMode(message: Message, enabled: boolean): boolean {
|
||||||
const queue = this.getQueue(message);
|
const queue = this.getQueue(message);
|
||||||
|
@ -804,7 +804,7 @@ export class Player extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* Returns time code of currently playing song
|
* Returns time code of currently playing song
|
||||||
* @param {Discord.Message} message The message object
|
* @param {Discord.Message} message The message object
|
||||||
* @param {boolean} [queueTime] If it should make the time code of the whole queue
|
* @param {Boolean} [queueTime] If it should make the time code of the whole queue
|
||||||
*/
|
*/
|
||||||
getTimeCode(message: Message, queueTime?: boolean): { current: string; end: string } {
|
getTimeCode(message: Message, queueTime?: boolean): { current: string; end: string } {
|
||||||
const queue = this.getQueue(message);
|
const queue = this.getQueue(message);
|
||||||
|
@ -875,7 +875,7 @@ export class Player extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets lyrics of a song
|
* Gets lyrics of a song
|
||||||
* @param {string} query Search query
|
* @param {String} query Search query
|
||||||
* @example const lyrics = await player.lyrics("alan walker faded")
|
* @example const lyrics = await player.lyrics("alan walker faded")
|
||||||
* message.channel.send(lyrics.lyrics);
|
* message.channel.send(lyrics.lyrics);
|
||||||
*/
|
*/
|
||||||
|
@ -892,7 +892,7 @@ export class Player extends EventEmitter {
|
||||||
/**
|
/**
|
||||||
* Toggle autoplay for youtube streams
|
* Toggle autoplay for youtube streams
|
||||||
* @param {Discord.Message} message The message object
|
* @param {Discord.Message} message The message object
|
||||||
* @param {boolean} enable Enable/Disable autoplay
|
* @param {Boolean} enable Enable/Disable autoplay
|
||||||
*/
|
*/
|
||||||
setAutoPlay(message: Message, enable: boolean): boolean {
|
setAutoPlay(message: Message, enable: boolean): boolean {
|
||||||
const queue = this.getQueue(message);
|
const queue = this.getQueue(message);
|
||||||
|
@ -1199,7 +1199,7 @@ export default Player;
|
||||||
* Emitted when the bot is awaiting search results
|
* Emitted when the bot is awaiting search results
|
||||||
* @event Player#searchResults
|
* @event Player#searchResults
|
||||||
* @param {Discord.Message} message The message
|
* @param {Discord.Message} message The message
|
||||||
* @param {string} query The query
|
* @param {String} query The query
|
||||||
* @param {Track[]} tracks The tracks
|
* @param {Track[]} tracks The tracks
|
||||||
* @param {Discord.Collector} collector The collector
|
* @param {Discord.Collector} collector The collector
|
||||||
*/
|
*/
|
||||||
|
@ -1208,9 +1208,9 @@ export default Player;
|
||||||
* Emitted when the user has sent an invalid response for search results
|
* Emitted when the user has sent an invalid response for search results
|
||||||
* @event Player#searchInvalidResponse
|
* @event Player#searchInvalidResponse
|
||||||
* @param {Discord.Message} message The message
|
* @param {Discord.Message} message The message
|
||||||
* @param {string} query The query
|
* @param {String} query The query
|
||||||
* @param {Track[]} tracks The tracks
|
* @param {Track[]} tracks The tracks
|
||||||
* @param {string} invalidResponse The `invalidResponse` string
|
* @param {String} invalidResponse The `invalidResponse` string
|
||||||
* @param {Discord.MessageCollector} collector The collector
|
* @param {Discord.MessageCollector} collector The collector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1218,7 +1218,7 @@ export default Player;
|
||||||
* Emitted when the bot has stopped awaiting search results (timeout)
|
* Emitted when the bot has stopped awaiting search results (timeout)
|
||||||
* @event Player#searchCancel
|
* @event Player#searchCancel
|
||||||
* @param {Discord.Message} message The message
|
* @param {Discord.Message} message The message
|
||||||
* @param {string} query The query
|
* @param {String} query The query
|
||||||
* @param {Track[]} tracks The tracks
|
* @param {Track[]} tracks The tracks
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1226,7 +1226,7 @@ export default Player;
|
||||||
* Emitted when the bot can't find related results to the query
|
* Emitted when the bot can't find related results to the query
|
||||||
* @event Player#noResults
|
* @event Player#noResults
|
||||||
* @param {Discord.Message} message The message
|
* @param {Discord.Message} message The message
|
||||||
* @param {string} query The query
|
* @param {String} query The query
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1268,7 +1268,7 @@ export default Player;
|
||||||
/**
|
/**
|
||||||
* Emitted when an error is triggered
|
* Emitted when an error is triggered
|
||||||
* @event Player#error
|
* @event Player#error
|
||||||
* @param {string} error It can be `NotConnected`, `UnableToJoin`, `NotPlaying`, `ParseError`, `LiveVideo` or `VideoUnavailable`.
|
* @param {String} error It can be `NotConnected`, `UnableToJoin`, `NotPlaying`, `ParseError`, `LiveVideo` or `VideoUnavailable`.
|
||||||
* @param {Discord.Message} message The message
|
* @param {Discord.Message} message The message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -1285,3 +1285,111 @@ export default Player;
|
||||||
* @param {Object} playlist The playlist data (parsed)
|
* @param {Object} playlist The playlist data (parsed)
|
||||||
* @param {Discord.Message} message The message
|
* @param {Discord.Message} message The message
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} PlayerOptions
|
||||||
|
* @property {Boolean} [leaveOnEnd=false] If it should leave on queue end
|
||||||
|
* @property {Number} [leaveOnEndCooldown=0] Time in ms to wait before executing `leaveOnEnd`
|
||||||
|
* @property {Boolean} [leaveOnStop=false] If it should leave on stop command
|
||||||
|
* @property {Boolean} [leaveOnEmpty=false] If it should leave on empty voice channel
|
||||||
|
* @property {Number} [leaveOnEmptyCooldown=0] Time in ms to wait before executing `leaveOnEmpty`
|
||||||
|
* @property {Boolean} [autoSelfDeaf=false] If it should set the client to `self deaf` mode on joining
|
||||||
|
* @property {Boolean} [enableLive=false] If it should enable live videos support
|
||||||
|
* @property {YTDLDownloadOptions} [ytdlDownloadOptions={}] The download options passed to `ytdl-core`
|
||||||
|
* @property {Boolean} [useSafeSearch=false] If it should use `safe search` method for youtube searches
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {'soundcloud'|'youtube'|'arbitrary'} TrackSource
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} TrackData
|
||||||
|
* @property {String} title The title
|
||||||
|
* @property {String} description The description
|
||||||
|
* @property {String} author The author
|
||||||
|
* @property {String} url The url
|
||||||
|
* @property {String} duration The duration
|
||||||
|
* @property {Number} views The view count
|
||||||
|
* @property {Discord.User} requestedBy The user who requested this track
|
||||||
|
* @property {Boolean} fromPlaylist If this track came from a playlist
|
||||||
|
* @property {TrackSource} [source] The track source
|
||||||
|
* @property {string|Readable} [engine] The stream engine
|
||||||
|
* @property {Boolean} [live=false] If this track is livestream instance
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} QueueFilters
|
||||||
|
* The FFmpeg Filters
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {'soundcloud_track'|'soundcloud_playlist'|'spotify_song'|'spotify_album'|'spotify_playlist'|'youtube_video'|'youtube_playlist'|'vimeo'|'facebook'|'reverbnation'|'attachment'|'youtube_search'} QueryType The query type
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} ExtractorModelData
|
||||||
|
* @property {String} title The title
|
||||||
|
* @property {Number} duration The duration in ms
|
||||||
|
* @property {String} thumbnail The thumbnail url
|
||||||
|
* @property {string|Readable} engine The audio engine
|
||||||
|
* @property {Number} views The views count of this stream
|
||||||
|
* @property {String} author The author
|
||||||
|
* @property {String} description The description
|
||||||
|
* @property {String} url The url
|
||||||
|
* @property {String} [version='0.0.0'] The extractor version
|
||||||
|
* @property {Boolean} [important=false] Mark as important
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} PlayerProgressbarOptions
|
||||||
|
* @property {Boolean} [timecodes] If it should return progres bar with time codes
|
||||||
|
* @property {Boolean} [queue] if it should return the progress bar of the whole queue
|
||||||
|
* @property {Number} [length] The length of progress bar to build
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} LyricsData
|
||||||
|
* @property {String} title The title of the lyrics
|
||||||
|
* @property {Number} id The song id
|
||||||
|
* @property {String} thumbnail The thumbnail
|
||||||
|
* @property {String} image The image
|
||||||
|
* @property {String} url The url
|
||||||
|
* @property {Object} artist The artust info
|
||||||
|
* @property {String} [artist.name] The name of the artist
|
||||||
|
* @property {Number} [artist.id] The ID of the artist
|
||||||
|
* @property {String} [artist.url] The profile link of the artist
|
||||||
|
* @property {String} [artist.image] The artist image url
|
||||||
|
* @property {String?} lyrics The lyrics
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} PlayerStats
|
||||||
|
* @property {Number} uptime The uptime in ms
|
||||||
|
* @property {Number} connections The number of connections
|
||||||
|
* @property {Number} users The number of users
|
||||||
|
* @property {Number} queues The number of queues
|
||||||
|
* @property {Number} extractors The number of custom extractors registered
|
||||||
|
* @property {Object} versions The versions metadata
|
||||||
|
* @property {String} [versions.ffmpeg] The ffmpeg version
|
||||||
|
* @property {String} [versions.node] The node version
|
||||||
|
* @property {String} [versions.v8] The v8 JavaScript engine version
|
||||||
|
* @property {Object} system The system data
|
||||||
|
* @property {String} [system.arch] The system arch
|
||||||
|
* @property {'aix'|'android'|'darwin'|'freebsd'|'linux'|'openbsd'|'sunos'|'win32'|'cygwin'|'netbsd'} [system.platform] The system platform
|
||||||
|
* @property {Number} [system.cpu] The cpu count
|
||||||
|
* @property {Object} [system.memory] The memory info
|
||||||
|
* @property {String} [system.memory.total] The total memory
|
||||||
|
* @property {String} [system.memory.usage] The memory usage
|
||||||
|
* @property {String} [system.memory.rss] The memory usage in RSS
|
||||||
|
* @property {String} [system.memory.arrayBuffers] The memory usage in ArrayBuffers
|
||||||
|
* @property {Number} [system.uptime] The system uptime
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Object} TimeData
|
||||||
|
* @property {Number} days The time in days
|
||||||
|
* @property {Number} hours The time in hours
|
||||||
|
* @property {Number} minutes The time in minutes
|
||||||
|
* @property {Number} seconds The time in seconds
|
||||||
|
*/
|
|
@ -6,13 +6,13 @@ class ExtractorModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for raw Discord Player extractors
|
* Model for raw Discord Player extractors
|
||||||
* @param {string} extractorName Name of the extractor
|
* @param {String} extractorName Name of the extractor
|
||||||
* @param {Object} data Extractor object
|
* @param {Object} data Extractor object
|
||||||
*/
|
*/
|
||||||
constructor(extractorName: string, data: any) {
|
constructor(extractorName: string, data: any) {
|
||||||
/**
|
/**
|
||||||
* The extractor name
|
* The extractor name
|
||||||
* @type {string}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
this.name = extractorName;
|
this.name = extractorName;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class ExtractorModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to handle requests from `Player.play()`
|
* Method to handle requests from `Player.play()`
|
||||||
* @param {string} query Query to handle
|
* @param {String} query Query to handle
|
||||||
*/
|
*/
|
||||||
async handle(query: string): Promise<ExtractorModelData> {
|
async handle(query: string): Promise<ExtractorModelData> {
|
||||||
const data = await this._raw.getInfo(query);
|
const data = await this._raw.getInfo(query);
|
||||||
|
@ -41,7 +41,7 @@ class ExtractorModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method used by Discord Player to validate query with this extractor
|
* Method used by Discord Player to validate query with this extractor
|
||||||
* @param {string} query The query to validate
|
* @param {String} query The query to validate
|
||||||
*/
|
*/
|
||||||
validate(query: string): boolean {
|
validate(query: string): boolean {
|
||||||
return Boolean(this._raw.validate(query));
|
return Boolean(this._raw.validate(query));
|
||||||
|
@ -49,7 +49,7 @@ class ExtractorModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The extractor version
|
* The extractor version
|
||||||
* @type {string}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
get version(): string {
|
get version(): string {
|
||||||
return this._raw.version ?? '0.0.0';
|
return this._raw.version ?? '0.0.0';
|
||||||
|
@ -57,7 +57,7 @@ class ExtractorModel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If player should mark this extractor as important
|
* If player should mark this extractor as important
|
||||||
* @type {boolean}
|
* @type {Boolean}
|
||||||
*/
|
*/
|
||||||
get important(): boolean {
|
get important(): boolean {
|
||||||
return Boolean(this._raw.important);
|
return Boolean(this._raw.important);
|
||||||
|
|
|
@ -78,7 +78,7 @@ export class Queue extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue volume
|
* Queue volume
|
||||||
* @type {number}
|
* @type {Number}
|
||||||
*/
|
*/
|
||||||
this.volume = 100;
|
this.volume = 100;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ export class Queue extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The additional calculated stream time
|
* The additional calculated stream time
|
||||||
* @type {number}
|
* @type {Number}
|
||||||
*/
|
*/
|
||||||
this.additionalStreamTime = 0;
|
this.additionalStreamTime = 0;
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ export class Queue extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculated volume of this queue
|
* Calculated volume of this queue
|
||||||
* @type {number}
|
* @type {Number}
|
||||||
*/
|
*/
|
||||||
get calculatedVolume(): number {
|
get calculatedVolume(): number {
|
||||||
return this.filters.normalizer ? this.volume + 70 : this.volume;
|
return this.filters.normalizer ? this.volume + 70 : this.volume;
|
||||||
|
@ -141,7 +141,7 @@ export class Queue extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Total duration
|
* Total duration
|
||||||
* @type {number}
|
* @type {Number}
|
||||||
*/
|
*/
|
||||||
get totalTime(): number {
|
get totalTime(): number {
|
||||||
return this.tracks.length > 0 ? this.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : 0;
|
return this.tracks.length > 0 ? this.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : 0;
|
||||||
|
@ -149,7 +149,7 @@ export class Queue extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Current stream time
|
* Current stream time
|
||||||
* @type {number}
|
* @type {Number}
|
||||||
*/
|
*/
|
||||||
get currentStreamTime(): number {
|
get currentStreamTime(): number {
|
||||||
return this.voiceConnection?.dispatcher?.streamTime + this.additionalStreamTime || 0;
|
return this.voiceConnection?.dispatcher?.streamTime + this.additionalStreamTime || 0;
|
||||||
|
@ -166,7 +166,7 @@ export class Queue extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns array of all enabled filters
|
* Returns array of all enabled filters
|
||||||
* @type {string[]}
|
* @type {String[]}
|
||||||
*/
|
*/
|
||||||
getFiltersEnabled(): string[] {
|
getFiltersEnabled(): string[] {
|
||||||
const filters: string[] = [];
|
const filters: string[] = [];
|
||||||
|
@ -180,7 +180,7 @@ export class Queue extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all disabled filters
|
* Returns all disabled filters
|
||||||
* @type {string[]}
|
* @type {String[]}
|
||||||
*/
|
*/
|
||||||
getFiltersDisabled(): string[] {
|
getFiltersDisabled(): string[] {
|
||||||
const enabled = this.getFiltersEnabled();
|
const enabled = this.getFiltersEnabled();
|
||||||
|
@ -190,7 +190,7 @@ export class Queue extends EventEmitter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String representation of this Queue
|
* String representation of this Queue
|
||||||
* @type {string}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
toString(): string {
|
toString(): string {
|
||||||
return `<Queue ${this.guildID}>`;
|
return `<Queue ${this.guildID}>`;
|
||||||
|
|
|
@ -12,43 +12,43 @@ export class Track {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Title of this track
|
* Title of this track
|
||||||
* @type {string}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
public title!: string;
|
public title!: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of this track
|
* Description of this track
|
||||||
* @type {string}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
public description!: string;
|
public description!: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Author of this track
|
* Author of this track
|
||||||
* @type {string}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
public author!: string;
|
public author!: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Link of this track
|
* Link of this track
|
||||||
* @type {string}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
public url!: string;
|
public url!: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thumbnail of this track
|
* Thumbnail of this track
|
||||||
* @type {string}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
public thumbnail!: string;
|
public thumbnail!: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Duration of this track
|
* Duration of this track
|
||||||
* @type {string}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
public duration!: string;
|
public duration!: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View count of this track
|
* View count of this track
|
||||||
* @type {number}
|
* @type {Number}
|
||||||
*/
|
*/
|
||||||
public views!: number;
|
public views!: number;
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ export class Track {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If this track belongs to a playlist
|
* If this track belongs to a playlist
|
||||||
* @type {boolean}
|
* @type {Boolean}
|
||||||
*/
|
*/
|
||||||
public fromPlaylist!: boolean;
|
public fromPlaylist!: boolean;
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ export class Track {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The track duration in millisecond
|
* The track duration in millisecond
|
||||||
* @type {number}
|
* @type {Number}
|
||||||
*/
|
*/
|
||||||
get durationMS(): number {
|
get durationMS(): number {
|
||||||
const times = (n: number, t: number) => {
|
const times = (n: number, t: number) => {
|
||||||
|
@ -124,7 +124,7 @@ export class Track {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String representation of this track
|
* String representation of this track
|
||||||
* @type {string}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
toString(): string {
|
toString(): string {
|
||||||
return `${this.title} by ${this.author}`;
|
return `${this.title} by ${this.author}`;
|
||||||
|
|
|
@ -2,18 +2,6 @@ import { downloadOptions } from 'ytdl-core';
|
||||||
import { User } from 'discord.js';
|
import { User } from 'discord.js';
|
||||||
import { Readable, Duplex } from 'stream';
|
import { Readable, Duplex } from 'stream';
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} PlayerOptions
|
|
||||||
* @property {boolean} [leaveOnEnd=false] If it should leave on queue end
|
|
||||||
* @property {number} [leaveOnEndCooldown=0] Time in ms to wait before executing `leaveOnEnd`
|
|
||||||
* @property {boolean} [leaveOnStop=false] If it should leave on stop command
|
|
||||||
* @property {boolean} [leaveOnEmpty=false] If it should leave on empty voice channel
|
|
||||||
* @property {number} [leaveOnEmptyCooldown=0] Time in ms to wait before executing `leaveOnEmpty`
|
|
||||||
* @property {boolean} [autoSelfDeaf=false] If it should set the client to `self deaf` mode on joining
|
|
||||||
* @property {boolean} [enableLive=false] If it should enable live videos support
|
|
||||||
* @property {YTDLDownloadOptions} [ytdlDownloadOptions={}] The download options passed to `ytdl-core`
|
|
||||||
* @property {boolean} [useSafeSearch=false] If it should use `safe search` method for youtube searches
|
|
||||||
*/
|
|
||||||
export interface PlayerOptions {
|
export interface PlayerOptions {
|
||||||
leaveOnEnd?: boolean;
|
leaveOnEnd?: boolean;
|
||||||
leaveOnEndCooldown?: number;
|
leaveOnEndCooldown?: number;
|
||||||
|
@ -28,25 +16,8 @@ export interface PlayerOptions {
|
||||||
|
|
||||||
export type FiltersName = keyof QueueFilters;
|
export type FiltersName = keyof QueueFilters;
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {'soundcloud'|'youtube'|'arbitrary'} TrackSource
|
|
||||||
*/
|
|
||||||
export type TrackSource = 'soundcloud' | 'youtube' | 'arbitrary';
|
export type TrackSource = 'soundcloud' | 'youtube' | 'arbitrary';
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} TrackData
|
|
||||||
* @property {string} title The title
|
|
||||||
* @property {string} description The description
|
|
||||||
* @property {string} author The author
|
|
||||||
* @property {string} url The url
|
|
||||||
* @property {string} duration The duration
|
|
||||||
* @property {number} views The view count
|
|
||||||
* @property {Discord.User} requestedBy The user who requested this track
|
|
||||||
* @property {boolean} fromPlaylist If this track came from a playlist
|
|
||||||
* @property {TrackSource} [source] The track source
|
|
||||||
* @property {string|Readable} [engine] The stream engine
|
|
||||||
* @property {boolean} [live=false] If this track is livestream instance
|
|
||||||
*/
|
|
||||||
export interface TrackData {
|
export interface TrackData {
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
@ -62,10 +33,6 @@ export interface TrackData {
|
||||||
live?: boolean;
|
live?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} QueueFilters
|
|
||||||
* The FFmpeg Filters
|
|
||||||
*/
|
|
||||||
export type QueueFilters = {
|
export type QueueFilters = {
|
||||||
bassboost?: boolean;
|
bassboost?: boolean;
|
||||||
'8D'?: boolean;
|
'8D'?: boolean;
|
||||||
|
@ -97,9 +64,6 @@ export type QueueFilters = {
|
||||||
fadein?: boolean;
|
fadein?: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {'soundcloud_track'|'soundcloud_playlist'|'spotify_song'|'spotify_album'|'spotify_playlist'|'youtube_video'|'youtube_playlist'|'vimeo'|'facebook'|'reverbnation'|'attachment'|'youtube_search'} QueryType The query type
|
|
||||||
*/
|
|
||||||
export type QueryType =
|
export type QueryType =
|
||||||
| 'soundcloud_track'
|
| 'soundcloud_track'
|
||||||
| 'soundcloud_playlist'
|
| 'soundcloud_playlist'
|
||||||
|
@ -114,19 +78,6 @@ export type QueryType =
|
||||||
| 'attachment'
|
| 'attachment'
|
||||||
| 'youtube_search';
|
| 'youtube_search';
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} ExtractorModelData
|
|
||||||
* @property {string} title The title
|
|
||||||
* @property {number} duration The duration in ms
|
|
||||||
* @property {string} thumbnail The thumbnail url
|
|
||||||
* @property {string|Readable} engine The audio engine
|
|
||||||
* @property {number} views The views count of this stream
|
|
||||||
* @property {string} author The author
|
|
||||||
* @property {string} description The description
|
|
||||||
* @property {string} url The url
|
|
||||||
* @property {string} [version='0.0.0'] The extractor version
|
|
||||||
* @property {boolean} [important=false] Mark as important
|
|
||||||
*/
|
|
||||||
export interface ExtractorModelData {
|
export interface ExtractorModelData {
|
||||||
title: string;
|
title: string;
|
||||||
duration: number;
|
duration: number;
|
||||||
|
@ -140,32 +91,12 @@ export interface ExtractorModelData {
|
||||||
important?: boolean;
|
important?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} PlayerProgressbarOptions
|
|
||||||
* @property {boolean} [timecodes] If it should return progres bar with time codes
|
|
||||||
* @property {boolean} [queue] if it should return the progress bar of the whole queue
|
|
||||||
* @property {number} [length] The length of progress bar to build
|
|
||||||
*/
|
|
||||||
export interface PlayerProgressbarOptions {
|
export interface PlayerProgressbarOptions {
|
||||||
timecodes?: boolean;
|
timecodes?: boolean;
|
||||||
queue?: boolean;
|
queue?: boolean;
|
||||||
length?: number;
|
length?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} LyricsData
|
|
||||||
* @property {string} title The title of the lyrics
|
|
||||||
* @property {number} id The song id
|
|
||||||
* @property {string} thumbnail The thumbnail
|
|
||||||
* @property {string} image The image
|
|
||||||
* @property {string} url The url
|
|
||||||
* @property {object} artist The artust info
|
|
||||||
* @property {string} [artist.name] The name of the artist
|
|
||||||
* @property {number} [artist.id] The ID of the artist
|
|
||||||
* @property {string} [artist.url] The profile link of the artist
|
|
||||||
* @property {string} [artist.image] The artist image url
|
|
||||||
* @property {string?} lyrics The lyrics
|
|
||||||
*/
|
|
||||||
export interface LyricsData {
|
export interface LyricsData {
|
||||||
title: string;
|
title: string;
|
||||||
id: number;
|
id: number;
|
||||||
|
@ -181,28 +112,6 @@ export interface LyricsData {
|
||||||
lyrics?: string;
|
lyrics?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} PlayerStats
|
|
||||||
* @property {number} uptime The uptime in ms
|
|
||||||
* @property {number} connections The number of connections
|
|
||||||
* @property {number} users The number of users
|
|
||||||
* @property {number} queues The number of queues
|
|
||||||
* @property {number} extractors The number of custom extractors registered
|
|
||||||
* @property {object} versions The versions metadata
|
|
||||||
* @property {string} [versions.ffmpeg] The ffmpeg version
|
|
||||||
* @property {string} [versions.node] The node version
|
|
||||||
* @property {string} [versions.v8] The v8 JavaScript engine version
|
|
||||||
* @property {object} system The system data
|
|
||||||
* @property {string} [system.arch] The system arch
|
|
||||||
* @property {'aix'|'android'|'darwin'|'freebsd'|'linux'|'openbsd'|'sunos'|'win32'|'cygwin'|'netbsd'} [system.platform] The system platform
|
|
||||||
* @property {number} [system.cpu] The cpu count
|
|
||||||
* @property {object} [system.memory] The memory info
|
|
||||||
* @property {string} [system.memory.total] The total memory
|
|
||||||
* @property {string} [system.memory.usage] The memory usage
|
|
||||||
* @property {string} [system.memory.rss] The memory usage in RSS
|
|
||||||
* @property {string} [system.memory.arrayBuffers] The memory usage in ArrayBuffers
|
|
||||||
* @property {number} [system.uptime] The system uptime
|
|
||||||
*/
|
|
||||||
export interface PlayerStats {
|
export interface PlayerStats {
|
||||||
uptime: number;
|
uptime: number;
|
||||||
connections: number;
|
connections: number;
|
||||||
|
@ -238,13 +147,6 @@ export interface PlayerStats {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {object} TimeData
|
|
||||||
* @property {number} days The time in days
|
|
||||||
* @property {number} hours The time in hours
|
|
||||||
* @property {number} minutes The time in minutes
|
|
||||||
* @property {number} seconds The time in seconds
|
|
||||||
*/
|
|
||||||
export interface TimeData {
|
export interface TimeData {
|
||||||
days: number;
|
days: number;
|
||||||
hours: number;
|
hours: number;
|
||||||
|
|
|
@ -24,7 +24,7 @@ export class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks FFmpeg Version
|
* Checks FFmpeg Version
|
||||||
* @param {boolean} [force] If it should forcefully get the version
|
* @param {Boolean} [force] If it should forcefully get the version
|
||||||
*/
|
*/
|
||||||
static getFFmpegVersion(force?: boolean): string {
|
static getFFmpegVersion(force?: boolean): string {
|
||||||
try {
|
try {
|
||||||
|
@ -38,7 +38,7 @@ export class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks FFmpeg
|
* Checks FFmpeg
|
||||||
* @param {boolean} [force] If it should forcefully get the version
|
* @param {Boolean} [force] If it should forcefully get the version
|
||||||
*/
|
*/
|
||||||
static checkFFmpeg(force?: boolean): boolean {
|
static checkFFmpeg(force?: boolean): boolean {
|
||||||
const version = Util.getFFmpegVersion(force);
|
const version = Util.getFFmpegVersion(force);
|
||||||
|
@ -59,7 +59,7 @@ export class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resolves query type
|
* Resolves query type
|
||||||
* @param {string} query The query
|
* @param {String} query The query
|
||||||
*/
|
*/
|
||||||
static getQueryType(query: string): QueryType {
|
static getQueryType(query: string): QueryType {
|
||||||
if (SoundcloudValidateURL(query) && !query.includes('/sets/')) return 'soundcloud_track';
|
if (SoundcloudValidateURL(query) && !query.includes('/sets/')) return 'soundcloud_track';
|
||||||
|
@ -79,7 +79,7 @@ export class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the given string is url
|
* Checks if the given string is url
|
||||||
* @param {string} str URL to check
|
* @param {String} str URL to check
|
||||||
*/
|
*/
|
||||||
static isURL(str: string): boolean {
|
static isURL(str: string): boolean {
|
||||||
return str.length < 2083 && attachmentRegex.test(str);
|
return str.length < 2083 && attachmentRegex.test(str);
|
||||||
|
@ -87,7 +87,7 @@ export class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns Vimeo ID
|
* Returns Vimeo ID
|
||||||
* @param {string} query Vimeo link
|
* @param {String} query Vimeo link
|
||||||
*/
|
*/
|
||||||
static getVimeoID(query: string): string {
|
static getVimeoID(query: string): string {
|
||||||
return Util.getQueryType(query) === 'vimeo'
|
return Util.getQueryType(query) === 'vimeo'
|
||||||
|
@ -100,7 +100,7 @@ export class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses ms time
|
* Parses ms time
|
||||||
* @param {number} milliseconds Time to parse
|
* @param {Number} milliseconds Time to parse
|
||||||
*/
|
*/
|
||||||
static parseMS(milliseconds: number): TimeData {
|
static parseMS(milliseconds: number): TimeData {
|
||||||
const roundTowardsZero = milliseconds > 0 ? Math.floor : Math.ceil;
|
const roundTowardsZero = milliseconds > 0 ? Math.floor : Math.ceil;
|
||||||
|
@ -125,7 +125,7 @@ export class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes youtube searches
|
* Makes youtube searches
|
||||||
* @param {string} query The query
|
* @param {String} query The query
|
||||||
* @param {any} options Options
|
* @param {any} options Options
|
||||||
* @returns {Promise<Track[]>}
|
* @returns {Promise<Track[]>}
|
||||||
*/
|
*/
|
||||||
|
@ -206,7 +206,7 @@ export class Util {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manage CJS require
|
* Manage CJS require
|
||||||
* @param {string} id id to require
|
* @param {String} id id to require
|
||||||
*/
|
*/
|
||||||
static require(id: string): any {
|
static require(id: string): any {
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in a new issue