Unlisted
Script
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
import { discordFetch } from "https://esm.town/v/vtdocs/discordFetch?v=10";
const recipientId = "146784581280858112";
const content = "Hello from valtown!";
const botToken = Deno.env.get("discordbot"); // ?? Deno.env.get("valtownbot");
const DM = await discordFetch(
botToken,
"/users/@me/channels",
"POST",
JSON.stringify({
recipient_id: recipientId,
}),
);
console.log(DM);
// Then, we send a message via the DM
const result = await discordFetch(
botToken,
`/channels/${DM.id}/messages`,
"POST",
JSON.stringify({
content,
}),
);
console.log(result);
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!
April 23, 2024