diff --git a/src/Player.js b/src/Player.js index 1030587..396f11f 100644 --- a/src/Player.js +++ b/src/Player.js @@ -63,6 +63,7 @@ const filters = { * @property {boolean} [leaveOnEmpty=true] Whether the bot should leave the voice channel if there is no more member in it. * @property {number} [leaveOnEmptyCooldown=0] Used when leaveOnEmpty is enabled, to let the time to users to come back in the voice channel. * @property {boolean} [autoSelfDeaf=true] Whether the bot should automatically turn off its headphones when joining a voice channel. + * @property {string} [quality='high'] Music quality (high or low) */ /** @@ -75,7 +76,8 @@ const defaultPlayerOptions = { leaveOnStop: true, leaveOnEmpty: true, leaveOnEmptyCooldown: 0, - autoSelfDeaf: true + autoSelfDeaf: true, + quality: 'high' } class Player extends EventEmitter { @@ -679,6 +681,7 @@ class Player extends EventEmitter { encoderArgs = ['-af', encoderArgsFilters.join(',')] } const newStream = ytdl(queue.playing.url, { + quality: this.options.quality === 'low' ? 'lowestaudio' : 'highestaudio', filter: 'audioonly', opusEncoded: true, encoderArgs, diff --git a/typings/index.d.ts b/typings/index.d.ts index 4846d27..347ec6b 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -45,6 +45,7 @@ declare module 'discord-player' { public once(event: K, listener: (...args: PlayerEvents[K]) => void): this; public emit(event: K, ...args: PlayerEvents[K]): boolean; } + type MusicQuality = 'high' | 'low'; interface PlayerOptions { leaveOnEnd: boolean; leaveOnEndCooldown?: number; @@ -52,6 +53,7 @@ declare module 'discord-player' { leaveOnEmpty: boolean; leaveOnEmptyCooldown?: number; autoSelfDeaf: boolean; + quality: MusicQuality; } type Filters = 'bassboost' | '8D' | 'vaporwave' | 'nightcore'| 'phaser' | 'tremolo' | 'vibrato' | 'reverse' | 'treble' | 'normalizer' | 'surrounding' | 'pulsator' | 'subboost' | 'karaoke' | 'flanger' | 'gate' | 'haas' | 'mcompand'; type FiltersStatuses = {