Time announcement memory leak finally fixed

This commit is contained in:
Histmy 2020-12-27 02:17:13 +01:00
parent 0515cbcdbf
commit e80ba096c8

View File

@ -18,7 +18,7 @@ function vypocitatCas(vojsl) {
d.setMinutes(min); d.setMinutes(min);
d.setSeconds(0); d.setSeconds(0);
setTimeout(function() { timeouty[vojsl.channel.guild.id] = setTimeout(function() {
rekniCas(vojsl, `${nula(hod)}${nula(min)}`); rekniCas(vojsl, `${nula(hod)}${nula(min)}`);
}, d - c + 3000); }, d - c + 3000);
} }
@ -56,6 +56,8 @@ const vytahnout = (clen, patro) => {
setTimeout(() => vytahnout(clen, patro), 1000); setTimeout(() => vytahnout(clen, patro), 1000);
}; };
const timeouty = {};
module.exports = (mes, komand, celArgs) => { module.exports = (mes, komand, celArgs) => {
switch (komand) { switch (komand) {
@ -69,11 +71,17 @@ module.exports = (mes, komand, celArgs) => {
mes.channel.send(`di si tam sam ne ty gadzo ${mes.author}`); mes.channel.send(`di si tam sam ne ty gadzo ${mes.author}`);
break; break;
} }
if (mes.guild.voice) {
if (mes.guild.voice.channel === channel) {
mes.channel.send(`vsak uz tam sem ne ty gadzo ${mes.author}`);
break;
}
}
if (celArgs !== 'potichu') mes.channel.send('<@&591306633196339261> vojs'); if (celArgs !== 'potichu') mes.channel.send('<@&591306633196339261> vojs');
channel.join() channel.join()
.then(con => { .then(con => {
vypocitatCas(con); if (!timeouty[mes.guild.id]) vypocitatCas(con);
con.play('./zvuky/nazdar.ogg'); con.play('./zvuky/nazdar.ogg');
}); });
break; break;
@ -95,6 +103,8 @@ module.exports = (mes, komand, celArgs) => {
break; break;
} }
vojs.channel.leave(); vojs.channel.leave();
clearTimeout(timeouty[mes.guild.id]);
delete timeouty[mes.guild.id];
mes.react('purfieRIP:644609482843881483'); mes.react('purfieRIP:644609482843881483');
break; break;