|
|
|
@ -11,7 +11,7 @@ let connections = {};
|
|
|
|
|
|
|
|
|
|
/* Function Definition */
|
|
|
|
|
|
|
|
|
|
exports.DJ = class{
|
|
|
|
|
exports.DJ = class {
|
|
|
|
|
constructor(voiceChannel) {
|
|
|
|
|
this.conn = null;
|
|
|
|
|
this.disp = null;
|
|
|
|
@ -80,7 +80,7 @@ exports.DJ = class{
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
if (this.voiceChannel && this.voiceChannel.members.size === 1)
|
|
|
|
|
logger.verbose(`Exiting ${this.voiceChannel.name}`);
|
|
|
|
|
this.stop();
|
|
|
|
|
this.stop();
|
|
|
|
|
}, 300000);
|
|
|
|
|
} else if (this.connected)
|
|
|
|
|
setTimeout(() => this.checkListeners(), 10000);
|
|
|
|
@ -226,7 +226,7 @@ exports.DJ = class{
|
|
|
|
|
this.voiceChannel.leave();
|
|
|
|
|
logger.debug("Left VoiceChannel");
|
|
|
|
|
}
|
|
|
|
|
} catch(error) {
|
|
|
|
|
} catch (error) {
|
|
|
|
|
logger.verbose(JSON.stringify(error));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -236,7 +236,7 @@ exports.DJ = class{
|
|
|
|
|
* end event of the dispatcher that automatically plays the next song. If no dispatcher is found
|
|
|
|
|
* It tries to play the next song with playYouTube
|
|
|
|
|
*/
|
|
|
|
|
skip () {
|
|
|
|
|
skip() {
|
|
|
|
|
logger.debug("Skipping song");
|
|
|
|
|
if (this.disp !== null) {
|
|
|
|
|
this.disp.end();
|
|
|
|
@ -298,7 +298,7 @@ exports.setLogger = function (newLogger) {
|
|
|
|
|
* Connects to a voicechannel
|
|
|
|
|
* @param voiceChannel
|
|
|
|
|
*/
|
|
|
|
|
exports.connect = function(voiceChannel) {
|
|
|
|
|
exports.connect = function (voiceChannel) {
|
|
|
|
|
let gid = voiceChannel.guild.id;
|
|
|
|
|
let voiceDJ = new this.DJ(voiceChannel);
|
|
|
|
|
djs[gid] = voiceDJ;
|
|
|
|
@ -310,7 +310,7 @@ exports.connect = function(voiceChannel) {
|
|
|
|
|
* @param filename
|
|
|
|
|
* @param guildId
|
|
|
|
|
*/
|
|
|
|
|
exports.playFile = function(guildId, filename) {
|
|
|
|
|
exports.playFile = function (guildId, filename) {
|
|
|
|
|
djs[guildId].playFile(filename);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -319,7 +319,7 @@ exports.playFile = function(guildId, filename) {
|
|
|
|
|
* @param voiceChannel
|
|
|
|
|
* @param url
|
|
|
|
|
*/
|
|
|
|
|
exports.play = function(voiceChannel, url) {
|
|
|
|
|
exports.play = function (voiceChannel, url) {
|
|
|
|
|
let guildId = voiceChannel.guild.id;
|
|
|
|
|
if (!djs[guildId]) {
|
|
|
|
|
this.connect(voiceChannel).then(() => {
|
|
|
|
@ -335,7 +335,7 @@ exports.play = function(voiceChannel, url) {
|
|
|
|
|
* @param voiceChannel
|
|
|
|
|
* @param url
|
|
|
|
|
*/
|
|
|
|
|
exports.playnext = function(voiceChannel, url) {
|
|
|
|
|
exports.playnext = function (voiceChannel, url) {
|
|
|
|
|
let guildId = voiceChannel.guild.id;
|
|
|
|
|
if (!djs[guildId]) {
|
|
|
|
|
this.connect(voiceChannel).then(() => {
|
|
|
|
@ -351,14 +351,14 @@ exports.playnext = function(voiceChannel, url) {
|
|
|
|
|
* @param percentage
|
|
|
|
|
* @param guildId
|
|
|
|
|
*/
|
|
|
|
|
exports.setVolume = function(guildId, percentage) {
|
|
|
|
|
exports.setVolume = function (guildId, percentage) {
|
|
|
|
|
djs[guildId].setVolume(percentage);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* pauses the music
|
|
|
|
|
*/
|
|
|
|
|
exports.pause = function(guildId) {
|
|
|
|
|
exports.pause = function (guildId) {
|
|
|
|
|
djs[guildId].pause();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -366,7 +366,7 @@ exports.pause = function(guildId) {
|
|
|
|
|
* Resumes the music
|
|
|
|
|
* @param guildId
|
|
|
|
|
*/
|
|
|
|
|
exports.resume = function(guildId) {
|
|
|
|
|
exports.resume = function (guildId) {
|
|
|
|
|
djs[guildId].resume();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -374,7 +374,7 @@ exports.resume = function(guildId) {
|
|
|
|
|
* Stops the music
|
|
|
|
|
* @param guildId
|
|
|
|
|
*/
|
|
|
|
|
exports.stop = function(guildId) {
|
|
|
|
|
exports.stop = function (guildId) {
|
|
|
|
|
djs[guildId].stop();
|
|
|
|
|
delete djs[guildId];
|
|
|
|
|
};
|
|
|
|
@ -383,7 +383,7 @@ exports.stop = function(guildId) {
|
|
|
|
|
* Skips the song
|
|
|
|
|
* @param guildId
|
|
|
|
|
*/
|
|
|
|
|
exports.skip = function(guildId) {
|
|
|
|
|
exports.skip = function (guildId) {
|
|
|
|
|
djs[guildId].skip();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -391,7 +391,7 @@ exports.skip = function(guildId) {
|
|
|
|
|
* Clears the playlist
|
|
|
|
|
* @param guildId
|
|
|
|
|
*/
|
|
|
|
|
exports.clearQueue = function(guildId) {
|
|
|
|
|
exports.clearQueue = function (guildId) {
|
|
|
|
|
djs[guildId].clear();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -399,7 +399,7 @@ exports.clearQueue = function(guildId) {
|
|
|
|
|
* Returns the queue
|
|
|
|
|
* @param guildId
|
|
|
|
|
*/
|
|
|
|
|
exports.getQueue = function(guildId) {
|
|
|
|
|
exports.getQueue = function (guildId) {
|
|
|
|
|
return djs[guildId].playlist;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -407,7 +407,7 @@ exports.getQueue = function(guildId) {
|
|
|
|
|
* evokes the callback function with the title of the current song
|
|
|
|
|
* @param guildId
|
|
|
|
|
*/
|
|
|
|
|
exports.nowPlaying = function(guildId) {
|
|
|
|
|
exports.nowPlaying = function (guildId) {
|
|
|
|
|
return djs[guildId].song;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -415,7 +415,7 @@ exports.nowPlaying = function(guildId) {
|
|
|
|
|
* shuffles the queue
|
|
|
|
|
* @param guildId
|
|
|
|
|
*/
|
|
|
|
|
exports.shuffle = function(guildId) {
|
|
|
|
|
exports.shuffle = function (guildId) {
|
|
|
|
|
djs[guildId].shuffle();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|