Skip to content

Commit

Permalink
✨ Add music quality option
Browse files Browse the repository at this point in the history
  • Loading branch information
Androz2091 committed Jan 10, 2021
1 parent 11acf26 commit 6d53e02
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
*/

/**
Expand All @@ -75,7 +76,8 @@ const defaultPlayerOptions = {
leaveOnStop: true,
leaveOnEmpty: true,
leaveOnEmptyCooldown: 0,
autoSelfDeaf: true
autoSelfDeaf: true,
quality: 'high'
}

class Player extends EventEmitter {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ declare module 'discord-player' {
public once<K extends keyof PlayerEvents>(event: K, listener: (...args: PlayerEvents[K]) => void): this;
public emit<K extends keyof PlayerEvents>(event: K, ...args: PlayerEvents[K]): boolean;
}
type MusicQuality = 'high' | 'low';
interface PlayerOptions {
leaveOnEnd: boolean;
leaveOnEndCooldown?: number;
leaveOnStop: boolean;
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 = {
Expand Down

0 comments on commit 6d53e02

Please sign in to comment.