1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook?v=3";
// # New Val Town User (on Clerk) -> Val Town Discord notification
// Translates one kind of webhook (Clerk) into another (Discord)
export async function handleDiscordNewUser(req: Request) {
// check custom auth secret sent from clerk
if (req.headers.get("auth") !== Deno.env.get("clerkNonSensitive"))
return new Response("Unauthorized", { status: 401 });
const body = await req.json();
await discordWebhook({
url: Deno.env.get("newUserDiscord"),
content: body.data.email_addresses[0].email_address
+ " "
+ body.data.profile_image_url,
});
return new Response("Success");
}