@a1-dev/discord-notifier
v0.1.4
Published
Lightweight Discord webhook notifier
Downloads
319
Readme
Discord Notifier
Lightweight Discord webhook notifier.
Install
pnpm add @a1-dev/discord-notifierOr directly from GitHub:
{
"dependencies": {
"@a1-dev/discord-notifier": "github:antofa/discord-notifier#main"
}
}Usage
import { DiscordClient } from "@a1-dev/discord-notifier";
const client = new DiscordClient({
webhookUrl: process.env.DISCORD_WEBHOOK_URL,
name: "My Bot",
});
await client.notify({
title: "Job Failed",
description: "Unexpected error while running task",
color: 0xf1c40f,
fields: [{ name: "Env", value: "prod", inline: true }],
});Example file
See test.ts for a runnable example.
Build
pnpm run buildRun test.ts
DISCORD_WEBHOOK_URL="your_webhook_url" pnpm dlx tsx test.tsWindows CMD:
set DISCORD_WEBHOOK_URL=your_webhook_url && pnpm dlx tsx test.tsLicense
MIT
