MCPcopy Create free account
hub / github.com/anomalyco/opencode-bench / sendWebhook

Function sendWebhook

scripts/discord-sample.ts:567–597  ·  view source on GitHub ↗
(
  webhookUrl: string,
  payload: unknown,
  partIndex: number,
  totalParts: number,
)

Source from the content-addressed store, hash-verified

565 return undefined;
566}
567async function sendWebhook(
568 webhookUrl: string,
569 payload: unknown,
570 partIndex: number,
571 totalParts: number,
572): Promise<void> {
573 const partLabel = `part ${partIndex}/${totalParts}`;
574 console.log(`Sending Discord webhook (${partLabel})...`);
575 const response = await fetch(webhookUrl, {
576 method: "POST",
577 headers: {
578 "Content-Type": "application/json",
579 },
580 body: JSON.stringify(payload),
581 });
582
583 if (!response.ok) {
584 const errorText = await response.text();
585 console.error(
586 `Discord webhook request failed (${partLabel}): ${response.status} ${response.statusText}`,
587 );
588 if (errorText) {
589 console.error(`Response body: ${errorText}`);
590 }
591 throw new Error(
592 `Discord webhook request failed (${response.status} ${response.statusText})`,
593 );
594 }
595
596 console.log(`Discord webhook delivered (${partLabel}).`);
597}
598
599async function main(): Promise<void> {
600 const exportData = loadExport();

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected