fix totalPoint error

This commit is contained in:
nolan 2021-06-17 10:25:09 -07:00
parent baba22c5ae
commit b83ea79cf1

View File

@ -82,9 +82,11 @@ class ModerationManager {
const responses = [];
for (const target of targets) {
const response = await this._handleTarget(Infraction, target, {
message,
guild: message.guild,
channel: message.channel,
executor: message.member,
arguments: message.arguments,
points: message.arguments?.points?.value,
expiration: message.arguments?.expiration?.value,
reason: info.reason,
@ -180,7 +182,7 @@ class ModerationManager {
}
async _handleTarget(Infraction, target, info, automod = false) {
async _handleTarget(Infraction, target, info) {
const { guild, reason, force } = info;
const { autoModeration, moderationPoints } = guild._settings;
const { type } = Infraction;
@ -244,6 +246,8 @@ class ModerationManager {
const infraction = new Infraction(this.client, {
target,
type,
message: info.message || null,
arguments: info.arguments,
guild: info.guild,
channel: info.channel,
executor: info.executor,
@ -262,6 +266,8 @@ class ModerationManager {
const escalationClass = Constant.Infractions[response.escalation.type];
const escalationInfraction = new escalationClass(this.client, {
target,
message: info.message || null,
arguments: info.arguments,
type: escalationClass.type,
guild: info.guild,
channel: info.channel,
@ -280,7 +286,11 @@ class ModerationManager {
if(response.error) return response;
response.infraction.totalPoints = await response.infraction.target.totalPoints(guild, { points, expiration, timestamp: response.infraction.timestamp });
if(response.infraction.targetType === 'USER') {
response.infraction.totalPoints = await response.infraction.target.totalPoints(guild, {
points, expiration, timestamp: response.infraction.timestamp
});
}
return response.infraction.execute();
}