1
0
Fork 0
polaris-task-force/src/bot/lib/roles.ts
Z8MB1E d3890cc191 feat(discord): integrate RBAC into Discord bot
Replace legacy role-name checks in isStaff with hasPermission(discord:staff).
Auto-assign the 'user' role document on signup. Import hasPermission in
announce command for future permission gating.
2026-08-19 19:48:28 -04:00

14 lines
609 B
TypeScript

import type { GuildMember } from "discord.js";
import type { Payload } from "payload";
import { botConfig } from "@/bot/config";
import { findUserByDiscordId } from "@/bot/lib/resolve";
import { hasPermission } from "@/utils/access-control/hasPermission";
export const isStaff = async (member: GuildMember, payload: Payload): Promise<boolean> => {
if (member.roles.cache.some((role) => botConfig.staffRoleIds.includes(role.id))) {
return true;
}
const user = await findUserByDiscordId(payload, member.id);
if (!user) return false;
return await hasPermission(payload, user, "discord:staff");
};