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); });