Discord: implement role allowlist with OR logic in preflight

This commit is contained in:
Minidoracat
2026-01-29 10:26:40 +00:00
committed by Shadow
parent 8ff89ba14c
commit 4c0ce46ac3

View File

@@ -181,6 +181,20 @@ export function resolveDiscordOwnerAllowFrom(params: {
return [match.matchKey];
}
export function resolveDiscordRoleAllowed(params: {
allowList?: Array<string | number>;
memberRoleIds: string[];
}) {
const allowList = normalizeDiscordAllowList(params.allowList, ["role:"]);
if (!allowList) {
return true;
}
if (allowList.allowAll) {
return true;
}
return params.memberRoleIds.some((roleId) => allowList.ids.has(roleId));
}
export function resolveDiscordCommandAuthorized(params: {
isDirectMessage: boolean;
allowFrom?: Array<string | number>;