Minor music performance changes

pull/17/head
Trivernis 6 years ago
parent e4e26cd51f
commit 149e73621f

@ -16,6 +16,7 @@ let presences = [],
function main() {
utils.Cleanup(() => {
guilding.destroyAll();
client.destroy();
});
cmd.setLogger(logger);

@ -33,6 +33,11 @@ exports.GuildHandler = class {
this.registerMusicCommands();
}
destroy(){
this.dj.stop();
this.db.close();
}
/**
* Creates all tables needed in the Database.
* These are at the moment:
@ -299,4 +304,15 @@ exports.GuildHandler = class {
exports.getHandler = function (guild, prefix) {
if (!handlers[guild.id]) handlers[guild.id] = new this.GuildHandler(guild, prefix);
return handlers[guild.id];
};
/**
* Destroy all handlers to safely end all sql3-clients.
*/
exports.destroyAll = function () {
logger.debug('Destroying all handlers...');
for (let key in Object.keys(handlers)) {
if (handlers[key])
handlers[key].destroy();
}
};

@ -22,6 +22,7 @@ exports.DJ = class {
this.repeat = false;
this.volume = 0.5;
this.voiceChannel = voiceChannel;
this.quality = 'lowest';
}
/**
@ -130,8 +131,10 @@ exports.DJ = class {
if (!this.playing || !this.disp) {
logger.debug(`Playing ${url}`);
this.disp = this.conn.playStream(ytdl(url, {
filter: "audioonly"
}), {seek: 0, volume: this.volume});
filter: 'audioonly',
quality: this.quality,
liveBuffer: 40000
}), {volume: this.volume});
this.disp.on('end', (reason) => {
if (reason !== 'stop') {
this.playing = false;

Loading…
Cancel
Save