From bea86bb47be02bd82ec7fe1e6af78fa1135badc8 Mon Sep 17 00:00:00 2001 From: LTS20050703 <87189679+lts20050703@users.noreply.github.com> Date: Sat, 19 Feb 2022 21:29:12 +0700 Subject: [PATCH] fix(helpers): when creating/modifying a channel `permission_overwrites` can omit the `allow` and `deny` (#2053) Clarify that permission_overwrites can omit allow and deny keys when creating/modifying channel/channel ovewrites --- helpers/channels/createChannel.ts | 10 +++++----- helpers/channels/editChannel.ts | 13 ++++++------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/helpers/channels/createChannel.ts b/helpers/channels/createChannel.ts index 58ff87760..5992c30ff 100644 --- a/helpers/channels/createChannel.ts +++ b/helpers/channels/createChannel.ts @@ -22,11 +22,11 @@ export async function createChannel(bot: Bot, guildId: bigint, options?: CreateG position: options.position, parent_id: options.parentId?.toString(), nsfw: options.nsfw, - permission_overwrites: options?.permissionOverwrites?.map((perm) => ({ - id: perm.id.toString(), - type: perm.type, - allow: perm.allow ? bot.utils.calculateBits(perm.allow) : "0", - deny: perm.deny ? bot.utils.calculateBits(perm.deny) : "0", + permission_overwrites: options?.permissionOverwrites?.map((overwrite) => ({ + id: overwrite.id.toString(), + type: overwrite.type, + allow: overwrite.allow ? bot.utils.calculateBits(overwrite.allow) : null, + deny: overwrite.deny ? bot.utils.calculateBits(overwrite.deny) : null, })), type: options?.type || ChannelTypes.GuildText, reason, diff --git a/helpers/channels/editChannel.ts b/helpers/channels/editChannel.ts index 8e67ec0b2..9c6455795 100644 --- a/helpers/channels/editChannel.ts +++ b/helpers/channels/editChannel.ts @@ -46,13 +46,12 @@ export async function editChannel(bot: Bot, channelId: bigint, options: ModifyCh locked: options.locked, invitable: options.invitable, permission_overwrites: options.permissionOverwrites - ? options.permissionOverwrites?.map((overwrite) => { - return { - ...overwrite, - allow: overwrite.allow ? bot.utils.calculateBits(overwrite.allow) : "0", - deny: overwrite.deny ? bot.utils.calculateBits(overwrite.deny) : "0", - }; - }) + ? options.permissionOverwrites?.map((overwrite) => ({ + id: overwrite.id.toString(), + type: overwrite.type, + allow: overwrite.allow ? bot.utils.calculateBits(overwrite.allow) : null, + deny: overwrite.deny ? bot.utils.calculateBits(overwrite.deny) : null, + })) : undefined, reason, });