mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
Discord: implement role allowlist with OR logic in preflight
This commit is contained in:
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user