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.
14 lines
609 B
TypeScript
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");
|
|
};
|