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