| 40 | } |
| 41 | |
| 42 | async function close(num: number) { |
| 43 | const base = `https://api.github.com/repos/${repo}/issues/${num}` |
| 44 | |
| 45 | const comment = await fetch(`${base}/comments`, { |
| 46 | method: "POST", |
| 47 | headers, |
| 48 | body: JSON.stringify({ body: msg }), |
| 49 | }) |
| 50 | if (!comment.ok) throw new Error(`Failed to comment #${num}: ${comment.status} ${comment.statusText}`) |
| 51 | |
| 52 | const patch = await fetch(base, { |
| 53 | method: "PATCH", |
| 54 | headers, |
| 55 | body: JSON.stringify({ state: "closed", state_reason: "not_planned" }), |
| 56 | }) |
| 57 | if (!patch.ok) throw new Error(`Failed to close #${num}: ${patch.status} ${patch.statusText}`) |
| 58 | |
| 59 | console.log(`Closed https://github.com/${repo}/issues/${num}`) |
| 60 | } |
| 61 | |
| 62 | async function main() { |
| 63 | let page = 1 |