3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-25 10:25:01 +00:00
zeppelin/backend/src/plugins/Automod/functions/clearOldNicknameChanges.ts

12 lines
496 B
TypeScript

import { GuildPluginData } from "knub";
import { RECENT_NICKNAME_CHANGE_EXPIRY_TIME } from "../constants";
import { AutomodPluginType } from "../types";
export function clearOldRecentNicknameChanges(pluginData: GuildPluginData<AutomodPluginType>) {
const now = Date.now();
for (const [userId, { timestamp }] of pluginData.state.recentNicknameChanges) {
if (timestamp + RECENT_NICKNAME_CHANGE_EXPIRY_TIME <= now) {
pluginData.state.recentNicknameChanges.delete(userId);
}
}
}