feat(bot): added achievement caching
Some checks failed
Commitlint / Run commitlint scanning (push) Has been cancelled

This commit is contained in:
Ahmad 2025-06-24 19:33:11 -04:00
parent 0cf8da1941
commit b990b8ea06
No known key found for this signature in database
GPG key ID: 8FD8A93530D182BF
3 changed files with 105 additions and 102 deletions

View file

@ -2,7 +2,6 @@ import { Message, EmbedBuilder, TextChannel, Guild } from 'discord.js';
import {
addXpToUser,
awardAchievement,
getAllAchievements,
getUserAchievements,
getUserLevel,
@ -34,11 +33,14 @@ async function handleProgress(
(a) => a.achievementId === achievement.id && a.earnedAt !== null,
);
await updateAchievementProgress(userId, achievement.id, progress);
const updated = await updateAchievementProgress(
userId,
achievement.id,
progress,
);
if (progress === 100 && !existing && !skipAward) {
const awarded = await awardAchievement(userId, achievement.id);
if (awarded && guild) {
if (updated && guild) {
await announceAchievement(guild, userId, achievement);
}
}