|
|
|
@ -1,4 +1,4 @@
|
|
|
|
|
const ytdl = require("ytdl-core-discord"),
|
|
|
|
|
const ytdl = require("ytdl-core"),
|
|
|
|
|
ypi = require('youtube-playlist-info'),
|
|
|
|
|
yttl = require('get-youtube-title'),
|
|
|
|
|
config = require('../../config.json'),
|
|
|
|
@ -24,6 +24,7 @@ class MusicPlayer extends xevents.ExtendedEventEmitter {
|
|
|
|
|
this.playing = false;
|
|
|
|
|
this.current = null;
|
|
|
|
|
this.repeat = false;
|
|
|
|
|
this.volume = 0.5;
|
|
|
|
|
this.voiceChannel = voiceChannel;
|
|
|
|
|
this.exitTimeout = null;
|
|
|
|
|
this._logger = new logging.Logger(this);
|
|
|
|
@ -188,8 +189,8 @@ class MusicPlayer extends xevents.ExtendedEventEmitter {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
try {
|
|
|
|
|
this.disp = this.conn.playOpusStream(await ytdl(url,
|
|
|
|
|
{filter: 'audioonly', quality: this.quality, liveBuffer: this.liveBuffer}));
|
|
|
|
|
this.disp = this.conn.playStream(await ytdl(url,
|
|
|
|
|
{filter: 'audioonly', quality: this.quality, liveBuffer: this.liveBuffer}, {volume: this.volume}));
|
|
|
|
|
this.disp.on('error', (err) => {
|
|
|
|
|
this._logger.error(err.message);
|
|
|
|
|
this._logger.debug(err.stack);
|
|
|
|
@ -232,6 +233,17 @@ class MusicPlayer extends xevents.ExtendedEventEmitter {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the volume of the dispatcher to the given value
|
|
|
|
|
* @param percentage {Number}
|
|
|
|
|
*/
|
|
|
|
|
setVolume(percentage) {
|
|
|
|
|
this._logger.verbose(`Setting volume to ${percentage}`);
|
|
|
|
|
this.volume = percentage;
|
|
|
|
|
if (this.disp !== null)
|
|
|
|
|
this.disp.setVolume(percentage);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Pauses if a dispatcher exists
|
|
|
|
|
*/
|
|
|
|
@ -295,7 +307,9 @@ class MusicPlayer extends xevents.ExtendedEventEmitter {
|
|
|
|
|
skip() {
|
|
|
|
|
this._logger.debug("Skipping song");
|
|
|
|
|
if (this.disp !== null) {
|
|
|
|
|
this.disp.end();
|
|
|
|
|
let disp = this.disp;
|
|
|
|
|
this.disp = null;
|
|
|
|
|
disp.end();
|
|
|
|
|
} else {
|
|
|
|
|
this.playing = false;
|
|
|
|
|
if (this.queue.length > 0) {
|
|
|
|
|