From fb91250208c50221ee6df33ac9e31c8d677bf92d Mon Sep 17 00:00:00 2001 From: metal Date: Fri, 10 Dec 2021 13:46:17 +0000 Subject: [PATCH] check no perms for overrides --- backend/src/plugins/Automod/actions/changePerms.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/src/plugins/Automod/actions/changePerms.ts b/backend/src/plugins/Automod/actions/changePerms.ts index 5d8afdb6..fd27094f 100644 --- a/backend/src/plugins/Automod/actions/changePerms.ts +++ b/backend/src/plugins/Automod/actions/changePerms.ts @@ -31,6 +31,7 @@ export const ChangePermsAction = automodAction({ const allow = new Permissions(overwrite ? overwrite.allow : "0").serialize(); const deny = new Permissions(overwrite ? overwrite.deny : "0").serialize(); const newPerms: Partial> = {}; + let hasPerms = false; for (const key in allow) { if (typeof actionConfig.perms[key] !== "undefined") { @@ -39,10 +40,16 @@ export const ChangePermsAction = automodAction({ } if (allow[key]) { newPerms[key] = true; + hasPerms = true; } else if (deny[key]) { newPerms[key] = false; + hasPerms = true; } } + if (overwrite && !hasPerms) { + await channel.permissionOverwrites.delete(actionConfig.target).catch(noop); + return; + } await channel.permissionOverwrites.create(actionConfig.target, newPerms).catch(noop); return; }