Skip to content

Commit 9e292a3

Browse files
Use discord instead of slack
1 parent dd9aaa0 commit 9e292a3

File tree

2 files changed

+24
-24
lines changed

2 files changed

+24
-24
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,8 @@ rssFeed: 'https://rss.flightcast.com/w7bqgc792i30fd43a32uawx0.xml';
100100
#### Setting up the contact form
101101

102102
The contact form hits an APIRoute at `/api/contact`. It is currently configured
103-
to send the form data to a Slack channel webhook I had setup. It reads the url
104-
from `import.meta.env.SLACK_WEBHOOK`, so if you define a `SLACK_WEBHOOK`
103+
to send the form data to a Discord channel webhook. It reads the url from
104+
`import.meta.env.DISCORD_WEBHOOK`, so if you define a `DISCORD_WEBHOOK`
105105
environment variable it should work for you. Of course, feel free to customize
106106
the code [here](./src/pages/api/contact.ts) to send the data elsewhere as you
107107
see fit.

src/pages/api/contact.ts

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,34 @@ export const POST: APIRoute = async ({ request }) => {
1818
);
1919
}
2020

21-
await fetch(import.meta.env.SLACK_WEBHOOK, {
21+
await fetch(import.meta.env.DISCORD_WEBHOOK, {
2222
method: 'POST',
2323
headers: {
24-
Accept: 'application/json',
2524
'Content-Type': 'application/json'
2625
},
2726
body: JSON.stringify({
28-
blocks: [
27+
embeds: [
2928
{
30-
type: 'section',
31-
text: {
32-
type: 'mrkdwn',
33-
text: `*Name:* ${name}`
34-
}
35-
},
36-
{
37-
type: 'section',
38-
text: {
39-
type: 'mrkdwn',
40-
text: `*Email:* ${email}`
41-
}
42-
},
43-
{
44-
type: 'section',
45-
text: {
46-
type: 'mrkdwn',
47-
text: `*Message:* ${message}`
48-
}
29+
title: 'New Contact Form Submission',
30+
color: 0x5865f2,
31+
fields: [
32+
{
33+
name: 'Name',
34+
value: String(name),
35+
inline: true
36+
},
37+
{
38+
name: 'Email',
39+
value: String(email),
40+
inline: true
41+
},
42+
{
43+
name: 'Message',
44+
value: String(message),
45+
inline: false
46+
}
47+
],
48+
timestamp: new Date().toISOString()
4949
}
5050
]
5151
})

0 commit comments

Comments
 (0)