mirror of
https://github.com/ReCloudStudio/WebHooker.git
synced 2026-09-23 00:21:28 +00:00
feat: add merge/close PR buttons to Discord PR notifications
This commit is contained in:
parent
d40f34cc4d
commit
44b8fead78
9 changed files with 223 additions and 3 deletions
|
|
@ -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 } : {}),
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue