From 5ad461260ac29f7f403fbe2e95718c574d1068c9 Mon Sep 17 00:00:00 2001 From: almeidx Date: Sat, 14 Aug 2021 16:33:01 +0100 Subject: [PATCH] cleaned up the event --- .../events/runAutomodOnVoiceStateUpdate.ts | 50 +++++++------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/backend/src/plugins/Automod/events/runAutomodOnVoiceStateUpdate.ts b/backend/src/plugins/Automod/events/runAutomodOnVoiceStateUpdate.ts index 1726f35c..18c8c518 100644 --- a/backend/src/plugins/Automod/events/runAutomodOnVoiceStateUpdate.ts +++ b/backend/src/plugins/Automod/events/runAutomodOnVoiceStateUpdate.ts @@ -13,43 +13,27 @@ export const RunAutomodOnVoiceStateUpdate = typedGuildEventListener { - runAutomod(pluginData, context); - }); + context.voiceChannel!.joined = newChannel; + addToQueue = true; } else if (oldChannel && !newChannel) { - const context: AutomodContext = { - member, - timestamp, - voiceChannel: { - left: oldChannel, - }, - user: member.user, - }; - - pluginData.state.queue.add(() => { - runAutomod(pluginData, context); - }); + context.voiceChannel!.left = oldChannel; + addToQueue = true; } else if (oldChannel?.id && newChannel?.id && oldChannel.id === newChannel.id) { - const context: AutomodContext = { - member, - timestamp, - voiceChannel: { - left: oldChannel, - joined: newChannel, - }, - user: member.user, - }; + context.voiceChannel!.left = oldChannel; + context.voiceChannel!.joined = newChannel; + addToQueue = true; + } + if (addToQueue) { pluginData.state.queue.add(() => { runAutomod(pluginData, context); });