From 7bd7b1127ada65985035197ee952f7d4e20a932d Mon Sep 17 00:00:00 2001 From: Rei Star Date: Mon, 17 Feb 2025 18:50:02 +0400 Subject: [PATCH] feat: make the reply action work for triggers without a message --- backend/src/plugins/Automod/actions/reply.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/src/plugins/Automod/actions/reply.ts b/backend/src/plugins/Automod/actions/reply.ts index aade027d..da83de9a 100644 --- a/backend/src/plugins/Automod/actions/reply.ts +++ b/backend/src/plugins/Automod/actions/reply.ts @@ -31,18 +31,19 @@ export const ReplyAction = automodAction({ async apply({ pluginData, contexts, actionConfig, ruleName }) { const contextsWithTextChannels = contexts - .filter((c) => c.message?.channel_id) + .filter((c) => c.channel?.id ?? c.message?.channel_id) .filter((c) => { - const channel = pluginData.guild.channels.cache.get(c.message!.channel_id as Snowflake); + const channel = pluginData.guild.channels.cache.get(c.channel?.id || c.message!.channel_id as Snowflake); return channel?.isTextBased(); }); const contextsByChannelId = contextsWithTextChannels.reduce((map: Map, context) => { - if (!map.has(context.message!.channel_id)) { - map.set(context.message!.channel_id, []); + const channelId = context.channel?.id ?? context.message!.channel_id + if (!map.has(channelId)) { + map.set(channelId, []); } - map.get(context.message!.channel_id)!.push(context); + map.get(channelId)!.push(context); return map; }, new Map());