From def092b06651d3c3510711198c7c08ec72c9eae1 Mon Sep 17 00:00:00 2001 From: lauriechammah Date: Wed, 28 Oct 2026 15:57:02 -0400 Subject: [PATCH] feat: Enhance Discord bot user mapping and PR merge notifications --- .github/discord-bot/config.mjs | 14 +++++++++++++- .github/discord-bot/handlers/pull_request.mjs | 1 + 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/discord-bot/config.mjs b/.github/discord-bot/config.mjs index ab25713..99b23bb 100644 --- a/.github/discord-bot/config.mjs +++ b/.github/discord-bot/config.mjs @@ -59,7 +59,19 @@ function loadUserMap() { const map = {} for (const [login, id] of Object.entries(raw)) { if (login.startsWith('_')) continue // comment keys - map[login.toLowerCase()] = String(id) + + // Discord rejects the whole message (400 on allowed_mentions) if a single id is + // not a snowflake, so one bad entry would silence the bot for everyone. Accept a + // pasted "<@123>" mention, and skip anything else that is not a bare id. + const snowflake = String(id).match(/^?$/)?.[1] + if (typeof id === 'number' || !snowflake) { + console.warn( + `::warning::DISCORD_USER_MAP entry for "${login}" is not a Discord user id ` + + '(must be a quoted string of 17-20 digits, e.g. "123456789012345678"); skipped.', + ) + continue + } + map[login.toLowerCase()] = snowflake } return map } diff --git a/.github/discord-bot/handlers/pull_request.mjs b/.github/discord-bot/handlers/pull_request.mjs index b671ce8..f5ba21f 100644 --- a/.github/discord-bot/handlers/pull_request.mjs +++ b/.github/discord-bot/handlers/pull_request.mjs @@ -117,6 +117,7 @@ async function onClosed(payload) { const closes = closesIssues(pr) await sendDiscord({ + review: true, content: `${mention(author)} — your PR #${pr.number} was merged into \`${pr.base?.ref}\` by ${mention(merger)}. 🎉`, pingLogins: [...new Set([author, merger].filter(Boolean))], embed: prEmbed(pr, repository, COLORS.merged, [