MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / sendDiscordNotification

Function sendDiscordNotification

packages/integrations/src/discord.ts:3–26  ·  view source on GitHub ↗
({
  webhookUrl,
  message,
}: {
  webhookUrl: string;
  message: string;
})

Source from the content-addressed store, hash-verified

1// Cred to (@OpenStatusHQ) https://github.com/openstatusHQ/openstatus/blob/main/packages/notifications/discord/src/index.ts
2
3export function sendDiscordNotification({
4 webhookUrl,
5 message,
6}: {
7 webhookUrl: string;
8 message: string;
9}) {
10 return fetch(webhookUrl, {
11 method: 'POST',
12 headers: {
13 'Content-Type': 'application/json',
14 },
15 body: JSON.stringify({
16 content: message,
17 avatar_url: 'https://openpanel.dev/logo.jpg',
18 username: 'OpenPanel Notifications',
19 }),
20 }).catch((err) => {
21 return {
22 ok: false,
23 json: () => Promise.resolve({}),
24 };
25 });
26}
27
28export function sendTestDiscordNotification(webhookUrl: string) {
29 return sendDiscordNotification({

Callers 2

notificationJobFunction · 0.90

Calls 3

fetchFunction · 0.50
catchMethod · 0.45
stringifyMethod · 0.45

Tested by

no test coverage detected