mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
automod: ensure actions only apply once per user/member
This commit is contained in:
parent
e55a1e3bd6
commit
c39d69dd5d
9 changed files with 27 additions and 22 deletions
|
@ -1,7 +1,7 @@
|
|||
import * as t from "io-ts";
|
||||
import { automodAction } from "../helpers";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { asyncMap, resolveMember, tNullable } from "../../../utils";
|
||||
import { asyncMap, resolveMember, tNullable, unique } from "../../../utils";
|
||||
import { resolveActionContactMethods } from "../functions/resolveActionContactMethods";
|
||||
import { ModActionsPlugin } from "../../ModActions/ModActionsPlugin";
|
||||
|
||||
|
@ -9,11 +9,10 @@ export const RemoveRolesAction = automodAction({
|
|||
configType: t.array(t.string),
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
const members = contexts.map(c => c.member).filter(Boolean);
|
||||
const uniqueMembers = new Set(members);
|
||||
const members = unique(contexts.map(c => c.member).filter(Boolean));
|
||||
|
||||
await Promise.all(
|
||||
Array.from(uniqueMembers.values()).map(async member => {
|
||||
members.map(async member => {
|
||||
const memberRoles = new Set(member.roles);
|
||||
for (const roleId of actionConfig) {
|
||||
memberRoles.delete(roleId);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue