From cb92b1eea0de4ed16eee1af304c304b3332606fe Mon Sep 17 00:00:00 2001 From: "Navy.gif" Date: Wed, 13 Jul 2022 20:11:46 +0300 Subject: [PATCH] bugfix to null ID in user point tally --- src/structure/client/ModerationManager.js | 11 +++++++---- src/structure/client/wrappers/UserWrapper.js | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/structure/client/ModerationManager.js b/src/structure/client/ModerationManager.js index 1d4a77f..e5bfa7a 100644 --- a/src/structure/client/ModerationManager.js +++ b/src/structure/client/ModerationManager.js @@ -342,11 +342,14 @@ class ModerationManager { if (response.error) return response; if (response.infraction.targetType === 'USER') { - response.infraction.totalPoints = await targetWrapper.totalPoints(guild, { - points, expiration, timestamp: response.infraction.timestamp, id: response.infraction.id - }); + response.infraction.totalPoints = await targetWrapper.totalPoints(guild); + response.infraction.totalPoints += points; } - return response.infraction.execute(); + const result = await response.infraction.execute(); + await targetWrapper.totalPoints(guild, { + points, expiration, timestamp: response.infraction.timestamp, id: response.infraction.id + }); + return result; } diff --git a/src/structure/client/wrappers/UserWrapper.js b/src/structure/client/wrappers/UserWrapper.js index 2828f0c..544ec88 100644 --- a/src/structure/client/wrappers/UserWrapper.js +++ b/src/structure/client/wrappers/UserWrapper.js @@ -24,7 +24,7 @@ class UserWrapper { async fetchPoints(guild) { let index = this._points[guild.id]; - if (index) return index; + if (index) return Promise.resolve(index); this._points[guild.id] = { expirations: [], points: 0