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: { $set: {
"automodSettings.spam.$[rulefilter]": { "automodSettings.spam.$[rulefilter]": {
...rule, ...rule,
action: body.action ?? rule.action, action: Number(body.action ?? rule.action),
channels: body.channels ?? rule.channels, channels: body.channels ?? rule.channels,
message: body.message ?? rule.message, message: body.message ?? rule.message,
max_msg: body.max_msg ?? rule.max_msg, max_msg: body.max_msg ?? rule.max_msg,
timeframe: body.timeframe ?? rule.timeframe, timeframe: body.timeframe ?? rule.timeframe,
} as AntispamRule } as AntispamRule
} }
}, { arrayFilters: [ { "rulefilter.id": ruleid } ] }); }, { 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]}`); logger.info(`Antispam rule triggered: ${rule.max_msg}/${rule.timeframe} -> ${ModerationAction[rule.action]}`);
ruleTriggered = true; ruleTriggered = true;
switch(rule.action) { switch(Number(rule.action)) {
case ModerationAction.Delete: case ModerationAction.Delete:
message.delete() message.delete()
.catch(() => logger.warn('Antispam: Failed to delete message') ); .catch(() => logger.warn('Antispam: Failed to delete message') );
@ -86,6 +86,7 @@ async function antispam(message: Message): Promise<boolean> {
case ModerationAction.Ban: case ModerationAction.Ban:
message.reply('(Ban user)'); message.reply('(Ban user)');
break; break;
default: logger.warn(`Unknown Moderation Action: ${rule.action}`);
} }
} }
} }