Added can't stream error before adding to queue

This commit is contained in:
RemixDev
2022-08-19 23:49:53 +02:00
parent 59d8222177
commit 12d6cafdd0
3 changed files with 34 additions and 4 deletions

View File

@@ -1,3 +1,16 @@
const { TrackFormats } = require('deezer-js')
const bitrateLabels = {
[TrackFormats.MP4_RA3]: '360 HQ',
[TrackFormats.MP4_RA2]: '360 MQ',
[TrackFormats.MP4_RA1]: '360 LQ',
[TrackFormats.FLAC]: 'FLAC',
[TrackFormats.MP3_320]: '320kbps',
[TrackFormats.MP3_128]: '128kbps',
[TrackFormats.DEFAULT]: '128kbps',
[TrackFormats.LOCAL]: 'MP3'
}
export class BadRequestError extends Error {
constructor() {
super()
@@ -31,3 +44,12 @@ export class NotLoggedIn extends QueueError {
this.name = 'NotLoggedIn'
}
}
export class CantStream extends QueueError {
bitrate: number
constructor(bitrate: number) {
super(`Your account can't stream at ${bitrateLabels[bitrate]}.`)
this.name = 'CantStream'
this.bitrate = bitrate
}
}