Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions backend/src/plugins/Automod/actions/reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, AutomodContext[]>, 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());

Expand Down
Loading