🥅 Add video unavailable error
This commit is contained in:
parent
35fd4e663b
commit
d79c39949d
3 changed files with 12 additions and 3 deletions
|
@ -161,6 +161,9 @@ client.player
|
|||
case 'LiveVideo':
|
||||
message.channel.send('YouTube lives are not supported!')
|
||||
break;
|
||||
case 'VideoUnavailable':
|
||||
message.channel.send('This YouTube video is not available!');
|
||||
break;
|
||||
default:
|
||||
message.channel.send(`Something went wrong... Error: ${error}`)
|
||||
}
|
||||
|
|
|
@ -1094,7 +1094,13 @@ class Player extends EventEmitter {
|
|||
})
|
||||
}
|
||||
|
||||
newStream.on('error', (error) => this.emit('error', error, queue.firstMessage))
|
||||
newStream.on('error', (error) => {
|
||||
if (error.message === 'Video unavailable') {
|
||||
this.emit('error', 'VideoUnavailable', queue.firstMessage)
|
||||
} else {
|
||||
this.emit('error', error, queue.firstMessage)
|
||||
}
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
if (queue.stream) queue.stream.destroy()
|
||||
|
@ -1254,7 +1260,7 @@ module.exports = Player
|
|||
/**
|
||||
* Emitted when an error is triggered
|
||||
* @event Player#error
|
||||
* @param {string} error It can be `NotConnected`, `UnableToJoin`, `NotPlaying`, `ParseError` or `LiveVideo`.
|
||||
* @param {string} error It can be `NotConnected`, `UnableToJoin`, `NotPlaying`, `ParseError`, `LiveVideo` or `VideoUnavailable`.
|
||||
* @param {Discord.Message} message
|
||||
*/
|
||||
|
||||
|
|
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
|
@ -107,7 +107,7 @@ declare module 'discord-player' {
|
|||
requestedBy: User;
|
||||
}
|
||||
type Playlist = YTSRPlaylist & CustomPlaylist;
|
||||
type PlayerError = 'NotConnected' | 'UnableToJoin' | 'NotPlaying' | 'LiveVideo' | 'ParseError';
|
||||
type PlayerError = 'NotConnected' | 'UnableToJoin' | 'NotPlaying' | 'LiveVideo' | 'ParseError' | 'VideoUnavailable';
|
||||
interface PlayerEvents {
|
||||
searchResults: [Message, string, Track[]];
|
||||
searchInvalidResponse: [Message, string, Track[], string, MessageCollector];
|
||||
|
|
Loading…
Reference in a new issue