From d8a8813c9187e5e74d11ce5785fa32211ab68c63 Mon Sep 17 00:00:00 2001 From: Dark <7890309+DarkView@users.noreply.github.com> Date: Sat, 3 Apr 2021 20:58:17 +0200 Subject: [PATCH] Allow whole categories to be used to set slowmode --- .../src/plugins/Automod/actions/setSlowmode.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/backend/src/plugins/Automod/actions/setSlowmode.ts b/backend/src/plugins/Automod/actions/setSlowmode.ts index 3f1b9f56..810077dd 100644 --- a/backend/src/plugins/Automod/actions/setSlowmode.ts +++ b/backend/src/plugins/Automod/actions/setSlowmode.ts @@ -2,6 +2,7 @@ import * as t from "io-ts"; import { automodAction } from "../helpers"; import { convertDelayStringToMS, isDiscordRESTError, tDelayString, tNullable } from "../../../utils"; import { LogType } from "../../../data/LogType"; +import { AnyGuildChannel } from "eris"; export const SetSlowmodeAction = automodAction({ configType: t.type({ @@ -21,10 +22,19 @@ export const SetSlowmodeAction = automodAction({ // 2 = Guild Voice, 5 = Guild News - Both dont allow slowmode if (!channel || channel.type === 2 || channel.type === 5) continue; + let channelsToSlowmode: AnyGuildChannel[] = []; + if (channel.type === 4) { + channelsToSlowmode = pluginData.guild.channels.filter(ch => ch.parentID === channel.id && ch.type === 0); + } else { + channelsToSlowmode.push(channel); + } + try { - await channel.edit({ - rateLimitPerUser: duration / 1000, // ms -> seconds - }); + for (const chan of channelsToSlowmode) { + await chan.edit({ + rateLimitPerUser: duration / 1000, // ms -> seconds + }); + } } catch (e) { let errorMessage = e;