3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-23 01:25:02 +00:00
zeppelin/backend/src/plugins/Spam/events/SpamVoiceEvt.ts
2021-08-20 19:05:59 +02:00

30 lines
869 B
TypeScript

import { RecentActionType, spamEvt } from "../types";
import { logAndDetectOtherSpam } from "../util/logAndDetectOtherSpam";
export const SpamVoiceStateUpdateEvt = spamEvt({
event: "voiceStateUpdate",
async listener(meta) {
const member = meta.args.newState.member;
if (!member) return;
const channel = meta.args.newState.channel;
if (!channel) return;
if (channel.id === meta.args.oldState?.id) return;
const config = await meta.pluginData.config.getMatchingConfig({ member, channelId: channel.id });
const maxVoiceMoves = config.max_voice_moves;
if (maxVoiceMoves) {
logAndDetectOtherSpam(
meta.pluginData,
RecentActionType.VoiceChannelMove,
maxVoiceMoves,
member.id,
1,
"0",
Date.now(),
null,
"too many voice channel moves",
);
}
},
});