mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-11 04:45: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
|
@ -2,6 +2,7 @@ import * as t from "io-ts";
|
|||
import { automodAction } from "../helpers";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { LogsPlugin } from "../../Logs/LogsPlugin";
|
||||
import { unique } from "../../../utils";
|
||||
|
||||
export const ChangeNicknameAction = automodAction({
|
||||
configType: t.type({
|
||||
|
@ -9,10 +10,9 @@ export const ChangeNicknameAction = automodAction({
|
|||
}),
|
||||
|
||||
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));
|
||||
|
||||
for (const member of uniqueMembers) {
|
||||
for (const member of members) {
|
||||
if (pluginData.state.recentNicknameChanges.has(member.id)) continue;
|
||||
|
||||
member.edit({ nick: actionConfig.name }).catch(err => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue