mirror of
https://github.com/ahmadk953/poixpixel-discord-bot.git
synced 2025-07-05 03:46:00 +00:00
fix(bot): fixed command achievements and progress updates
This commit is contained in:
parent
86e0a59188
commit
d71d9f0dcc
2 changed files with 25 additions and 19 deletions
|
@ -129,7 +129,6 @@ export async function updateAchievementProgress(
|
|||
): Promise<boolean> {
|
||||
try {
|
||||
await ensureDbInitialized();
|
||||
|
||||
if (!db) {
|
||||
console.error(
|
||||
'Database not initialized, cannot update achievement progress',
|
||||
|
@ -149,21 +148,15 @@ export async function updateAchievementProgress(
|
|||
.then((rows) => rows[0]);
|
||||
|
||||
if (existing) {
|
||||
if (existing.earnedAt) {
|
||||
return false;
|
||||
}
|
||||
|
||||
await db
|
||||
.update(schema.userAchievementsTable)
|
||||
.set({
|
||||
progress: Math.floor(progress) > 100 ? 100 : Math.floor(progress),
|
||||
})
|
||||
.set({ progress })
|
||||
.where(eq(schema.userAchievementsTable.id, existing.id));
|
||||
} else {
|
||||
await db.insert(schema.userAchievementsTable).values({
|
||||
discordId: userId,
|
||||
achievementId: achievementId,
|
||||
progress: Math.floor(progress) > 100 ? 100 : Math.floor(progress),
|
||||
achievementId,
|
||||
progress,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue