switch to using _handleTarget
This commit is contained in:
parent
96cc1cd111
commit
8cfacb9d9c
@ -291,75 +291,27 @@ class ModerationManager {
|
|||||||
let points = 0,
|
let points = 0,
|
||||||
expiration = 0,
|
expiration = 0,
|
||||||
response = null;
|
response = null;
|
||||||
const { force } = action;
|
const { force, duration, type } = action;
|
||||||
const Infraction = Constant.Infractions[action.type];
|
const Infraction = Constant.Infractions[type];
|
||||||
|
|
||||||
if (moderationPoints.enabled) {
|
if (moderationPoints.enabled) {
|
||||||
points = action.points || moderationPoints.points[action.type];
|
points = action.points || moderationPoints.points[type];
|
||||||
expiration = action.expiration || moderationPoints.expirations[action.type];
|
expiration = action.expiration || moderationPoints.expirations[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
const infractionData = {
|
response = await this._handleTarget(Infraction, message.member, {
|
||||||
executor: guild.me,
|
|
||||||
guild,
|
guild,
|
||||||
channel: message.channel,
|
channel: message.channel,
|
||||||
message,
|
executor: guild.me,
|
||||||
target: message.member,
|
arguments: null,
|
||||||
reason,
|
reason,
|
||||||
duration: action.duration,
|
duration: duration,
|
||||||
silent,
|
|
||||||
data,
|
data,
|
||||||
points,
|
force,
|
||||||
expiration
|
silent
|
||||||
};
|
});
|
||||||
|
|
||||||
const infraction = new Infraction(this.client, infractionData);
|
console.log(response)
|
||||||
|
|
||||||
const verification = await infraction.verify();
|
|
||||||
if (verification.error) {
|
|
||||||
this.client.logger.debug(`Automod infraction failed verification.\n${infraction.type}:\n${JSON.stringify(infractionData)}`);
|
|
||||||
return; // Possibly add a automod error log channel setting and do something here -- skip for now
|
|
||||||
}
|
|
||||||
|
|
||||||
if (autoModeration.enabled && points && !force) {
|
|
||||||
|
|
||||||
const userTarget = message.author;
|
|
||||||
const oldPoints = await userTarget.totalPoints(guild);
|
|
||||||
const newPoints = oldPoints + points;
|
|
||||||
|
|
||||||
let result = null;
|
|
||||||
// eslint-disable-next-line prefer-const
|
|
||||||
for (let [threshold, action] of Object.entries(autoModeration.thresholds)) {
|
|
||||||
threshold = parseInt(threshold);
|
|
||||||
if (oldPoints >= threshold) continue;
|
|
||||||
if (newPoints >= threshold) result = {
|
|
||||||
threshold,
|
|
||||||
...action
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result && Constant.Hierarchy[infraction.type] <= Constant.Hierarchy[result.type]) {
|
|
||||||
infractionData.duration = result.length;
|
|
||||||
infractionData.reason += `\n*${message.format('INFRACTION_AUTOMODESCALATION')}*`;
|
|
||||||
const escalation = new Constant.Infractions[result.type](this.client, infractionData);
|
|
||||||
|
|
||||||
const verification = await escalation.verify();
|
|
||||||
if (verification.error) {
|
|
||||||
this.client.logger.debug(`Automod escalated infraction failed verification.\n${infraction.type}:\n${JSON.stringify(infractionData)}`);
|
|
||||||
return; // Possibly add a automod error log channel setting and do something here -- skip for now
|
|
||||||
}
|
|
||||||
//: moderationPoints.expirations[escalation.type]
|
|
||||||
escalation.totalPoints = await userTarget.totalPoints(guild, { points, expiration, timestamp: infraction.timestamp });
|
|
||||||
|
|
||||||
response = await escalation.execute();
|
|
||||||
|
|
||||||
} else {
|
|
||||||
infraction.totalPoints = await userTarget.totalPoints(guild, { points, expiration, timestamp: infraction.timestamp });
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!response) response = await infraction.execute();
|
|
||||||
|
|
||||||
if (response.error) this.client.logger.debug(`Automod infraction execution failed:\n${JSON.stringify(response)}`);
|
if (response.error) this.client.logger.debug(`Automod infraction execution failed:\n${JSON.stringify(response)}`);
|
||||||
// TODO:
|
// TODO:
|
||||||
|
Loading…
Reference in New Issue
Block a user