last commit but unironically

This commit is contained in:
janderedev 2022-03-19 21:41:52 +01:00
parent 1c34be948a
commit 801f0263b3
Signed by: Lea
GPG key ID: 5D5E18ACB990F57A
2 changed files with 4 additions and 4 deletions

View file

@ -69,12 +69,11 @@ app.patch('/dash/server/:server/automod/:ruleid', requireAuth({ permission: 2 })
$set: {
"automodSettings.spam.$[rulefilter]": {
...rule,
action: body.action ?? rule.action,
action: Number(body.action ?? rule.action),
channels: body.channels ?? rule.channels,
message: body.message ?? rule.message,
max_msg: body.max_msg ?? rule.max_msg,
timeframe: body.timeframe ?? rule.timeframe,
} as AntispamRule
}
}, { arrayFilters: [ { "rulefilter.id": ruleid } ] });

View file

@ -46,7 +46,7 @@ async function antispam(message: Message): Promise<boolean> {
logger.info(`Antispam rule triggered: ${rule.max_msg}/${rule.timeframe} -> ${ModerationAction[rule.action]}`);
ruleTriggered = true;
switch(rule.action) {
switch(Number(rule.action)) {
case ModerationAction.Delete:
message.delete()
.catch(() => logger.warn('Antispam: Failed to delete message') );
@ -86,10 +86,11 @@ async function antispam(message: Message): Promise<boolean> {
case ModerationAction.Ban:
message.reply('(Ban user)');
break;
default: logger.warn(`Unknown Moderation Action: ${rule.action}`);
}
}
}
return !ruleTriggered;
}