1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { email } from "https://esm.town/v/std/email";
import { noteToSelf } from "https://esm.town/v/wittjosiah/discord_note_to_self";
import { parse } from "https://esm.town/v/wittjosiah/parse_github_email";
export default async function(message: Email) {
try {
const { title, description, url, name, bot, reason } = parse(message);
console.log({ title, description, url, name, bot, reason });
if (bot) {
return;
}
const body = {
embeds: [{
title,
description,
url,
author: {
name,
},
footer: {
text: reason,
},
}],
};
const { status, dmId } = await noteToSelf({
body,
dmId: Deno.env.get("DISCORD_DM_ID"),
userId: Deno.env.get("DISCORD_USER_ID"),
token: Deno.env.get("DISCORD_GH_BOT_TOKEN"),
});
if (dmId) {
Deno.env.set("DISCORD_DM_ID", dmId);
}
} catch (err) {
console.error(err);
email({ text: message.text });
}
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
February 5, 2024