diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..fb081ea --- /dev/null +++ b/.editorconfig @@ -0,0 +1,9 @@ +# EditorConfig is awesome: https://EditorConfig.org +root = true + +[*] +charset = utf-8 +end_of_line = lf +indent_size = 2 +indent_style = space +insert_final_newline = true diff --git a/index.js b/index.js index f190db6..f3316b5 100644 --- a/index.js +++ b/index.js @@ -46,6 +46,11 @@ async function findThreadByIssueNumber(issueNumber) { return thread; } +async function getStarterMessage(thread) { + const messages = await thread.messages.fetch({ limit: 1 }); + return messages.first(); +} + app.post("/webhook", async (req, res) => { try { // Verify webhook signature @@ -120,6 +125,14 @@ app.post("/webhook", async (req, res) => { if (thread) { if (action === "closed" && pull_request.merged) { await thread.send(`**${sender.login} merged this PR**`); + const message = await getStarterMessage(thread); + if (message) { + await message.react( + message.guild.emojis.cache.find( + (emoji) => emoji.name === "pr_merged", + ), + ); + } } else { await thread.send(`**${sender.login} ${action} this PR**`); }