From d74afbee5cae8bf011af423c75aa0b608e0e8601 Mon Sep 17 00:00:00 2001 From: Almeida Date: Sat, 8 May 2021 14:17:45 +0100 Subject: [PATCH] merged all events into one file --- .../Automod/events/runAutomodOnVoiceEvents.ts | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 backend/src/plugins/Automod/events/runAutomodOnVoiceEvents.ts diff --git a/backend/src/plugins/Automod/events/runAutomodOnVoiceEvents.ts b/backend/src/plugins/Automod/events/runAutomodOnVoiceEvents.ts new file mode 100644 index 00000000..fd0db61f --- /dev/null +++ b/backend/src/plugins/Automod/events/runAutomodOnVoiceEvents.ts @@ -0,0 +1,58 @@ +import { guildEventListener } from "knub"; +import { AutomodContext, AutomodPluginType } from "../types"; +import { runAutomod } from "../functions/runAutomod"; + +export const RunAutomodOnVoiceJoin = guildEventListener()( + "voiceChannelJoin", + ({ pluginData, args: { member, newChannel } }) => { + const context: AutomodContext = { + member, + timestamp: Date.now(), + voiceChannel: { + joined: newChannel, + }, + user: member.user, + }; + + pluginData.state.queue.add(() => { + runAutomod(pluginData, context); + }); + }, +); + +export const RunAutomodOnVoiceLeave = guildEventListener()( + "voiceChannelLeave", + ({ pluginData, args: { member, oldChannel } }) => { + const context: AutomodContext = { + member, + timestamp: Date.now(), + voiceChannel: { + left: oldChannel, + }, + user: member.user, + }; + + pluginData.state.queue.add(() => { + runAutomod(pluginData, context); + }); + }, +); + +export const RunAutomodOnVoiceSwitch = guildEventListener()( + "voiceChannelSwitch", + ({ pluginData, args: { member, oldChannel, newChannel } }) => { + const context: AutomodContext = { + member, + timestamp: Date.now(), + voiceChannel: { + left: oldChannel, + joined: newChannel, + }, + user: member.user, + }; + + pluginData.state.queue.add(() => { + runAutomod(pluginData, context); + }); + }, +);