feat: add merge/close PR buttons to Discord PR notifications

This commit is contained in:
RhenCloud 2026-08-02 23:02:37 +08:00
parent d40f34cc4d
commit 44b8fead78
No known key found for this signature in database
GPG key ID: A574A617378C4E0B
9 changed files with 223 additions and 3 deletions

View file

@ -311,6 +311,22 @@ function formatPullRequest(
});
}
// Merge / close buttons on the Discord notification. They only make sense
// while the PR is still open. custom_id encodes the action + owner/repo/number
// (repo full_name never contains "|").
const actionable = pr.state === "open" && !!repo && pr.number != null;
const components = actionable
? [
{
type: 1,
components: [
{ type: 2, style: 3, label: "合并", custom_id: `ghpr|merge|${repo}|${pr.number}` },
{ type: 2, style: 4, label: "关闭", custom_id: `ghpr|close|${repo}|${pr.number}` },
],
},
]
: undefined;
return {
embeds: [
{
@ -324,6 +340,7 @@ function formatPullRequest(
timestamp: new Date().toISOString(),
},
],
...(components ? { components } : {}),
};
}