3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-20 16:25:03 +00:00

Allow whole categories to be used to set slowmode

This commit is contained in:
Dark 2021-04-03 20:58:17 +02:00
parent db3d1d7c3b
commit d8a8813c91
No known key found for this signature in database
GPG key ID: 384C4B4F5B1E25A8

View file

@ -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;