
Send a message to a Discord channel. It's useful for notifying your team or community when someone interesting happens, like a user signup, Stripe payment, mention on social media, etc.
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook/main.ts";
await discordWebhook({
url: Deno.env.get("DISCORD_WEBHOOK_URL"),
content: "Hi from val town!",
});
Example val: https://www.val.town/v/stevekrouse.discordWebhookEx
Follow the instructions here: https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks
It really only takes 2 minutes.
Paste it into val's environment variables.
import { discordWebhook } from "https://esm.town/v/stevekrouse/discordWebhook/main.ts";
await discordWebhook({
url: Deno.env.get("DISCORD_WEBHOOK_URL"),
content: "Hi from val town!",
});
Any text, rendered as markdown. If over 2000 characters, we will truncate it to the first 2000 for you.
ie SUPPRESS_EMBEDS
Learn more about flag options here: https://discord.com/developers/docs/resources/message#message-object-message-flags
This helper function only supports content
and flags
as parameters. There are other parameters that Discord supports. PRs welcome!