mirror of
https://github.com/ahmadk953/poixpixel-discord-bot.git
synced 2025-07-05 11:56:00 +00:00
feat(bot): added achievement caching
Some checks failed
Commitlint / Run commitlint scanning (push) Has been cancelled
Some checks failed
Commitlint / Run commitlint scanning (push) Has been cancelled
This commit is contained in:
parent
0cf8da1941
commit
b990b8ea06
3 changed files with 105 additions and 102 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue