|
|
|
@ -32,9 +32,9 @@ exports.DJ = class {
|
|
|
|
|
connect(voiceChannel) {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
this.voiceChannel = voiceChannel || this.voiceChannel;
|
|
|
|
|
if (this.connected) {
|
|
|
|
|
if (this.connected)
|
|
|
|
|
this.stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
logger.verbose(`Connecting to voiceChannel ${this.voiceChannel.name}`);
|
|
|
|
|
this.voiceChannel.join().then(connection => {
|
|
|
|
|
logger.info(`Connected to Voicechannel ${this.voiceChannel.name}`);
|
|
|
|
@ -42,7 +42,7 @@ exports.DJ = class {
|
|
|
|
|
this.checkListeners();
|
|
|
|
|
resolve();
|
|
|
|
|
}).catch((error) => reject(error));
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -51,9 +51,9 @@ exports.DJ = class {
|
|
|
|
|
*/
|
|
|
|
|
set listenOnRepeat(value) {
|
|
|
|
|
this.repeat = value;
|
|
|
|
|
if (this.current) {
|
|
|
|
|
if (this.current)
|
|
|
|
|
this.queue.push(this.current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -99,8 +99,9 @@ exports.DJ = class {
|
|
|
|
|
logger.verbose(`Exiting ${this.voiceChannel.name}`);
|
|
|
|
|
this.stop();
|
|
|
|
|
}, config.music.timeout || 300000);
|
|
|
|
|
} else if (this.connected)
|
|
|
|
|
setTimeout(() => this.checkListeners(), 10000);
|
|
|
|
|
} else if (this.connected) {
|
|
|
|
|
setTimeout(() => this.checkListeners(), 10000);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -159,15 +160,15 @@ exports.DJ = class {
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
logger.debug(`Added ${url} to the queue`);
|
|
|
|
|
if (playnext) {
|
|
|
|
|
if (playnext)
|
|
|
|
|
this.getVideoName(url).then((title) => {
|
|
|
|
|
this.queue.unshift({'url': url, 'title': title});
|
|
|
|
|
}).catch((err) => logger.verbose(err.message));
|
|
|
|
|
} else {
|
|
|
|
|
else
|
|
|
|
|
this.getVideoName(url).then((title) => {
|
|
|
|
|
this.queue.push({'url': url, 'title': title});
|
|
|
|
|
}).catch((err) => logger.verbose(err.message));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -200,7 +201,7 @@ exports.DJ = class {
|
|
|
|
|
this.volume = percentage;
|
|
|
|
|
this.disp.setVolume(percentage);
|
|
|
|
|
} else {
|
|
|
|
|
logger.warn("No dispatcher found.")
|
|
|
|
|
logger.warn("No dispatcher found.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -209,11 +210,11 @@ exports.DJ = class {
|
|
|
|
|
*/
|
|
|
|
|
pause() {
|
|
|
|
|
logger.verbose("Pausing music...");
|
|
|
|
|
if (this.disp !== null) {
|
|
|
|
|
if (this.disp !== null)
|
|
|
|
|
this.disp.pause();
|
|
|
|
|
} else {
|
|
|
|
|
else
|
|
|
|
|
logger.warn("No dispatcher found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -221,11 +222,11 @@ exports.DJ = class {
|
|
|
|
|
*/
|
|
|
|
|
resume() {
|
|
|
|
|
logger.verbose("Resuming music...");
|
|
|
|
|
if (this.disp !== null) {
|
|
|
|
|
if (this.disp !== null)
|
|
|
|
|
this.disp.resume();
|
|
|
|
|
} else {
|
|
|
|
|
else
|
|
|
|
|
logger.warn("No dispatcher found");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -340,13 +341,13 @@ exports.playFile = function (guildId, filename) {
|
|
|
|
|
*/
|
|
|
|
|
exports.play = function (voiceChannel, url) {
|
|
|
|
|
let guildId = voiceChannel.guild.id;
|
|
|
|
|
if (!djs[guildId]) {
|
|
|
|
|
if (!djs[guildId])
|
|
|
|
|
this.connect(voiceChannel).then(() => {
|
|
|
|
|
djs[guildId].playYouTube(url);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
else
|
|
|
|
|
djs[guildId].playYouTube(url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -357,13 +358,13 @@ exports.play = function (voiceChannel, url) {
|
|
|
|
|
*/
|
|
|
|
|
exports.playnext = function (voiceChannel, url) {
|
|
|
|
|
let guildId = voiceChannel.guild.id;
|
|
|
|
|
if (!djs[guildId]) {
|
|
|
|
|
if (!djs[guildId])
|
|
|
|
|
this.connect(voiceChannel).then(() => {
|
|
|
|
|
djs[guildId].playYouTube(url, true);
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
else
|
|
|
|
|
djs[guildId].playYouTube(url, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|