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