switch to discord hook for contact

This commit is contained in:
Benjamin Palko 2026-01-26 10:39:02 -05:00
parent 68c5fc73f4
commit 832ef7f411
5 changed files with 53 additions and 62 deletions

26
src/lib/server/discord.ts Normal file
View file

@ -0,0 +1,26 @@
import { DISCORD_CONTACT_WEBHOOK } from '$env/static/private';
export async function sendContactMessage(
name: string,
email: string,
subject: string,
message: string
) {
const form = new FormData();
// We need a better way than this to format a string to markdown
const content = `
# Someone is reaching out!
From: ${name} - [${email}](mailto:${email})
> **Subject: ${subject}**
> ${message}
`
.split('\n')
.map((str) => str.trim())
.join('\n');
form.append('content', content);
return await fetch(DISCORD_CONTACT_WEBHOOK, { method: 'POST', body: form });
}