feat: add hasPermission util to check if a member has a specific permission
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
This commit is contained in:
parent
695bdbc777
commit
aecbcaefba
1 changed files with 11 additions and 0 deletions
11
utils/hasPermission.ts
Normal file
11
utils/hasPermission.ts
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
import type { Permission } from "~/types/enums";
|
||||||
|
import type { GuildMemberResponse } from "~/types/interfaces";
|
||||||
|
|
||||||
|
export default (member: GuildMemberResponse, permission: Permission) => {
|
||||||
|
for (const role of member.roles) {
|
||||||
|
if (role.permissions & permission) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue