Update cache helper using the wrong symbol to measure interval
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Ethan Lane 2024-03-30 16:15:53 +00:00
parent ad2e4d8f9b
commit 2b04952d85
2 changed files with 12 additions and 4 deletions

View file

@ -3,7 +3,9 @@ import NicknameChanged from "./GuildMemberUpdate/NicknameChanged";
import CacheHelper from "../../helpers/CacheHelper";
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
await NicknameChanged(oldMember, newMember);

View file

@ -2,10 +2,10 @@ import { Guild } from "discord.js";
import Server from "../database/entities/Server";
export default class CacheHelper {
public static async UpdateServerCache(guild: Guild) {
public static async UpdateServerCache(guild: Guild): Promise<boolean> {
const cacheInterval = process.env.CACHE_INTERVAL;
if (!cacheInterval) return;
if (!cacheInterval) return false;
let server = await Server.FetchOneById(Server, guild.id);
@ -14,9 +14,15 @@ export default class CacheHelper {
await server.Save(Server, server);
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);
return true;
}
return false;
}
private static async UpdateCache(guild: Guild) {