mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-16 11:28:15 +00:00
Merge branch 'master' of https://github.com/Skillz4Killz/Discordeno into unit-tests
This commit is contained in:
@@ -34,6 +34,8 @@ export function memberHasPermission(
|
||||
const permissionBits = memberRoleIDs.map((id) =>
|
||||
guild.roles.get(id)?.permissions
|
||||
)
|
||||
// Removes any edge case undefined
|
||||
.filter((id) => id)
|
||||
.reduce((bits, permissions) => {
|
||||
bits |= BigInt(permissions);
|
||||
return bits;
|
||||
@@ -86,13 +88,18 @@ export async function hasChannelPermissions(
|
||||
permissions: Permissions[],
|
||||
) {
|
||||
const channel = await cacheHandlers.get("channels", channelID);
|
||||
if (!channel?.guildID) return true;
|
||||
if (!channel) return false;
|
||||
if (!channel.guildID) return true;
|
||||
|
||||
const guild = await cacheHandlers.get("guilds", channel.guildID);
|
||||
if (!guild) return false;
|
||||
|
||||
if (guild.ownerID === memberID) return true;
|
||||
if (botHasPermission(guild.id, [Permissions.ADMINISTRATOR])) return true;
|
||||
if (
|
||||
await memberIDHasPermission(memberID, guild.id, ["ADMINISTRATOR"])
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const member = guild.members.get(memberID);
|
||||
if (!member) return false;
|
||||
|
||||
Reference in New Issue
Block a user