mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 20:08:26 +00:00
fix: add discord role allowlists (#10650) (thanks @Minidoracat)
This commit is contained in:
@@ -179,7 +179,7 @@ function matchesRoles(
|
||||
if (!Array.isArray(roles) || roles.length === 0) {
|
||||
return false;
|
||||
}
|
||||
return roles.some((r) => memberRoleIds.includes(r));
|
||||
return roles.some((role) => memberRoleIds.includes(role));
|
||||
}
|
||||
|
||||
export function resolveAgentRoute(input: ResolveAgentRouteInput): ResolvedAgentRoute {
|
||||
@@ -234,15 +234,6 @@ export function resolveAgentRoute(input: ResolveAgentRouteInput): ResolvedAgentR
|
||||
}
|
||||
}
|
||||
|
||||
if (guildId && memberRoleIds.length > 0) {
|
||||
const guildRolesMatch = bindings.find(
|
||||
(b) => matchesGuild(b.match, guildId) && matchesRoles(b.match, memberRoleIds),
|
||||
);
|
||||
if (guildRolesMatch) {
|
||||
return choose(guildRolesMatch.agentId, "binding.guild+roles");
|
||||
}
|
||||
}
|
||||
|
||||
// Thread parent inheritance: if peer (thread) didn't match, check parent peer binding
|
||||
const parentPeer = input.parentPeer
|
||||
? { kind: input.parentPeer.kind, id: normalizeId(input.parentPeer.id) }
|
||||
@@ -254,6 +245,15 @@ export function resolveAgentRoute(input: ResolveAgentRouteInput): ResolvedAgentR
|
||||
}
|
||||
}
|
||||
|
||||
if (guildId && memberRoleIds.length > 0) {
|
||||
const guildRolesMatch = bindings.find(
|
||||
(b) => matchesGuild(b.match, guildId) && matchesRoles(b.match, memberRoleIds),
|
||||
);
|
||||
if (guildRolesMatch) {
|
||||
return choose(guildRolesMatch.agentId, "binding.guild+roles");
|
||||
}
|
||||
}
|
||||
|
||||
if (guildId) {
|
||||
const guildMatch = bindings.find(
|
||||
(b) =>
|
||||
|
||||
Reference in New Issue
Block a user