1 | |
2 |
|
3 | type DiscordWebhook = { |
4 | webhook_url: string; |
5 | }; |
6 | export async function main( |
7 | discord_webhook: DiscordWebhook, |
8 | messageId: string, |
9 | newMessageContent: string, |
10 | ) { |
11 | const response = await fetch( |
12 | `${discord_webhook.webhook_url}/messages/${messageId}`, |
13 | { |
14 | method: "PATCH", |
15 | headers: { |
16 | "Content-Type": "application/json", |
17 | }, |
18 | body: JSON.stringify({ content: newMessageContent }), |
19 | }, |
20 | ); |
21 | if (!response.ok) { |
22 | throw new Error(`${response.status} ${await response.text()}`); |
23 | } |
24 | return await response.json(); |
25 | } |
26 |
|