diff --git a/src/handlers/channel.ts b/src/handlers/channel.ts index 0f7b1a62e..ddfe12405 100644 --- a/src/handlers/channel.ts +++ b/src/handlers/channel.ts @@ -33,8 +33,8 @@ export function hasChannelPermission( return permissions.every((perm) => { if (overwrite) { - if (BigInt(overwrite.deny_new) & BigInt(perm)) return false; - if (BigInt(overwrite.allow_new) & BigInt(perm)) return true; + if (BigInt(overwrite.deny) & BigInt(perm)) return false; + if (BigInt(overwrite.allow) & BigInt(perm)) return true; } if (channel.guildID) { return botHasPermission(channel.guildID, [perm]); diff --git a/src/structures/channel.ts b/src/structures/channel.ts index 101f8d38d..572443d98 100644 --- a/src/structures/channel.ts +++ b/src/structures/channel.ts @@ -31,8 +31,8 @@ export function createChannel(data: ChannelCreatePayload, guildID?: string) { permissions: data.permission_overwrites ? data.permission_overwrites.map((perm) => ({ ...perm, - allow: calculatePermissions(BigInt(perm.allow_new)), - deny: calculatePermissions(BigInt(perm.deny_new)), + allow: calculatePermissions(BigInt(perm.allow)), + deny: calculatePermissions(BigInt(perm.deny)), })) : [], /** Whether this channel is nsfw or not */ diff --git a/src/types/guild.ts b/src/types/guild.ts index e5082469e..30df17c75 100644 --- a/src/types/guild.ts +++ b/src/types/guild.ts @@ -467,9 +467,9 @@ export interface RawOverwrite { /** The permissions that this id is NOT allowed to do. (This will mark it as a red x.) */ deny: number; /** permission bit set for new perms until new api version released. */ - allow_new: string; + allow: string; /** permission bit set for new perms until new api version released. */ - deny_new: string; + deny: string; } export interface ChannelCreateOptions { diff --git a/src/utils/permissions.ts b/src/utils/permissions.ts index d85fa70d5..468025864 100644 --- a/src/utils/permissions.ts +++ b/src/utils/permissions.ts @@ -48,7 +48,10 @@ export function memberHasPermission( ); } -export async function botHasPermission(guildID: string, permissions: Permissions[]) { +export async function botHasPermission( + guildID: string, + permissions: Permissions[], +) { const guild = await cacheHandlers.get("guilds", guildID); if (!guild) return false; @@ -111,9 +114,7 @@ export async function hasChannelPermissions( if (memberOverwrite) { // One of the necessary permissions is denied if ( - permissions.some((perm) => - BigInt(memberOverwrite.deny_new) & BigInt(perm) - ) + permissions.some((perm) => BigInt(memberOverwrite.deny) & BigInt(perm)) ) { return false; } @@ -121,7 +122,7 @@ export async function hasChannelPermissions( // Already allowed perm if (allowedPermissions.has(perm)) return; // This perm is allowed so we save it - if (BigInt(memberOverwrite.allow_new) & BigInt(perm)) { + if (BigInt(memberOverwrite.allow) & BigInt(perm)) { allowedPermissions.add(perm); } }); @@ -132,11 +133,11 @@ export async function hasChannelPermissions( if ( rolesOverwrites.some((overwrite) => permissions.some((perm) => - (BigInt(overwrite.deny_new) & BigInt(perm)) && + (BigInt(overwrite.deny) & BigInt(perm)) && // If another role allows these perms then they are not denied - !rolesOverwrites.some((o) => BigInt(o.allow_new) & BigInt(perm)) && + !rolesOverwrites.some((o) => BigInt(o.allow) & BigInt(perm)) && // Make sure the memberOverwrite does not allow this perm - !(memberOverwrite && BigInt(memberOverwrite.allow_new) & BigInt(perm)) + !(memberOverwrite && BigInt(memberOverwrite.allow) & BigInt(perm)) ) ) ) { @@ -148,7 +149,7 @@ export async function hasChannelPermissions( if (allowedPermissions.has(perm)) return; rolesOverwrites.forEach((overwrite) => { // This perm is allowed so we save it - if (BigInt(overwrite.allow_new) & BigInt(perm)) { + if (BigInt(overwrite.allow) & BigInt(perm)) { allowedPermissions.add(perm); } }); @@ -161,7 +162,7 @@ export async function hasChannelPermissions( ) { if ( permissions.some((perm) => - BigInt(everyoneOverwrite.deny_new) & BigInt(perm) && + BigInt(everyoneOverwrite.deny) & BigInt(perm) && !allowedPermissions.has(perm) ) ) { @@ -170,7 +171,7 @@ export async function hasChannelPermissions( // If all permissions are granted if ( permissions.every((perm) => - BigInt(everyoneOverwrite.allow_new) & BigInt(perm) + BigInt(everyoneOverwrite.allow) & BigInt(perm) ) ) { return true;