1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import process from "node:process";
import { discordAPI } from "https://esm.town/v/joey/discordAPI";
// add the bot to your server before calling:
// https://discord.com/oauth2/authorize?client_id=1099070848968691895&permissions=2048&scope=bot
//
// Usage:
// await @joey.sendDiscordMessage('some-channel-id', 'hello world!');
export const sendDiscordMessage = (channelId: string, message: string) =>
discordAPI({
path: `/channels/${channelId}/messages`,
method: "POST",
token: process.env.DISCORD_BOT_TOKEN,
body: { content: message },
});
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!
October 23, 2023