mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-25 10:25:01 +00:00
check no perms for overrides
This commit is contained in:
parent
42c56db858
commit
fb91250208
1 changed files with 7 additions and 0 deletions
|
@ -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<Record<PermissionString, boolean | null>> = {};
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue