From 4e39f327a51ffb315e0da31c7cf61b131fa267f9 Mon Sep 17 00:00:00 2001 From: ayyanm Date: Thu, 29 Oct 2020 12:19:57 -0700 Subject: [PATCH] New PermissionOverwrite interface --- src/structures/channel.ts | 16 +++++++++------- src/types/guild.ts | 6 ++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/structures/channel.ts b/src/structures/channel.ts index 0405dd03b..fe8848cc8 100644 --- a/src/structures/channel.ts +++ b/src/structures/channel.ts @@ -1,5 +1,6 @@ import { cacheHandlers } from "../controllers/cache.ts"; import { ChannelCreatePayload } from "../types/channel.ts"; +import { PermissionOverwrite } from "../types/guild.ts"; import { Unpromise } from "../types/misc.ts"; import { calculatePermissions } from "../utils/permissions.ts"; @@ -33,13 +34,14 @@ export async function createChannel( /** The last time when a message was pinned in this channel */ lastPinTimestamp, /** The permission overwrites for this channel */ - permissionOverwrites: data.permission_overwrites - ? data.permission_overwrites.map((perm) => ({ - ...perm, - allow: calculatePermissions(BigInt(perm.allow)), - deny: calculatePermissions(BigInt(perm.deny)), - })) - : [], + permissionOverwrites: + (data.permission_overwrites + ? data.permission_overwrites.map((perm) => ({ + ...perm, + allow: calculatePermissions(BigInt(perm.allow)), + deny: calculatePermissions(BigInt(perm.deny)), + })) + : []) as PermissionOverwrite[], /** Whether this channel is nsfw or not */ nsfw: data.nsfw || false, /** The mention of the channel */ diff --git a/src/types/guild.ts b/src/types/guild.ts index 590428f64..ba52fedfd 100644 --- a/src/types/guild.ts +++ b/src/types/guild.ts @@ -473,6 +473,12 @@ export interface RawOverwrite { deny: number; } +export interface PermissionOverwrite + extends Omit { + allow: Permission[]; + deny: Permission[]; +} + export interface ChannelCreateOptions { /** The type of the channel */ type?: ChannelTypes;