diff --git a/backend/src/plugins/Automod/triggers/joinVoiceChannel.ts b/backend/src/plugins/Automod/triggers/joinVoiceChannel.ts index 16723584..55ff01ac 100644 --- a/backend/src/plugins/Automod/triggers/joinVoiceChannel.ts +++ b/backend/src/plugins/Automod/triggers/joinVoiceChannel.ts @@ -7,17 +7,23 @@ interface JoinVoiceChannelResult { } export const JoinVoiceChannelTrigger = automodTrigger()({ - configType: t.union([t.string, t.array(t.string)]), + configType: t.type({ + channels: t.union([t.string, t.array(t.string)]), + include_moves: t.boolean, + }), - defaultConfig: "", + defaultConfig: {}, async match({ triggerConfig, context }) { const matchedChannelId = context.voiceChannel?.joined?.id; - if (!context.member || !matchedChannelId || context.voiceChannel?.left) { + const includeMoves = + typeof triggerConfig === "object" && !Array.isArray(triggerConfig) && triggerConfig.include_moves; + + if (!context.member || !matchedChannelId || (context.voiceChannel?.left && !includeMoves)) { return; } - const triggerChannels = Array.isArray(triggerConfig) ? triggerConfig : [triggerConfig]; + const triggerChannels = Array.isArray(triggerConfig.channels) ? triggerConfig.channels : [triggerConfig.channels]; if (!triggerChannels.includes(matchedChannelId)) { return; } diff --git a/backend/src/plugins/Automod/triggers/leaveVoiceChannel.ts b/backend/src/plugins/Automod/triggers/leaveVoiceChannel.ts index 4c8d2e09..91ffb27d 100644 --- a/backend/src/plugins/Automod/triggers/leaveVoiceChannel.ts +++ b/backend/src/plugins/Automod/triggers/leaveVoiceChannel.ts @@ -7,17 +7,23 @@ interface LeaveVoiceChannelResult { } export const LeaveVoiceChannelTrigger = automodTrigger()({ - configType: t.union([t.string, t.array(t.string)]), + configType: t.type({ + channels: t.union([t.string, t.array(t.string)]), + include_moves: t.boolean, + }), - defaultConfig: "", + defaultConfig: {}, async match({ triggerConfig, context }) { const matchedChannelId = context.voiceChannel?.left?.id; - if (!context.member || !matchedChannelId || context.voiceChannel?.joined) { + const includeMoves = + typeof triggerConfig === "object" && !Array.isArray(triggerConfig) && triggerConfig.include_moves; + + if (!context.member || !matchedChannelId || (context.voiceChannel?.joined && !includeMoves)) { return; } - const triggerChannels = Array.isArray(triggerConfig) ? triggerConfig : [triggerConfig]; + const triggerChannels = Array.isArray(triggerConfig.channels) ? triggerConfig.channels : [triggerConfig.channels]; if (!triggerChannels.includes(matchedChannelId)) { return; }