3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-15 05:41:51 +00:00

Fix customEvents channel perms overwrites (#253)

This commit is contained in:
metal 2021-09-04 17:13:29 +01:00 committed by GitHub
parent 6cddcb9074
commit d5da50c0ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,4 @@
import { Permissions, Snowflake, TextChannel } from "discord.js";
import { Permissions, Snowflake, TextChannel, PermissionString } from "discord.js";
import * as t from "io-ts";
import { GuildPluginData } from "knub";
import { ActionError } from "../ActionError";
@ -32,10 +32,17 @@ export async function setChannelPermissionOverridesAction(
}
for (const override of action.overrides) {
channel.permissionOverwrites.create(
override.id as Snowflake,
new Permissions(BigInt(override.allow)).remove(BigInt(override.deny)).serialize(),
);
const allow = new Permissions(BigInt(override.allow)).serialize();
const deny = new Permissions(BigInt(override.deny)).serialize();
const perms: Partial<Record<PermissionString, boolean | null>> = {};
for (const key in allow) {
if (allow[key]) {
perms[key] = true;
} else if (deny[key]) {
perms[key] = false;
}
}
channel.permissionOverwrites.create(override.id as Snowflake, perms);
/*
await channel.permissionOverwrites overwritePermissions(