mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 09:11:26 +00:00
fix(discord): role-based allowlist never matches (Carbon Role objects stringify to mentions) (#16369)
* fix(discord): role-based allowlist never matches because Carbon Role objects stringify to mentions Carbon's GuildMember.roles getter returns Role[] objects, not raw ID strings. String(Role) produces '<@&123456>' which never matches the plain role IDs in the guild allowlist config. Use data.rawMember.roles (raw Discord API string array) instead of data.member.roles (Carbon Role[] objects) for role ID extraction. Fixes #16207 * Docs: add discord role allowlist changelog entry --------- Co-authored-by: Shadow <hi@shadowing.dev>
This commit is contained in:
@@ -272,8 +272,8 @@ async function handleDiscordReactionEvent(params: {
|
||||
const authorLabel = message?.author ? formatDiscordUserTag(message.author) : undefined;
|
||||
const baseText = `Discord reaction ${action}: ${emojiLabel} by ${actorLabel} on ${guildSlug} ${channelLabel} msg ${data.message_id}`;
|
||||
const text = authorLabel ? `${baseText} from ${authorLabel}` : baseText;
|
||||
const memberRoleIds = Array.isArray(data.member?.roles)
|
||||
? data.member.roles.map((roleId: string) => String(roleId))
|
||||
const memberRoleIds = Array.isArray(data.rawMember?.roles)
|
||||
? data.rawMember.roles.map((roleId: string) => String(roleId))
|
||||
: [];
|
||||
const route = resolveAgentRoute({
|
||||
cfg: params.cfg,
|
||||
|
||||
@@ -224,8 +224,8 @@ export async function preflightDiscordMessage(
|
||||
}
|
||||
|
||||
// Fresh config for bindings lookup; other routing inputs are payload-derived.
|
||||
const memberRoleIds = Array.isArray(params.data.member?.roles)
|
||||
? params.data.member.roles.map((roleId: string) => String(roleId))
|
||||
const memberRoleIds = Array.isArray(params.data.rawMember?.roles)
|
||||
? params.data.rawMember.roles.map((roleId: string) => String(roleId))
|
||||
: [];
|
||||
const route = resolveAgentRoute({
|
||||
cfg: loadConfig(),
|
||||
|
||||
Reference in New Issue
Block a user