Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion .github/discord-bot/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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(/^<?@?!?(\d{17,20})>?$/)?.[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
}
Expand Down
1 change: 1 addition & 0 deletions .github/discord-bot/handlers/pull_request.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down
Loading