Update cache helper using the wrong symbol to measure interval
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
ad2e4d8f9b
commit
2b04952d85
2 changed files with 12 additions and 4 deletions
|
@ -3,7 +3,9 @@ import NicknameChanged from "./GuildMemberUpdate/NicknameChanged";
|
||||||
import CacheHelper from "../../helpers/CacheHelper";
|
import CacheHelper from "../../helpers/CacheHelper";
|
||||||
|
|
||||||
export default async function GuildMemberUpdate(oldMember: GuildMember, newMember: GuildMember) {
|
export default async function GuildMemberUpdate(oldMember: GuildMember, newMember: GuildMember) {
|
||||||
await CacheHelper.UpdateServerCache(newMember.guild);
|
const updatedFromCache = await CacheHelper.UpdateServerCache(newMember.guild);
|
||||||
|
|
||||||
|
if (updatedFromCache) return;
|
||||||
|
|
||||||
if (oldMember.nickname !== newMember.nickname) { // Nickname change
|
if (oldMember.nickname !== newMember.nickname) { // Nickname change
|
||||||
await NicknameChanged(oldMember, newMember);
|
await NicknameChanged(oldMember, newMember);
|
||||||
|
|
|
@ -2,10 +2,10 @@ import { Guild } from "discord.js";
|
||||||
import Server from "../database/entities/Server";
|
import Server from "../database/entities/Server";
|
||||||
|
|
||||||
export default class CacheHelper {
|
export default class CacheHelper {
|
||||||
public static async UpdateServerCache(guild: Guild) {
|
public static async UpdateServerCache(guild: Guild): Promise<boolean> {
|
||||||
const cacheInterval = process.env.CACHE_INTERVAL;
|
const cacheInterval = process.env.CACHE_INTERVAL;
|
||||||
|
|
||||||
if (!cacheInterval) return;
|
if (!cacheInterval) return false;
|
||||||
|
|
||||||
let server = await Server.FetchOneById(Server, guild.id);
|
let server = await Server.FetchOneById(Server, guild.id);
|
||||||
|
|
||||||
|
@ -14,9 +14,15 @@ export default class CacheHelper {
|
||||||
await server.Save(Server, server);
|
await server.Save(Server, server);
|
||||||
|
|
||||||
await CacheHelper.UpdateCache(guild);
|
await CacheHelper.UpdateCache(guild);
|
||||||
} else if (server.LastCached.getTime() + Number(cacheInterval) < Date.now()) {
|
|
||||||
|
return true;
|
||||||
|
} else if (server.LastCached.getTime() + Number(cacheInterval) > Date.now()) {
|
||||||
await CacheHelper.UpdateCache(guild);
|
await CacheHelper.UpdateCache(guild);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static async UpdateCache(guild: Guild) {
|
private static async UpdateCache(guild: Guild) {
|
||||||
|
|
Loading…
Reference in a new issue