mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 09:20:08 +00:00
add new cleaner perm checker function
This commit is contained in:
@@ -7,6 +7,23 @@ import { botID } from "../module/client.ts";
|
||||
import { Role } from "../structures/role.ts";
|
||||
import { Guild } from "../structures/guild.ts";
|
||||
|
||||
/** Checks if the member has this permission. If the member is an owner or has admin perms it will always be true. */
|
||||
export function memberIDHasPermission(
|
||||
memberID: string,
|
||||
guildID: string,
|
||||
permissions: Permission[],
|
||||
) {
|
||||
const guild = cache.guilds.get(guildID);
|
||||
if (!guild) return false;
|
||||
|
||||
if (memberID === guild.ownerID) return true;
|
||||
|
||||
const member = guild.members.get(memberID);
|
||||
if (!member) return false;
|
||||
|
||||
return memberHasPermission(member.guildID, guild, member.roles, permissions)
|
||||
}
|
||||
|
||||
/** Checks if the member has this permission. If the member is an owner or has admin perms it will always be true. */
|
||||
export function memberHasPermission(
|
||||
memberID: string,
|
||||
|
||||
Reference in New Issue
Block a user