From 7a52f301b3b3d4348f4889847615c6d2a1f96032 Mon Sep 17 00:00:00 2001 From: ayntee Date: Sat, 27 Feb 2021 23:54:37 +0400 Subject: [PATCH] fix(util/permissions): move owner check before member cache check (#555) --- src/util/permissions.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/permissions.ts b/src/util/permissions.ts index 97a97ac27..8579cb99b 100644 --- a/src/util/permissions.ts +++ b/src/util/permissions.ts @@ -52,15 +52,15 @@ export async function botHasPermission( guildID: string, permissions: Permission[], ) { - const member = await cacheHandlers.get("members", botID); - if (!member) return false; - const guild = await cacheHandlers.get("guilds", guildID); if (!guild) return false; // Check if the bot is the owner of the guild, if it is, returns true if (guild.ownerID === botID) return true; + const member = await cacheHandlers.get("members", botID); + if (!member) return false; + // The everyone role is not in member.roles const permissionBits = [...member.guilds.get(guildID)?.roles || [], guild.id] .map((id) => guild.roles.get(id)!)