mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-11 04:45:02 +00:00
Automod actions + ModActions public interface
This commit is contained in:
parent
0f0728bc1c
commit
86023877a2
22 changed files with 508 additions and 16 deletions
27
backend/src/plugins/Automod/actions/changeNickname.ts
Normal file
27
backend/src/plugins/Automod/actions/changeNickname.ts
Normal file
|
@ -0,0 +1,27 @@
|
|||
import * as t from "io-ts";
|
||||
import { automodAction } from "../helpers";
|
||||
import { LogType } from "../../../data/LogType";
|
||||
import { asyncMap, resolveMember, tNullable } from "../../../utils";
|
||||
import { resolveActionContactMethods } from "../functions/resolveActionContactMethods";
|
||||
import { ModActionsPlugin } from "../../ModActions/ModActionsPlugin";
|
||||
|
||||
export const ChangeNicknameAction = automodAction({
|
||||
configType: t.type({
|
||||
name: t.string,
|
||||
}),
|
||||
|
||||
async apply({ pluginData, contexts, actionConfig }) {
|
||||
const members = contexts.map(c => c.member).filter(Boolean);
|
||||
const uniqueMembers = new Set(members);
|
||||
|
||||
for (const member of uniqueMembers) {
|
||||
if (pluginData.state.recentNicknameChanges.has(member.id)) continue;
|
||||
|
||||
member.edit({ nick: actionConfig.name }).catch(err => {
|
||||
/* TODO: Log this error */
|
||||
});
|
||||
|
||||
pluginData.state.recentNicknameChanges.set(member.id, { timestamp: Date.now() });
|
||||
}
|
||||
},
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue