1
Send the error to discord Failure
One script reply has been approved by the moderators Verified

Send the error to a discord webhook channel

Created by rubenfiszel 703 days ago Viewed 16801 times
0
Submitted by rubenfiszel Deno
Verified 703 days ago
1
import discordwebhook from "https://deno.land/x/discordwebhook/mod.ts";
2

3
type DiscordWebhook = {
4
  webhook_url: string;
5
};
6
export async function main(
7
  discord_webhook: DiscordWebhook,
8
  message: string,
9
  name: string,
10
) {
11
  const flow_id = Deno.env.get("WM_FLOW_JOB_ID");
12
  message = `Flow [${flow_id}](${Deno.env.get(
13
    "WM_BASE_URL",
14
  )}/run/${flow_id}?workspace=${Deno.env.get(
15
    "WM_WORKSPACE",
16
  )}) had an error:\n${name}: ${message}`;
17
  const webhook = new discordwebhook(discord_webhook.webhook_url);
18
  const ret = await webhook.createMessage(message);
19
  return ret;
20
}
21