type Github = {
token: string;
};
/**
* Create a discussion comment
* Creates a new comment on a team discussion.
*/
export async function main(
auth: Github,
org: string,
team_slug: string,
discussion_number: string,
body: { body: string; [k: string]: unknown }
) {
const url = new URL(
`https://api.github.com/orgs/${org}/teams/${team_slug}/discussions/${discussion_number}/comments`
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 486 days ago