⚡ Add message to error event and add collector to invalidResponse
This commit is contained in:
parent
33728658fa
commit
216c654864
1 changed files with 11 additions and 11 deletions
|
@ -187,7 +187,7 @@ class Player extends EventEmitter {
|
||||||
collector.stop()
|
collector.stop()
|
||||||
resolve(track)
|
resolve(track)
|
||||||
} else {
|
} else {
|
||||||
this.emit('searchInvalidResponse', message, query, tracks, content)
|
this.emit('searchInvalidResponse', message, query, tracks, content, collector)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
collector.on('end', (collected, reason) => {
|
collector.on('end', (collected, reason) => {
|
||||||
|
@ -303,7 +303,6 @@ class Player extends EventEmitter {
|
||||||
const track = new Track(playlist.tracks.shift(), message.author)
|
const track = new Track(playlist.tracks.shift(), message.author)
|
||||||
const queue = await this._createQueue(message, track).catch((e) => this.emit('error', message, e))
|
const queue = await this._createQueue(message, track).catch((e) => this.emit('error', message, e))
|
||||||
this._addTracksToQueue(message, playlist.tracks)
|
this._addTracksToQueue(message, playlist.tracks)
|
||||||
this.emit('playlistStart', message, queue, playlist, queue.tracks[0])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +369,7 @@ class Player extends EventEmitter {
|
||||||
resume (message) {
|
resume (message) {
|
||||||
// Get guild queue
|
// Get guild queue
|
||||||
const queue = this.queues.find((g) => g.guildID === message.guild.id)
|
const queue = this.queues.find((g) => g.guildID === message.guild.id)
|
||||||
if (!queue) return this.emit('error', 'NotPlaying')
|
if (!queue) return this.emit('error', message, 'NotPlaying')
|
||||||
// Pause the dispatcher
|
// Pause the dispatcher
|
||||||
queue.voiceConnection.dispatcher.resume()
|
queue.voiceConnection.dispatcher.resume()
|
||||||
queue.paused = false
|
queue.paused = false
|
||||||
|
@ -387,7 +386,7 @@ class Player extends EventEmitter {
|
||||||
stop (message) {
|
stop (message) {
|
||||||
// Get guild queue
|
// Get guild queue
|
||||||
const queue = this.queues.find((g) => g.guildID === message.guild.id)
|
const queue = this.queues.find((g) => g.guildID === message.guild.id)
|
||||||
if (!queue) return this.emit('error', 'NotPlaying')
|
if (!queue) return this.emit('error', message, 'NotPlaying')
|
||||||
// Stop the dispatcher
|
// Stop the dispatcher
|
||||||
queue.stopped = true
|
queue.stopped = true
|
||||||
queue.tracks = []
|
queue.tracks = []
|
||||||
|
@ -408,7 +407,7 @@ class Player extends EventEmitter {
|
||||||
setVolume (message, percent) {
|
setVolume (message, percent) {
|
||||||
// Get guild queue
|
// Get guild queue
|
||||||
const queue = this.queues.get(message.guild.id)
|
const queue = this.queues.get(message.guild.id)
|
||||||
if (!queue) return this.emit('error', 'NotPlaying')
|
if (!queue) return this.emit('error', message, 'NotPlaying')
|
||||||
// Update volume
|
// Update volume
|
||||||
queue.volume = percent
|
queue.volume = percent
|
||||||
queue.voiceConnection.dispatcher.setVolumeLogarithmic(queue.calculatedVolume / 200)
|
queue.voiceConnection.dispatcher.setVolumeLogarithmic(queue.calculatedVolume / 200)
|
||||||
|
@ -435,7 +434,7 @@ class Player extends EventEmitter {
|
||||||
clearQueue (message) {
|
clearQueue (message) {
|
||||||
// Get guild queue
|
// Get guild queue
|
||||||
const queue = this.queues.get(message.guild.id)
|
const queue = this.queues.get(message.guild.id)
|
||||||
if (!queue) return this.emit('error', 'NotPlaying')
|
if (!queue) return this.emit('error', message, 'NotPlaying')
|
||||||
// Clear queue
|
// Clear queue
|
||||||
queue.tracks = []
|
queue.tracks = []
|
||||||
// Return the queue
|
// Return the queue
|
||||||
|
@ -450,7 +449,7 @@ class Player extends EventEmitter {
|
||||||
skip (message) {
|
skip (message) {
|
||||||
// Get guild queue
|
// Get guild queue
|
||||||
const queue = this.queues.get(message.guild.id)
|
const queue = this.queues.get(message.guild.id)
|
||||||
if (!queue) return this.emit('error', 'NotPlaying')
|
if (!queue) return this.emit('error', message, 'NotPlaying')
|
||||||
const currentTrack = queue.playing
|
const currentTrack = queue.playing
|
||||||
// End the dispatcher
|
// End the dispatcher
|
||||||
queue.voiceConnection.dispatcher.end()
|
queue.voiceConnection.dispatcher.end()
|
||||||
|
@ -467,7 +466,7 @@ class Player extends EventEmitter {
|
||||||
nowPlaying (message) {
|
nowPlaying (message) {
|
||||||
// Get guild queue
|
// Get guild queue
|
||||||
const queue = this.queues.get(message.guild.id)
|
const queue = this.queues.get(message.guild.id)
|
||||||
if (!queue) return this.emit('error', 'NotPlaying')
|
if (!queue) return this.emit('error', message, 'NotPlaying')
|
||||||
const currentTrack = queue.tracks[0]
|
const currentTrack = queue.tracks[0]
|
||||||
// Return the current track
|
// Return the current track
|
||||||
return currentTrack
|
return currentTrack
|
||||||
|
@ -482,7 +481,7 @@ class Player extends EventEmitter {
|
||||||
setRepeatMode (message, enabled) {
|
setRepeatMode (message, enabled) {
|
||||||
// Get guild queue
|
// Get guild queue
|
||||||
const queue = this.queues.get(message.guild.id)
|
const queue = this.queues.get(message.guild.id)
|
||||||
if (!queue) return this.emit('error', 'NotPlaying')
|
if (!queue) return this.emit('error', message, 'NotPlaying')
|
||||||
// Enable/Disable repeat mode
|
// Enable/Disable repeat mode
|
||||||
queue.repeatMode = enabled
|
queue.repeatMode = enabled
|
||||||
// Return the repeat mode
|
// Return the repeat mode
|
||||||
|
@ -497,7 +496,7 @@ class Player extends EventEmitter {
|
||||||
shuffle (message) {
|
shuffle (message) {
|
||||||
// Get guild queue
|
// Get guild queue
|
||||||
const queue = this.queues.get(message.guild.id)
|
const queue = this.queues.get(message.guild.id)
|
||||||
if (!queue) return this.emit('error', 'NotPlaying')
|
if (!queue) return this.emit('error', message, 'NotPlaying')
|
||||||
// Shuffle the queue (except the first track)
|
// Shuffle the queue (except the first track)
|
||||||
const currentTrack = queue.tracks.shift()
|
const currentTrack = queue.tracks.shift()
|
||||||
queue.tracks = queue.tracks.sort(() => Math.random() - 0.5)
|
queue.tracks = queue.tracks.sort(() => Math.random() - 0.5)
|
||||||
|
@ -515,7 +514,7 @@ class Player extends EventEmitter {
|
||||||
remove (message, track) {
|
remove (message, track) {
|
||||||
// Get guild queue
|
// Get guild queue
|
||||||
const queue = this.queues.get(message.guild.id)
|
const queue = this.queues.get(message.guild.id)
|
||||||
if (!queue) return this.emit('error', 'NotPlaying')
|
if (!queue) return this.emit('error', message, 'NotPlaying')
|
||||||
// Remove the track from the queue
|
// Remove the track from the queue
|
||||||
let trackFound = null
|
let trackFound = null
|
||||||
if (typeof track === 'number') {
|
if (typeof track === 'number') {
|
||||||
|
@ -725,6 +724,7 @@ module.exports = Player
|
||||||
* @param {string} query
|
* @param {string} query
|
||||||
* @param {Track[]} tracks
|
* @param {Track[]} tracks
|
||||||
* @param {string} invalidResponse
|
* @param {string} invalidResponse
|
||||||
|
* @param {Discord.MessageCollector} collector
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue