Small fixes

This commit is contained in:
Wessel T
2019-02-13 01:18:43 +01:00
parent 0a5554efc9
commit 05056ec9ca
2 changed files with 9 additions and 3 deletions

View File

@@ -8,6 +8,6 @@ module.exports = class Disconnect extends DiscordEvent {
}
emit() {
this.bot.print(1, `${cyan('Discord')} >> All websockets disconnected from ${green(`${this.bot.user.username}#${this.bot.user.discriminator}`)}`);
this.bot.print(1, `${cyan('Discord')} >> All websockets disconnected from ${green(`${this.bot.user.username}#${this.bot.user.discriminator}`)}`);
}
};

View File

@@ -31,10 +31,16 @@ module.exports = class Ready extends DiscordEvent {
const flushTime = 1800000;
setInterval(() => {
const uCache = this.bot.cache.get('users') || [];
const gCache = this.bot.cache.get('guilds') || [];
uCache.forEach((v, _) => (new Date(v.entryAge) <= new Date(new Date() - flushTime)) ? uCache.splice(_, 1) : undefined);
const vCache = this.bot.cache.get('voters') || [];
gCache.forEach((v, _) => (new Date(v.entryAge) <= new Date(new Date() - flushTime)) ? gCache.splice(_, 1) : undefined);
uCache.forEach((v, _) => {
if (new Date(v.entryAge) <= new Date(new Date() - flushTime)) {
vCache.forEach((n, _) => n === v.userId ? vCache.splice(_, 1) : undefined);
uCache.splice(_, 1);
}
});
}, flushTime);
}