discord-player
Advanced tools
Comparing version 3.3.2 to 3.4.0
{ | ||
"name": "discord-player", | ||
"version": "3.3.2", | ||
"version": "3.4.0", | ||
"description": "Complete framework to facilitate music commands using discord.js v12", | ||
@@ -34,3 +34,3 @@ "main": "index.js", | ||
"chalk": "^4.1.0", | ||
"discord-ytdl-core": "^5.0.0", | ||
"discord-ytdl-core": "^5.0.1", | ||
"jsdom": "^16.4.0", | ||
@@ -43,3 +43,3 @@ "merge-options": "^3.0.4", | ||
"spotify-url-info": "^2.2.0", | ||
"youtube-sr": "^4.0.0", | ||
"youtube-sr": "^4.0.2", | ||
"ytdl-core": "^4.5.0" | ||
@@ -46,0 +46,0 @@ }, |
@@ -6,3 +6,3 @@ # Discord Player | ||
**Note**: this module uses recent discordjs features and requires discord.js version 12. | ||
**Note**: this module uses recent discordjs features and requires discord.js version 12 and Node.js 14. | ||
@@ -9,0 +9,0 @@ Discord Player is a powerful [Node.js](https://nodejs.org) module that allows you to easily implement music commands. **Everything** is customizable, and everything is done to simplify your work **without limiting you**! It doesn't require any api key, as it uses **scraping**. |
@@ -455,2 +455,3 @@ const ytdl = require('discord-ytdl-core') | ||
* @param {Discord.VoiceChannel} channel Voice channel | ||
* @returns {boolean} Whether it succeed or not | ||
*/ | ||
@@ -460,3 +461,10 @@ moveTo (message, channel) { | ||
const queue = this.queues.find((g) => g.guildID === message.guild.id) | ||
if (!queue) return this.emit('error', 'NotPlaying', message) | ||
if (!queue) { | ||
this.emit('error', 'NotPlaying', message) | ||
return false | ||
} | ||
if (!queue.voiceConnection || !queue.voiceConnection.dispatcher) { | ||
this.emit('error', 'MusicStarting', message) | ||
return false | ||
} | ||
if (queue.voiceConnection.channel.id === channel.id) return | ||
@@ -468,2 +476,4 @@ | ||
.catch(() => this.emit('error', 'UnableToJoin', message)) | ||
return true | ||
} | ||
@@ -551,2 +561,3 @@ | ||
const queue = await this._createQueue(message, track).catch((e) => this.emit('error', e, message)) | ||
this.emit('playlistAdd', message, queue, playlist) | ||
this.emit('trackStart', message, queue.tracks[0], queue) | ||
@@ -761,2 +772,3 @@ this._addTracksToQueue(message, playlist.tracks) | ||
* @param {Discord.Message} message | ||
* @returns {boolean} Whether it succeed or not | ||
* @example | ||
@@ -768,6 +780,14 @@ * client.player.pause(message); | ||
const queue = this.queues.find((g) => g.guildID === message.guild.id) | ||
if (!queue) return this.emit('error', 'NotPlaying', message) | ||
if (!queue) { | ||
this.emit('error', 'NotPlaying', message) | ||
return false | ||
} | ||
if (!queue.voiceConnection || !queue.voiceConnection.dispatcher) { | ||
this.emit('error', 'MusicStarting', message) | ||
return false | ||
} | ||
// Pause the dispatcher | ||
queue.voiceConnection.dispatcher.pause() | ||
queue.paused = true | ||
return true | ||
} | ||
@@ -778,2 +798,3 @@ | ||
* @param {Discord.Message} message | ||
* @returns {boolean} Whether it succeed or not | ||
* @example | ||
@@ -785,6 +806,14 @@ * client.player.resume(message); | ||
const queue = this.queues.find((g) => g.guildID === message.guild.id) | ||
if (!queue) return this.emit('error', 'NotPlaying', message) | ||
if (!queue) { | ||
this.emit('error', 'NotPlaying', message) | ||
return false | ||
} | ||
if (!queue.voiceConnection || !queue.voiceConnection.dispatcher) { | ||
this.emit('error', 'MusicStarting', message) | ||
return false | ||
} | ||
// Resume the dispatcher | ||
queue.voiceConnection.dispatcher.resume() | ||
queue.paused = false | ||
return true | ||
} | ||
@@ -795,2 +824,3 @@ | ||
* @param {Discord.Message} message | ||
* @returns {boolean} Whether it succeed or not | ||
* @example | ||
@@ -802,3 +832,10 @@ * client.player.stop(message); | ||
const queue = this.queues.find((g) => g.guildID === message.guild.id) | ||
if (!queue) return this.emit('error', 'NotPlaying', message) | ||
if (!queue) { | ||
this.emit('error', 'NotPlaying', message) | ||
return false | ||
} | ||
if (!queue.voiceConnection || !queue.voiceConnection.dispatcher) { | ||
this.emit('error', 'MusicStarting', message) | ||
return false | ||
} | ||
// Stop the dispatcher | ||
@@ -811,2 +848,3 @@ queue.stopped = true | ||
this.queues.delete(message.guild.id) | ||
return true | ||
} | ||
@@ -818,2 +856,3 @@ | ||
* @param {number} percent | ||
* @returns {boolean} Whether it succeed or not | ||
* @example | ||
@@ -825,6 +864,14 @@ * client.player.setVolume(message, 90); | ||
const queue = this.queues.get(message.guild.id) | ||
if (!queue) return this.emit('error', 'NotPlaying', message) | ||
if (!queue) { | ||
this.emit('error', 'NotPlaying', message) | ||
return false | ||
} | ||
if (!queue.voiceConnection || !queue.voiceConnection.dispatcher) { | ||
this.emit('error', 'MusicStarting', message) | ||
return false | ||
} | ||
// Update volume | ||
queue.volume = percent | ||
queue.voiceConnection.dispatcher.setVolumeLogarithmic(queue.calculatedVolume / 200) | ||
return true | ||
} | ||
@@ -858,3 +905,3 @@ | ||
* @param {Discord.Message} message | ||
* @returns {Queue} | ||
* @returns {boolean} Whether it succeed or not | ||
*/ | ||
@@ -864,4 +911,10 @@ skip (message) { | ||
const queue = this.queues.get(message.guild.id) | ||
if (!queue) return this.emit('error', 'NotPlaying', message) | ||
const currentTrack = queue.playing | ||
if (!queue) { | ||
this.emit('error', 'NotPlaying', message) | ||
return false | ||
} | ||
if (!queue.voiceConnection || !queue.voiceConnection.dispatcher) { | ||
this.emit('error', 'MusicStarting', message) | ||
return false | ||
} | ||
// End the dispatcher | ||
@@ -871,3 +924,3 @@ queue.voiceConnection.dispatcher.end() | ||
// Return the queue | ||
return queue | ||
return true | ||
} | ||
@@ -878,3 +931,3 @@ | ||
* @param {Discord.Message} message | ||
* @returns {Queue} | ||
* @returns {boolean} Whether it succeed or not | ||
*/ | ||
@@ -884,3 +937,10 @@ back (message) { | ||
const queue = this.queues.get(message.guild.id) | ||
if (!queue) return this.emit('error', 'NotPlaying', message) | ||
if (!queue) { | ||
this.emit('error', 'NotPlaying', message) | ||
return false | ||
} | ||
if (!queue.voiceConnection || !queue.voiceConnection.dispatcher) { | ||
this.emit('error', 'MusicStarting', message) | ||
return false | ||
} | ||
queue.tracks.splice(1, 0, queue.previousTracks.shift()) | ||
@@ -891,3 +951,3 @@ // End the dispatcher | ||
// Return the queue | ||
return queue | ||
return true | ||
} | ||
@@ -1007,3 +1067,3 @@ | ||
// Total stream time | ||
const totalTracksTime = queue.tracks.length > 0 ? queue.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : 0 | ||
const totalTracksTime = queue.totalTime | ||
const totalTime = options && options.queue ? previousTracksTime + totalTracksTime : queue.playing.durationMS | ||
@@ -1141,3 +1201,3 @@ // Stream progress | ||
if (error.message.includes('Video unavailable')) { | ||
this.emit('error', 'VideoUnavailable', queue.firstMessage) | ||
this.emit('error', 'VideoUnavailable', queue.firstMessage, queue.playing) | ||
this._playTrack(queue, false) | ||
@@ -1144,0 +1204,0 @@ } else { |
@@ -101,2 +101,6 @@ const Discord = require('discord.js') | ||
get totalTime () { | ||
return this.tracks.length > 0 ? this.tracks.map((t) => t.durationMS).reduce((p, c) => p + c) : 0 | ||
} | ||
get currentStreamTime () { | ||
@@ -103,0 +107,0 @@ return this.voiceConnection.dispatcher |
@@ -33,4 +33,4 @@ declare module 'discord-player' { | ||
public isPlaying(message: Message): boolean; | ||
public setFilters(message: Message, newFilters: Partial<Filters>): Promise<void>; | ||
public play(message: Message, query: string | Track, firstResult?: boolean): Promise<void>; | ||
public setFilters(message: Message, newFilters: Partial<FiltersOption>): Promise<void>; | ||
public play(message: Message, query: string | Track, firstResult?: boolean, isAttachment?: boolean): Promise<void>; | ||
public pause(message: Message): void; | ||
@@ -49,3 +49,3 @@ public resume(message: Message): void; | ||
public remove(message: Message, trackOrPosition: Track | number): Track; | ||
public createProgressBar(message: Message, progressBarOptions: ProgressBarOptions): string; | ||
public createProgressBar(message: Message, progressBarOptions?: ProgressBarOptions): string; | ||
public seek(message: Message, time: number): Promise<void>; | ||
@@ -103,2 +103,5 @@ public moveTo(message: Message, channel: VoiceChannel): void; | ||
} | ||
type FiltersOption = { | ||
[key in Filters]: boolean; | ||
} | ||
type PlayerFilters = { | ||
@@ -108,4 +111,4 @@ [key in Filters]: string | ||
interface ProgressBarOptions { | ||
timecodes: boolean; | ||
queue: boolean; | ||
timecodes?: boolean; | ||
queue?: boolean; | ||
} | ||
@@ -112,0 +115,0 @@ interface CustomPlaylist { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
90777
2067
Updateddiscord-ytdl-core@^5.0.1
Updatedyoutube-sr@^4.0.2