Fix customEvents channel perms overwrites (#253)
This commit is contained in:
parent
6cddcb9074
commit
d5da50c0ed
1 changed files with 12 additions and 5 deletions
|
@ -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 * as t from "io-ts";
|
||||||
import { GuildPluginData } from "knub";
|
import { GuildPluginData } from "knub";
|
||||||
import { ActionError } from "../ActionError";
|
import { ActionError } from "../ActionError";
|
||||||
|
@ -32,10 +32,17 @@ export async function setChannelPermissionOverridesAction(
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const override of action.overrides) {
|
for (const override of action.overrides) {
|
||||||
channel.permissionOverwrites.create(
|
const allow = new Permissions(BigInt(override.allow)).serialize();
|
||||||
override.id as Snowflake,
|
const deny = new Permissions(BigInt(override.deny)).serialize();
|
||||||
new Permissions(BigInt(override.allow)).remove(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(
|
await channel.permissionOverwrites overwritePermissions(
|
||||||
|
|
Loading…
Add table
Reference in a new issue