Merge pull request #17 from Trivernis/develop

Develop
pull/22/head
Trivernis 6 years ago committed by GitHub
commit 79b104a35e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -33,6 +33,11 @@ exports.GuildHandler = class {
this.registerMusicCommands(); this.registerMusicCommands();
} }
destroy(){
this.dj.stop();
this.db.close();
}
/** /**
* Creates all tables needed in the Database. * Creates all tables needed in the Database.
* These are at the moment: * These are at the moment:
@ -300,3 +305,14 @@ exports.getHandler = function (guild, prefix) {
if (!handlers[guild.id]) handlers[guild.id] = new this.GuildHandler(guild, prefix); if (!handlers[guild.id]) handlers[guild.id] = new this.GuildHandler(guild, prefix);
return handlers[guild.id]; 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.repeat = false;
this.volume = 0.5; this.volume = 0.5;
this.voiceChannel = voiceChannel; this.voiceChannel = voiceChannel;
this.quality = 'lowest';
} }
/** /**
@ -130,8 +131,10 @@ exports.DJ = class {
if (!this.playing || !this.disp) { if (!this.playing || !this.disp) {
logger.debug(`Playing ${url}`); logger.debug(`Playing ${url}`);
this.disp = this.conn.playStream(ytdl(url, { this.disp = this.conn.playStream(ytdl(url, {
filter: "audioonly" filter: 'audioonly',
}), {seek: 0, volume: this.volume}); quality: this.quality,
liveBuffer: 40000
}), {volume: this.volume});
this.disp.on('end', (reason) => { this.disp.on('end', (reason) => {
if (reason !== 'stop') { if (reason !== 'stop') {
this.playing = false; this.playing = false;

@ -7,10 +7,10 @@
"ffmpeg-binaries": "4.0.0", "ffmpeg-binaries": "4.0.0",
"get-youtube-title": "1.0.0", "get-youtube-title": "1.0.0",
"opusscript": "0.0.6", "opusscript": "0.0.6",
"sqlite3": "^4.0.6", "sqlite3": "4.0.6",
"winston": "3.1.0", "winston": "3.1.0",
"winston-daily-rotate-file": "3.5.1", "winston-daily-rotate-file": "3.6.0",
"youtube-playlist-info": "1.1.2", "youtube-playlist-info": "1.1.2",
"ytdl-core": "0.28.3" "ytdl-core": "0.29.1"
} }
} }

Loading…
Cancel
Save