From ea4dc26671d08f49beba7ae79b78f888c5bd34c9 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Sun, 9 May 2021 18:19:25 +0545 Subject: [PATCH] jsdoc --- src/Player.ts | 53 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 4 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index 1c55cc5..ed2bf8e 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -131,6 +131,14 @@ export class Player extends EventEmitter { return this.Extractors.delete(extractorName); } + /** + * Internal method to search tracks + * @param {DiscordMessage} message The message + * @param {string} query The query + * @param {boolean} [firstResult=false] If it should return the first result + * @returns {Promise} + * @private + */ private _searchTracks(message: Message, query: string, firstResult?: boolean): Promise { return new Promise(async (resolve) => { let tracks: Track[] = []; @@ -379,7 +387,7 @@ export class Player extends EventEmitter { * Play a song * @param {DiscordMessage} message The discord.js message object * @param {string|Track} query Search query, can be `Player.Track` instance - * @param {Boolean} [firstResult] If it should play the first result + * @param {Boolean} [firstResult=false] If it should play the first result * @example await player.play(message, "never gonna give you up", true) * @returns {Promise} */ @@ -990,6 +998,13 @@ export class Player extends EventEmitter { return this.skip(message); } + /** + * Internal method to handle VoiceStateUpdate events + * @param {DiscordVoiceState} oldState The old voice state + * @param {DiscordVoiceState} newState The new voice state + * @returns {void} + * @private + */ private _handleVoiceStateUpdate(oldState: VoiceState, newState: VoiceState): void { const queue = this.queues.find((g) => g.guildID === oldState.guild.id); if (!queue) return; @@ -1023,7 +1038,14 @@ export class Player extends EventEmitter { } } - private _addTrackToQueue(message: Message, track: Track): Queue { + /** + * Internal method used to add tracks to the queue + * @param {DiscordMessage} message The discord message + * @param {Track} track The track + * @returns {Queue} + * @private + */ + _addTrackToQueue(message: Message, track: Track): Queue { const queue = this.getQueue(message); if (!queue) this.emit( @@ -1037,7 +1059,14 @@ export class Player extends EventEmitter { return queue; } - private _addTracksToQueue(message: Message, tracks: Track[]): Queue { + /** + * Same as `_addTrackToQueue` but used for multiple tracks + * @param {DiscordMessage} message Discord message + * @param {Track[]} tracks The tracks + * @returns {Queue} + * @private + */ + _addTracksToQueue(message: Message, tracks: Track[]): Queue { const queue = this.getQueue(message); if (!queue) throw new PlayerError( @@ -1085,6 +1114,13 @@ export class Player extends EventEmitter { }); } + /** + * Internal method used to init stream playing + * @param {Queue} queue The queue + * @param {boolean} firstPlay If this is a first play + * @returns {Promise} + * @private + */ private async _playTrack(queue: Queue, firstPlay: boolean): Promise { if (queue.stopped) return; @@ -1139,6 +1175,14 @@ export class Player extends EventEmitter { }); } + /** + * Internal method to play audio + * @param {Queue} queue The queue + * @param {boolean} updateFilter If this method was called for audio filter update + * @param {number} [seek] Time in ms to seek to + * @returns {Promise} + * @private + */ private _playStream(queue: Queue, updateFilter: boolean, seek?: number): Promise { return new Promise(async (resolve) => { const ffmpeg = Util.checkFFmpeg(); @@ -1323,7 +1367,8 @@ export default Player; */ /** - * Emitted when an error is triggered + * Emitted when an error is triggered. + * This event should handled properly by the users otherwise it might crash the process! * @event Player#error * @param {String} error It can be `NotConnected`, `UnableToJoin`, `NotPlaying`, `ParseError`, `LiveVideo` or `VideoUnavailable`. * @param {DiscordMessage} message The message